From 42c7d51a5fd1f6c918738c4bfdc96756836ea422 Mon Sep 17 00:00:00 2001 From: Alessandro OSIAS Date: Thu, 26 Oct 2023 15:07:03 +0200 Subject: [PATCH 1/9] Test rportd log --- .github/scripts/functional_test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/scripts/functional_test.sh b/.github/scripts/functional_test.sh index f3a9e55..cfbf384 100644 --- a/.github/scripts/functional_test.sh +++ b/.github/scripts/functional_test.sh @@ -35,6 +35,7 @@ sudo sh rport-installer.sh -h|grep "Install with SELinux enabled" echo "Executing the install now" sudo sh rport-installer.sh -x -s +cat /tmp/rportd.log # Verify the client has connected to the local rportd echo "Verifying client is connected to server" grep "client-listener.*Listening.*$(hostname)" /tmp/rportd.log From db642fc2798175a6b2ba3d2b4478bb4f21abc65b Mon Sep 17 00:00:00 2001 From: Alessandro OSIAS Date: Thu, 26 Oct 2023 17:15:40 +0200 Subject: [PATCH 2/9] Fix grep command --- .github/scripts/functional_test.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/scripts/functional_test.sh b/.github/scripts/functional_test.sh index cfbf384..6ff8ec8 100644 --- a/.github/scripts/functional_test.sh +++ b/.github/scripts/functional_test.sh @@ -35,7 +35,11 @@ sudo sh rport-installer.sh -h|grep "Install with SELinux enabled" echo "Executing the install now" sudo sh rport-installer.sh -x -s +echo "Display log for rportd" cat /tmp/rportd.log + +echo "Display hostname" +$(hostname) # Verify the client has connected to the local rportd echo "Verifying client is connected to server" grep "client-listener.*Listening.*$(hostname)" /tmp/rportd.log From 2155ac337c15f4dfdc2bccc2abb0ed571ccb7b75 Mon Sep 17 00:00:00 2001 From: Alessandro OSIAS Date: Thu, 26 Oct 2023 17:18:42 +0200 Subject: [PATCH 3/9] Fix grep command --- .github/scripts/functional_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/functional_test.sh b/.github/scripts/functional_test.sh index 6ff8ec8..1b633db 100644 --- a/.github/scripts/functional_test.sh +++ b/.github/scripts/functional_test.sh @@ -39,7 +39,7 @@ echo "Display log for rportd" cat /tmp/rportd.log echo "Display hostname" -$(hostname) +echo $(hostname) # Verify the client has connected to the local rportd echo "Verifying client is connected to server" grep "client-listener.*Listening.*$(hostname)" /tmp/rportd.log From 33ffa966ddfc74c2e2da038ca4dfd2fb4f4f08e9 Mon Sep 17 00:00:00 2001 From: Alessandro OSIAS Date: Thu, 26 Oct 2023 17:23:55 +0200 Subject: [PATCH 4/9] Fix grep command --- .github/scripts/functional_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/functional_test.sh b/.github/scripts/functional_test.sh index 1b633db..b845cd5 100644 --- a/.github/scripts/functional_test.sh +++ b/.github/scripts/functional_test.sh @@ -42,7 +42,7 @@ echo "Display hostname" echo $(hostname) # Verify the client has connected to the local rportd echo "Verifying client is connected to server" -grep "client-listener.*Listening.*$(hostname)" /tmp/rportd.log +grep "client-listener.*Listening.*" /tmp/rportd.log # Execute the update script echo "Executing the update script now" From a9d5df1e117f6140d835a3994db8ee185a0c9e48 Mon Sep 17 00:00:00 2001 From: Alessandro OSIAS Date: Thu, 26 Oct 2023 19:36:05 +0200 Subject: [PATCH 5/9] Update template update to fix shellcheck error --- retrieve/templates/linux/update.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/retrieve/templates/linux/update.sh b/retrieve/templates/linux/update.sh index 88f6009..116bc68 100644 --- a/retrieve/templates/linux/update.sh +++ b/retrieve/templates/linux/update.sh @@ -140,6 +140,7 @@ check_scripts() { else echo 1>&2 "Please use the switches -x/-d to enable or disable script execution." help + # shellcheck disable=SC2317 # Don't warn about unreachable commands in this function exit 1 fi if ask_yes_no "Do you want to activate script execution?"; then @@ -165,6 +166,7 @@ check_sudo() { else echo 1>&2 "Please use the switches -s/-n to enable or disable sudo rights." help + # shellcheck disable=SC2317 # Don't warn about unreachable commands in this function exit 1 fi if ask_yes_no "Do you want to activate sudo rights for RPort remote script execution?"; then From a6b186fa6f9c3a3f1e19c4cbf512f28f5e330d29 Mon Sep 17 00:00:00 2001 From: Alessandro OSIAS Date: Thu, 26 Oct 2023 19:42:40 +0200 Subject: [PATCH 6/9] Adding throw_info into update.sh --- retrieve/templates/linux/update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/retrieve/templates/linux/update.sh b/retrieve/templates/linux/update.sh index 116bc68..93aba18 100644 --- a/retrieve/templates/linux/update.sh +++ b/retrieve/templates/linux/update.sh @@ -45,10 +45,10 @@ restart_rport() { 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." + throw_info "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." + throw_info "Restart of rport scheduled via nohup+sleep." fi return 0 fi From 3bf82a0a04f2b7b185738fdbf525a3ebcbd2ff82 Mon Sep 17 00:00:00 2001 From: Alessandro OSIAS Date: Thu, 26 Oct 2023 19:46:17 +0200 Subject: [PATCH 7/9] Adding throw_info into update.sh --- retrieve/templates/linux/update.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/retrieve/templates/linux/update.sh b/retrieve/templates/linux/update.sh index 93aba18..4bf387c 100644 --- a/retrieve/templates/linux/update.sh +++ b/retrieve/templates/linux/update.sh @@ -37,23 +37,23 @@ current_version() { # RETURNS: #---------------------------------------------------------------------------------------------------------------------- restart_rport() { - if [ -e /etc/init.d/rport ]; then - RESTART_CMD='/etc/init.d/rport restart' - else - RESTART_CMD='systemctl restart rport' - fi - if [ "$1" = "background" ]; then - if command -v at >/dev/null 2>&1; then - echo "$RESTART_CMD" | at now +1 minute - throw_info "Restart of rport scheduled via atd." + if [ -e /etc/init.d/rport ]; then + RESTART_CMD='/etc/init.d/rport restart' else - nohup sh -c "sleep 10;$RESTART_CMD" >/dev/null 2>&1 & - throw_info "Restart of rport scheduled via nohup+sleep." + RESTART_CMD='systemctl restart rport' fi - return 0 - fi - throw_info "Restarting RPort using '$RESTART_CMD'" - $RESTART_CMD + if [ "$1" = "background" ]; then + if command -v at >/dev/null 2>&1; then + echo "$RESTART_CMD" | at now +1 minute + throw_info "Restart of rport scheduled via atd." + else + nohup sh -c "sleep 10;$RESTART_CMD" >/dev/null 2>&1 & + throw_info "Restart of rport scheduled via nohup+sleep." + fi + return 0 + fi + throw_info "Restarting RPort using '$RESTART_CMD'" + $RESTART_CMD } #--- FUNCTION ------------------------------------------------------------------------------------------------------- # NAME: update From 2cb007b6d9a38ba15abe97c7167bf528443ea177 Mon Sep 17 00:00:00 2001 From: Alessandro OSIAS Date: Thu, 26 Oct 2023 20:17:39 +0200 Subject: [PATCH 8/9] Update script --- .github/scripts/functional_test.sh | 5 ----- retrieve/templates/linux/functions.sh | 12 ++++++------ retrieve/templates/linux/update.sh | 7 ++++--- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.github/scripts/functional_test.sh b/.github/scripts/functional_test.sh index b845cd5..30f28dd 100644 --- a/.github/scripts/functional_test.sh +++ b/.github/scripts/functional_test.sh @@ -35,11 +35,6 @@ sudo sh rport-installer.sh -h|grep "Install with SELinux enabled" echo "Executing the install now" sudo sh rport-installer.sh -x -s -echo "Display log for rportd" -cat /tmp/rportd.log - -echo "Display hostname" -echo $(hostname) # Verify the client has connected to the local rportd echo "Verifying client is connected to server" grep "client-listener.*Listening.*" /tmp/rportd.log diff --git a/retrieve/templates/linux/functions.sh b/retrieve/templates/linux/functions.sh index 3ced656..989d3ba 100644 --- a/retrieve/templates/linux/functions.sh +++ b/retrieve/templates/linux/functions.sh @@ -155,7 +155,7 @@ has_sudo() { create_sudoers_all() { SUDOERS_FILE=/etc/sudoers.d/rport-all-cmd if [ -e "$SUDOERS_FILE" ]; then - echo "You already have a $SUDOERS_FILE. Not changing." + throw_info "You already have a $SUDOERS_FILE. Not changing." return 1 fi @@ -179,7 +179,7 @@ ${USER} ALL=(ALL) NOPASSWD:ALL create_sudoers_updates() { SUDOERS_FILE=/etc/sudoers.d/rport-update-status if [ -e "$SUDOERS_FILE" ]; then - echo "You already have a $SUDOERS_FILE. Not changing." + throw_info "You already have a $SUDOERS_FILE. Not changing." return 0 fi @@ -264,10 +264,10 @@ update_tacoscript() { curl -LSso tacoscript.tar.gz "https://download.rport.io/tacoscript/${RELEASE}/?arch=Linux_${ARCH}>=$TACO_VERSION" if tar xzf tacoscript.tar.gz 2>/dev/null; then echo "" - echo "Updating Tacoscript from ${TACO_VERSION} to latest ${RELEASE} $(./tacoscript --version | grep -o "Version:.*")" + throw_info "Updating Tacoscript from ${TACO_VERSION} to latest ${RELEASE} $(./tacoscript --version | grep -o "Version:.*")" mv -f /tmp/tacoscript /usr/local/bin/tacoscript else - echo "Nothing to do. Tacoscript is on the latest version ${TACO_VERSION}." + throw_info "Nothing to do. Tacoscript is on the latest version ${TACO_VERSION}." fi } @@ -277,7 +277,7 @@ update_tacoscript() { #---------------------------------------------------------------------------------------------------------------------- install_tacoscript() { if [ -e /usr/local/bin/tacoscript ]; then - echo "Tacoscript already installed. Checking for updates ..." + throw_info "Tacoscript already installed. Checking for updates ..." update_tacoscript return 0 fi @@ -672,4 +672,4 @@ abort_on_rport_subprocess() { throw_hint ' nohup sh -c "curl -s https://pairing.openrport.io/update|sh" >/tmp/rport-update.log 2>&1 &' throw_fatal "You cannot update rport from an rport subprocess." fi -} \ No newline at end of file +} diff --git a/retrieve/templates/linux/update.sh b/retrieve/templates/linux/update.sh index 4bf387c..049b155 100644 --- a/retrieve/templates/linux/update.sh +++ b/retrieve/templates/linux/update.sh @@ -63,10 +63,11 @@ update() { check_prerequisites cd /tmp download_package + RESTART_IN="background" test -e rport && rm -f rport if tar xzf rport.tar.gz rport 2>/dev/null; then TARGET_VERSION=$(./rport --version | awk '{print $2}') - echo "Updating from ${CURRENT_VERSION} to latest ${RELEASE} $(./rport --version)" + throw_info "Updating from ${CURRENT_VERSION} to latest ${RELEASE} $(./rport --version)" check_scripts check_sudo create_sudoers_updates @@ -76,9 +77,9 @@ update() { enable_file_reception insert_watchdog mv -f /tmp/rport /usr/local/bin/rport - restart_rport + restart_rport $RESTART_IN else - echo "Nothing to do. RPort is on the latest version ${CURRENT_VERSION}." + throw_info "Nothing to do. RPort is on the latest version ${CURRENT_VERSION}." [ "$ENABLE_TACOSCRIPT" -eq 1 ] && install_tacoscript exit 0 fi From 78958a1ab5a8a3f6d74f0b19884183547b99acd0 Mon Sep 17 00:00:00 2001 From: Alessandro OSIAS Date: Thu, 26 Oct 2023 20:26:45 +0200 Subject: [PATCH 9/9] Fix install windows test --- .github/scripts/run_rport_server.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/run_rport_server.ps1 b/.github/scripts/run_rport_server.ps1 index 7abd0dc..d5ed2be 100644 --- a/.github/scripts/run_rport_server.ps1 +++ b/.github/scripts/run_rport_server.ps1 @@ -1,7 +1,7 @@ $ErrorActionPreference = "Stop" mkdir C:\rport Set-Location C:\rport -Invoke-WebRequest "https://download.rport.io/rportd/stable/?arch=Windows_x86_64" -OutFile rportd.zip +Invoke-WebRequest "https://download.openrport.io/rportd/stable/?arch=_x86_64" -OutFile rportd.zip Expand-Archive rportd.zip . ./rportd --version