github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/scripts/packages/post-uninstall.sh (about)

     1  #!/bin/bash
     2  
     3  function disable_systemd {
     4    systemctl disable pyroscope-server
     5    rm -f /lib/systemd/system/pyroscope-server.service
     6  }
     7  
     8  function disable_update_rcd {
     9    update-rc.d -f pyroscope-server remove
    10    rm -f /etc/init.d/pyroscope-server
    11  }
    12  
    13  function disable_chkconfig {
    14    chkconfig --del pyroscope-server
    15    rm -f /etc/init.d/pyroscope-server
    16  }
    17  
    18  if [[ -f /etc/redhat-release ]]; then
    19    # RHEL-variant logic
    20    if [[ "$1" = "0" ]]; then
    21      # pyroscope is no longer installed, remove from init system
    22      rm -f /etc/default/pyroscope
    23  
    24      which systemctl &>/dev/null
    25      if [[ $? -eq 0 ]]; then
    26          disable_systemd
    27      else
    28          # Assuming sysv
    29          disable_chkconfig
    30      fi
    31    fi
    32  elif [[ -f /etc/lsb-release ]]; then
    33    # Debian/Ubuntu logic
    34    if [[ "$1" != "upgrade" ]]; then
    35      # Remove/purge
    36      rm -f /etc/default/pyroscope
    37  
    38      which systemctl &>/dev/null
    39      if [[ $? -eq 0 ]]; then
    40          disable_systemd
    41      else
    42          # Assuming sysv
    43          disable_update_rcd
    44      fi
    45    fi
    46  elif [[ -f /etc/os-release ]]; then
    47    source /etc/os-release
    48    if [[ $ID = "amzn" ]]; then
    49      # Amazon Linux logic
    50      if [[ "$1" = "0" ]]; then
    51          # pyroscope is no longer installed, remove from init system
    52          rm -f /etc/default/pyroscope
    53          which systemctl &>/dev/null
    54          if [[ $? -eq 0 ]]; then
    55              disable_systemd
    56          else
    57              # Assuming sysv
    58              disable_chkconfig
    59          fi
    60      fi
    61    fi
    62  fi