From 05e642103c1a22653acffc0764b81878608621e6 Mon Sep 17 00:00:00 2001 From: Pascal Fischer Date: Mon, 5 Jun 2023 21:18:42 +0200 Subject: [PATCH 1/7] kill netbird on pkg preinstall --- release_files/darwin_pkg/preinstall | 1 + 1 file changed, 1 insertion(+) diff --git a/release_files/darwin_pkg/preinstall b/release_files/darwin_pkg/preinstall index 83f571ac6..f069c2bec 100755 --- a/release_files/darwin_pkg/preinstall +++ b/release_files/darwin_pkg/preinstall @@ -5,6 +5,7 @@ LOG_FILE=/var/log/netbird/client_install.log mkdir -p /var/log/netbird/ { + pkill -f netbird || true echo "Preinstall complete" exit 0 # all good } &> $LOG_FILE From 8f51985fa548b4550a646c0bf66f92c3f89ebc0a Mon Sep 17 00:00:00 2001 From: Pascal Fischer Date: Mon, 5 Jun 2023 21:23:42 +0200 Subject: [PATCH 2/7] switch to clean stop --- release_files/darwin_pkg/preinstall | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_files/darwin_pkg/preinstall b/release_files/darwin_pkg/preinstall index f069c2bec..add71eb22 100755 --- a/release_files/darwin_pkg/preinstall +++ b/release_files/darwin_pkg/preinstall @@ -5,7 +5,7 @@ LOG_FILE=/var/log/netbird/client_install.log mkdir -p /var/log/netbird/ { - pkill -f netbird || true + osascript -e 'quit app "Netbird"' || true echo "Preinstall complete" exit 0 # all good } &> $LOG_FILE From 933fe1964afe07be20e770da9200ad5aebf48661 Mon Sep 17 00:00:00 2001 From: Pascal Fischer Date: Mon, 5 Jun 2023 21:46:13 +0200 Subject: [PATCH 3/7] revert to pkill and adding service stop --- release_files/darwin_pkg/preinstall | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/release_files/darwin_pkg/preinstall b/release_files/darwin_pkg/preinstall index add71eb22..80b8dcd97 100755 --- a/release_files/darwin_pkg/preinstall +++ b/release_files/darwin_pkg/preinstall @@ -5,7 +5,10 @@ LOG_FILE=/var/log/netbird/client_install.log mkdir -p /var/log/netbird/ { - osascript -e 'quit app "Netbird"' || true + netbird service stop || true + netbird service uninstall || true + pkill -f netbird || true + echo "Preinstall complete" exit 0 # all good } &> $LOG_FILE From bbf536be85b266c2e780aa22ed3325adc311dd63 Mon Sep 17 00:00:00 2001 From: Pascal Fischer Date: Tue, 6 Jun 2023 00:04:57 +0200 Subject: [PATCH 4/7] moved service uninstall and app close into postinstall --- release_files/darwin_pkg/postinstall | 9 +++++++-- release_files/darwin_pkg/preinstall | 4 ---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/release_files/darwin_pkg/postinstall b/release_files/darwin_pkg/postinstall index 503a2a2b5..b1e78064b 100755 --- a/release_files/darwin_pkg/postinstall +++ b/release_files/darwin_pkg/postinstall @@ -17,6 +17,8 @@ mkdir -p /usr/local/bin/ exit 1 fi + osascript -e 'quit app "Netbird"' || true + ln -s $APP/Contents/MacOS/netbird $AGENT if test -f $AGENT; then echo "NetBird binary linked successfully." @@ -25,8 +27,11 @@ mkdir -p /usr/local/bin/ exit 1 fi - $AGENT service install - $AGENT service start + $AGENT service stop || true + $AGENT service uninstall || true + + $AGENT service install || true + $AGENT service start || true open $APP diff --git a/release_files/darwin_pkg/preinstall b/release_files/darwin_pkg/preinstall index 80b8dcd97..83f571ac6 100755 --- a/release_files/darwin_pkg/preinstall +++ b/release_files/darwin_pkg/preinstall @@ -5,10 +5,6 @@ LOG_FILE=/var/log/netbird/client_install.log mkdir -p /var/log/netbird/ { - netbird service stop || true - netbird service uninstall || true - pkill -f netbird || true - echo "Preinstall complete" exit 0 # all good } &> $LOG_FILE From a0e133bd92f274e4bcc6e957eb11f146c3d75b3f Mon Sep 17 00:00:00 2001 From: Pascal Fischer Date: Tue, 6 Jun 2023 13:02:32 +0200 Subject: [PATCH 5/7] stop the daemon on brew update/install if running --- release_files/darwin-ui-installer.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/release_files/darwin-ui-installer.sh b/release_files/darwin-ui-installer.sh index 8bc194f80..df95e7c57 100644 --- a/release_files/darwin-ui-installer.sh +++ b/release_files/darwin-ui-installer.sh @@ -27,6 +27,14 @@ then echo "Please run: brew install netbirdio/tap/netbird" echo "to update it" fi + +if [ -n "$NB_BIN" ] +then + echo "Stopping and uninstalling NetBird daemon" + netbird service stop || true + netbird service uninstall || true +fi + # start netbird daemon service echo "Starting Netbird daemon" netbird service install || true From eac492be9bc811bf7ae3ef123249ce0cdd798ea1 Mon Sep 17 00:00:00 2001 From: Pascal Fischer Date: Tue, 6 Jun 2023 17:35:27 +0200 Subject: [PATCH 6/7] move stopping app and service to preinstall --- release_files/darwin_pkg/postinstall | 12 +++++------- release_files/darwin_pkg/preinstall | 9 ++++++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/release_files/darwin_pkg/postinstall b/release_files/darwin_pkg/postinstall index b1e78064b..33fa4bfee 100755 --- a/release_files/darwin_pkg/postinstall +++ b/release_files/darwin_pkg/postinstall @@ -1,8 +1,10 @@ #!/bin/sh +set -x + APP=/Applications/NetBird.app AGENT=/usr/local/bin/netbird -LOG_FILE=/var/log/netbird/client_install.log +LOG_FILE=/var/log/netbird/client_post_install.log mkdir -p /var/log/netbird/ mkdir -p /usr/local/bin/ @@ -17,9 +19,7 @@ mkdir -p /usr/local/bin/ exit 1 fi - osascript -e 'quit app "Netbird"' || true - - ln -s $APP/Contents/MacOS/netbird $AGENT + ln -fs $APP/Contents/MacOS/netbird $AGENT if test -f $AGENT; then echo "NetBird binary linked successfully." else @@ -27,9 +27,6 @@ mkdir -p /usr/local/bin/ exit 1 fi - $AGENT service stop || true - $AGENT service uninstall || true - $AGENT service install || true $AGENT service start || true @@ -38,3 +35,4 @@ mkdir -p /usr/local/bin/ echo "Finished Netbird installation successfully" exit 0 # all good } &> $LOG_FILE + diff --git a/release_files/darwin_pkg/preinstall b/release_files/darwin_pkg/preinstall index 83f571ac6..cdea1465c 100755 --- a/release_files/darwin_pkg/preinstall +++ b/release_files/darwin_pkg/preinstall @@ -1,10 +1,17 @@ #!/bin/sh -LOG_FILE=/var/log/netbird/client_install.log +set -x + +LOG_FILE=/var/log/netbird/client_pre_install.log +AGENT=/usr/local/bin/netbird mkdir -p /var/log/netbird/ { + osascript -e 'quit app "Netbird"' || true + $AGENT service stop || true + echo "Preinstall complete" exit 0 # all good } &> $LOG_FILE + From 675abbddf6f8b5361074de92595b5257c8985a95 Mon Sep 17 00:00:00 2001 From: Pascal Fischer Date: Tue, 6 Jun 2023 17:40:28 +0200 Subject: [PATCH 7/7] remove service uninstall from brew install --- release_files/darwin-ui-installer.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/release_files/darwin-ui-installer.sh b/release_files/darwin-ui-installer.sh index df95e7c57..c7fc55fd6 100644 --- a/release_files/darwin-ui-installer.sh +++ b/release_files/darwin-ui-installer.sh @@ -30,9 +30,8 @@ fi if [ -n "$NB_BIN" ] then - echo "Stopping and uninstalling NetBird daemon" + echo "Stopping NetBird daemon" netbird service stop || true - netbird service uninstall || true fi # start netbird daemon service