Skip to content

Commit

Permalink
Merge pull request #11 from alhdo/windows_test
Browse files Browse the repository at this point in the history
Windows test
  • Loading branch information
alhdo authored Oct 26, 2023
2 parents 6186acb + 78958a1 commit 97d1061
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 26 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.*Listening.*$(hostname)" /tmp/rportd.log
grep "client-listener.*Listening.*" /tmp/rportd.log

# Execute the update script
echo "Executing the update script now"
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/run_rport_server.ps1
Original file line number Diff line number Diff line change
@@ -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

Expand Down
12 changes: 6 additions & 6 deletions retrieve/templates/linux/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -264,10 +264,10 @@ update_tacoscript() {
curl -LSso tacoscript.tar.gz "https://download.rport.io/tacoscript/${RELEASE}/?arch=Linux_${ARCH}&gt=$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
}

Expand All @@ -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
Expand Down Expand Up @@ -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
}
}
39 changes: 21 additions & 18 deletions retrieve/templates/linux/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
echo "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 &
echo "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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -140,6 +141,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
Expand All @@ -165,6 +167,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
Expand Down

0 comments on commit 97d1061

Please sign in to comment.