From 1929dcbbbcabf723c8b0cb15e1c8d5c9d0773b57 Mon Sep 17 00:00:00 2001 From: Alessandro OSIAS Date: Sat, 7 Oct 2023 18:17:17 +0200 Subject: [PATCH] update update script --- .github/scripts/functional_test.sh | 2 +- .gitignore | 1 + retrieve/templates/linux/update.sh | 32 +++++++++++++++++++++++------- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/.github/scripts/functional_test.sh b/.github/scripts/functional_test.sh index ccab10a..f3a9e55 100644 --- a/.github/scripts/functional_test.sh +++ b/.github/scripts/functional_test.sh @@ -37,7 +37,7 @@ sudo sh rport-installer.sh -x -s # Verify the client has connected to the local rportd echo "Verifying client is connected to server" -grep "client-listener.*open.*$(hostname)" /tmp/rportd.log +grep "client-listener.*Listening.*$(hostname)" /tmp/rportd.log # Execute the update script echo "Executing the update script now" diff --git a/.gitignore b/.gitignore index 5660c6b..33e6a4f 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ release.sh push_to_prod.sh rport.example.conf .idea +dist \ No newline at end of file diff --git a/retrieve/templates/linux/update.sh b/retrieve/templates/linux/update.sh index 536b7ad..88f6009 100644 --- a/retrieve/templates/linux/update.sh +++ b/retrieve/templates/linux/update.sh @@ -16,6 +16,19 @@ download_package() { curl -Ls "${URL}" -o rport.tar.gz } +current_version() { + if [ -e /usr/bin/rport ]; then + /usr/bin/rport --version | awk '{print $2}' + return 0 + fi + if [ -e /usr/local/bin/rport ]; then + /usr/local/bin/rport --version | awk '{print $2}' + return 0 + fi + echo "Failed to get current rport version" + exit 1 +} + #--- FUNCTION ------------------------------------------------------------------------------------------------------- # NAME: restart_rport() # DESCRIPTION: The restart of RPort must be detached from this process in case the update @@ -29,13 +42,18 @@ restart_rport() { else RESTART_CMD='systemctl restart rport' fi - if command -v at >/dev/null 2>&1; then - echo "$RESTART_CMD" | at now +1 minute - echo "Restart of rport scheduled via atd." - else - nohup sh -c "sleep 10;$RESTART_CMD" >/dev/null 2>&1 & - echo "Restart of rport scheduled via nohup+sleep." + if [ "$1" = "background" ]; then + if command -v at >/dev/null 2>&1; then + echo "$RESTART_CMD" | at now +1 minute + echo "Restart of rport scheduled via atd." + else + nohup sh -c "sleep 10;$RESTART_CMD" >/dev/null 2>&1 & + echo "Restart of rport scheduled via nohup+sleep." + fi + return 0 fi + throw_info "Restarting RPort using '$RESTART_CMD'" + $RESTART_CMD } #--- FUNCTION ------------------------------------------------------------------------------------------------------- # NAME: update @@ -228,7 +246,7 @@ insert_watchdog() { ## Write a state file to {data_dir}/state.json that can be evaluated by external watchdog implementations. ## On Linux this also enables the systemd watchdog integration using the systemd notify socket. ## Requires max_retry_count = -1 and keep_alive > 0 - ## Read more https://oss.rport.io/advanced/watchdog-integration/ + ## Read more https://oss.openrport.io/advanced/watchdog-integration/ ## Disabled by default. #watchdog_integration = false EOF