netbird/release_files/post_install.sh

55 lines
1.5 KiB
Bash
Raw Permalink Normal View History

2021-05-01 12:45:37 +02:00
#!/bin/sh
# Step 1, 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
cleanInstall() {
printf "\033[32m Post Install of an clean install\033[0m\n"
# Step 3 (clean install), enable the service in the proper way for this platform
2022-05-22 18:53:47 +02:00
/usr/bin/netbird service install
/usr/bin/netbird service start
2021-05-01 12:45:37 +02:00
}
upgrade() {
printf "\033[32m Post Install of an upgrade\033[0m\n"
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 2> /dev/null || true
fi
2022-05-22 18:53:47 +02:00
if [ -e /lib/systemd/system/netbird.service ]; then
rm -f /lib/systemd/system/netbird.service
systemctl daemon-reload
2021-05-01 12:45:37 +02:00
fi
# will trow an error until everyone upgrade
2022-05-22 18:53:47 +02:00
/usr/bin/netbird service uninstall 2> /dev/null || true
/usr/bin/netbird service install
/usr/bin/netbird service start
2021-05-01 12:45:37 +02:00
}
# Check if this is a clean install or an upgrade
2021-05-01 12:45:37 +02:00
action="$1"
if [ "$1" = "configure" ] && [ -z "$2" ]; then
# Alpine linux does not pass args, and deb passes $1=configure
action="install"
elif [ "$1" = "configure" ] && [ -n "$2" ]; then
# deb passes $1=configure $2=<current version>
action="upgrade"
fi
case "$action" in
"1" | "install")
cleanInstall
;;
"2" | "upgrade")
upgrade
;;
*)
cleanInstall
;;
esac