#!/usr/bin/env sh

if [ "$1" = 'remove' ]
then
  echo 'Stopping and disabling grafana-server service...'
  if command -v systemctl >/dev/null; then
    systemctl stop grafana-server || true
    systemctl disable grafana-server || true
  elif [ -x '/etc/init.d/grafana-server' ]; then
    if command -v invoke-rc.d >/dev/null; then
      invoke-rc.d grafana-server stop || true
      update-rc.d -f grafana-server remove || true
    else
      /etc/init.d/grafana-server stop || true
    fi
  fi
fi
