Skip to content

Commit

Permalink
the target machine may needs reboot after test, add reboot option
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyLuLiu committed Dec 17, 2024
1 parent 73774d5 commit 8bf03fe
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ source /usr/local/bin/remote.sh
source /usr/local/bin/${OS}/os.sh

# Default values
REBOOT="${TARGET_CLEANUP:-"false"}"
TARGET_CLEANUP="${TARGET_CLEANUP:-"true"}"
CHECK_CONNECTION="${CHECK_CONNECTION:-"true"}"
CHECK_CONNECTION_ATTEMPTS=${CHECK_CONNECTION_ATTEMPTS:-30}
Expand Down Expand Up @@ -72,4 +73,10 @@ if [ "${TARGET_CLEANUP:-}" = "true" ]; then
# This will create the cmd based on OS env with the right syntax
cmd="$(remove_folder ${TARGET_FOLDER})"
exec_and_retry ${SSH_CMD_ATTEMPTS} ${SSH_CMD_DELAY} "$(ssh_cmd $cmd)"
fi

# Reboot machine
if [ "${REBOOT:-}" = "true" ]; then
reboot_cmd="$(ssh_cmd) $(reboot)"
$reboot_cmd
fi
4 changes: 4 additions & 0 deletions lib/os/darwin/os.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
# #1 folder name to be removed
remove_folder () {
echo "rm -r ${1}"
}

reboot() {
echo "sudo reboot"
}
4 changes: 4 additions & 0 deletions lib/os/linux/os.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
# #1 folder name to be removed
remove_folder () {
echo "rm -r ${1}"
}

reboot() {
echo "sudo reboot"
}
3 changes: 3 additions & 0 deletions lib/os/windows/os.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ remove_folder () {
echo "Remove-Item \"${1}\" -Recurse -Force"
}

reboot() {
echo "Restart-Computer -Force"
}

0 comments on commit 8bf03fe

Please sign in to comment.