mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-24 03:06:38 +00:00
Enhance up command (#133)
* move setup-key to root command * up will check login and start service * update tests to reflect new UP capabilities * display client IP * removed unused argument * install service if not installed * update post-install and add pre remove script * improve log messages * handle service status failures and install service when needed * removing unused files * update documentation and description * add version command * update service lib version * using lib constant for not installed services * match version from goreleaser * fix: graceful shutdown * stop only if service is running * add logs initialization to service controller commands Co-authored-by: braginini <bangvalo@gmail.com>
This commit is contained in:
@@ -12,30 +12,25 @@ 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
|
||||
if [ "${use_systemctl}" = "True" ]; then
|
||||
printf "\033[32m Reload the service unit from disk\033[0m\n"
|
||||
systemctl daemon-reload ||:
|
||||
printf "\033[32m Unmask the service\033[0m\n"
|
||||
systemctl unmask wiretrustee ||:
|
||||
printf "\033[32m Set the preset flag for the service unit\033[0m\n"
|
||||
systemctl preset wiretrustee ||:
|
||||
printf "\033[32m Set the enabled flag for the service unit\033[0m\n"
|
||||
systemctl enable wiretrustee ||:
|
||||
systemctl restart wiretrustee ||:
|
||||
fi
|
||||
/usr/local/bin/wiretrustee service install
|
||||
}
|
||||
|
||||
upgrade() {
|
||||
printf "\033[32m Post Install of an upgrade\033[0m\n"
|
||||
if [ "${use_systemctl}" = "True" ]; then
|
||||
printf "\033[32m Reload the service unit from disk\033[0m\n"
|
||||
systemctl daemon-reload ||:
|
||||
printf "\033[32m Restarting the service\033[0m\n"
|
||||
systemctl restart wiretrustee ||:
|
||||
printf "\033[32m Stopping the service\033[0m\n"
|
||||
systemctl stop wiretrustee
|
||||
fi
|
||||
if [ -e /lib/systemd/system/wiretrustee.service ]; then
|
||||
rm -f /lib/systemd/system/wiretrustee.service
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
# will trow an error until everyone upgrade
|
||||
/usr/local/bin/wiretrustee service uninstall
|
||||
/usr/local/bin/wiretrustee service install
|
||||
}
|
||||
|
||||
# Step 2, check if this is a clean install or an upgrade
|
||||
# Check if this is a clean install or an upgrade
|
||||
action="$1"
|
||||
if [ "$1" = "configure" ] && [ -z "$2" ]; then
|
||||
# Alpine linux does not pass args, and deb passes $1=configure
|
||||
|
||||
30
release_files/pre_remove.sh
Normal file
30
release_files/pre_remove.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/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
|
||||
|
||||
printf "\033[32m Pre uninstall\033[0m\n"
|
||||
|
||||
if [ "${use_systemctl}" = "True" ]; then
|
||||
printf "\033[32m Stopping the service\033[0m\n"
|
||||
systemctl stop wiretrustee
|
||||
|
||||
if [ -e /lib/systemd/system/wiretrustee.service ]; then
|
||||
rm -f /lib/systemd/system/wiretrustee.service
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
|
||||
fi
|
||||
printf "\033[32m Uninstalling the service\033[0m\n"
|
||||
/usr/local/bin/wiretrustee service uninstall
|
||||
|
||||
|
||||
if [ "${use_systemctl}" = "True" ]; then
|
||||
printf "\n\033[32m running daemon reload\033[0m\n"
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
@@ -1,30 +0,0 @@
|
||||
{
|
||||
"PrivateKey": "",
|
||||
"Peers": [
|
||||
{
|
||||
"WgPubKey": "",
|
||||
"WgAllowedIps": ""
|
||||
}
|
||||
],
|
||||
"StunTurnURLs": [
|
||||
{
|
||||
"Scheme": 1,
|
||||
"Host": "",
|
||||
"Port": 3468,
|
||||
"Username": "",
|
||||
"Password": "",
|
||||
"Proto": 1
|
||||
},
|
||||
{
|
||||
"Scheme": 3,
|
||||
"Host": "",
|
||||
"Port": 3468,
|
||||
"Username": "",
|
||||
"Password": "",
|
||||
"Proto": 1
|
||||
}
|
||||
],
|
||||
"SignalAddr": "",
|
||||
"WgAddr": "",
|
||||
"WgIface": ""
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
[Unit]
|
||||
Description=Wiretrustee Service
|
||||
After=multi-user.target network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/local/bin/wiretrustee up --config /etc/wiretrustee/config.json --log-level debug
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user