github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/debian/postrm (about)

     1  #!/bin/bash
     2  
     3  if [ "$1" = "purge" ]; then
     4      if [[ -e /usr/share/debconf/confmodule ]]; then
     5          # Source debconf library.
     6          . /usr/share/debconf/confmodule
     7          # Remove my changes to the db.
     8          db_purge
     9      else
    10          printf  "confmodule is missing, debconf db data was not purged..\n"
    11      fi
    12  fi
    13  
    14  function disable_systemd {
    15      system_service=/lib/systemd/system/mysterium-node.service
    16      system_consumer=/lib/systemd/system/mysterium-consumer.service
    17      if [ ! -e $system_service ]; then
    18          return
    19      fi
    20      printf  "Disabling systemd script '$system_service' and '$system_consumer'..\n"
    21      systemctl stop mysterium-node
    22      systemctl disable mysterium-node
    23      systemctl stop mysterium-consumer
    24      systemctl disable mysterium-consumer
    25      rm -f $system_service $system_consumer
    26  }
    27  
    28  function disable_update_rcd {
    29      initd=/etc/init.d/mysterium-node
    30      printf  "Disabling initd script '$initd'..\n"
    31      update-rc.d -f mysterium-node remove
    32      rm -f $initd
    33  }
    34  
    35  function disable_chkconfig {
    36      printf  "Disabling chkconfig..\n"
    37      chkconfig --del mysterium-node
    38      rm -f /etc/init.d/mysterium-node
    39  }
    40  
    41  if [[ -f /etc/redhat-release ]]; then
    42      # RHEL-variant logic
    43      if [[ "$1" = "0" ]]; then
    44  	# MysteriumNode is no longer installed, remove from init system
    45  	rm -f /etc/default/mysterium-node
    46  
    47  	which systemctl &>/dev/null
    48  	if [[ $? -eq 0 ]]; then
    49  	    disable_systemd
    50  	else
    51  	    # Assuming sysv
    52  	    disable_chkconfig
    53  	fi
    54      fi
    55  elif [[ -f /etc/lsb-release ]]; then
    56      # Debian/Ubuntu logic
    57      if [[ "$1" != "upgrade" ]]; then
    58  	# Remove/purge
    59  	rm -f /etc/default/mysterium-node
    60  
    61  	which systemctl &>/dev/null
    62  	if [[ $? -eq 0 ]]; then
    63  	    disable_systemd
    64  	else
    65  	    # Assuming sysv
    66  	    disable_update_rcd
    67  	fi
    68      fi
    69  elif [[ -f /etc/os-release ]]; then
    70      source /etc/os-release
    71      if [[ $ID = "amzn" ]]; then
    72  	# Amazon Linux logic
    73  	if [[ "$1" = "0" ]]; then
    74  	    # MysteriumNode is no longer installed, remove from init system
    75  	    rm -f /etc/default/mysterium-node
    76  	    disable_chkconfig
    77  	fi
    78      fi
    79  fi
    80  
    81  #DEBHELPER#