Skip to content

Commit

Permalink
Merge pull request #9 from alhdo/main
Browse files Browse the repository at this point in the history
update update script
  • Loading branch information
alhdo authored Oct 7, 2023
2 parents 9a2a9a4 + 1929dcb commit 921554f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/functional_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ release.sh
push_to_prod.sh
rport.example.conf
.idea
dist
32 changes: 25 additions & 7 deletions retrieve/templates/linux/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 921554f

Please sign in to comment.