2021-10-17 21:34:07 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# decide if we should use systemd or init/upstart
|
|
|
|
use_systemctl="True"
|
|
|
|
systemd_version=0
|
|
|
|
if ! command -V systemctl >/dev/null 2>&1; then
|
|
|
|
use_systemctl="False"
|
|
|
|
else
|
|
|
|
systemd_version=$(systemctl --version | head -1 | sed 's/systemd //g')
|
|
|
|
fi
|
|
|
|
|
2021-10-20 11:51:32 +02:00
|
|
|
remove() {
|
|
|
|
printf "\033[32m Pre uninstall\033[0m\n"
|
2021-10-17 21:34:07 +02:00
|
|
|
|
2021-10-20 11:51:32 +02:00
|
|
|
if [ "${use_systemctl}" = "True" ]; then
|
|
|
|
printf "\033[32m Stopping the service\033[0m\n"
|
2022-05-22 18:53:47 +02:00
|
|
|
systemctl stop netbird || true
|
2021-10-20 11:51:32 +02:00
|
|
|
|
2022-05-22 18:53:47 +02:00
|
|
|
if [ -e /lib/systemd/system/netbird.service ]; then
|
|
|
|
rm -f /lib/systemd/system/netbird.service
|
2021-10-20 11:51:32 +02:00
|
|
|
systemctl daemon-reload || true
|
|
|
|
fi
|
2021-10-17 21:34:07 +02:00
|
|
|
|
|
|
|
fi
|
2021-10-20 11:51:32 +02:00
|
|
|
printf "\033[32m Uninstalling the service\033[0m\n"
|
2022-05-22 18:53:47 +02:00
|
|
|
/usr/bin/netbird service uninstall || true
|
2021-10-17 21:34:07 +02:00
|
|
|
|
|
|
|
|
2021-10-20 11:51:32 +02:00
|
|
|
if [ "${use_systemctl}" = "True" ]; then
|
|
|
|
printf "\n\033[32m running daemon reload\033[0m\n"
|
|
|
|
systemctl daemon-reload || true
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
action="$1"
|
2021-10-17 21:34:07 +02:00
|
|
|
|
2021-10-20 11:51:32 +02:00
|
|
|
case "$action" in
|
|
|
|
"0" | "remove")
|
|
|
|
remove
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|