diff --git a/entrypoint.sh b/entrypoint.sh index 515f97e..b9f8c08 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,6 +5,7 @@ source /usr/local/bin/remote.sh source /usr/local/bin/${OS}/os.sh # Default values +REBOOT="${REBOOT:-"false"}" TARGET_CLEANUP="${TARGET_CLEANUP:-"true"}" CHECK_CONNECTION="${CHECK_CONNECTION:-"true"}" CHECK_CONNECTION_ATTEMPTS=${CHECK_CONNECTION_ATTEMPTS:-30} @@ -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 \ No newline at end of file +fi + +# Reboot machine +if [ "${REBOOT:-}" = "true" ]; then + reboot_cmd="$(ssh_cmd) $(reboot)" + $reboot_cmd +fi diff --git a/lib/os/darwin/os.sh b/lib/os/darwin/os.sh index 67afc97..17ee641 100644 --- a/lib/os/darwin/os.sh +++ b/lib/os/darwin/os.sh @@ -5,4 +5,8 @@ # #1 folder name to be removed remove_folder () { echo "rm -r ${1}" +} + +reboot() { + echo "sudo reboot" } \ No newline at end of file diff --git a/lib/os/linux/os.sh b/lib/os/linux/os.sh index 4162f82..62463b9 100644 --- a/lib/os/linux/os.sh +++ b/lib/os/linux/os.sh @@ -5,4 +5,8 @@ # #1 folder name to be removed remove_folder () { echo "rm -r ${1}" +} + +reboot() { + echo "sudo reboot" } \ No newline at end of file diff --git a/lib/os/windows/os.sh b/lib/os/windows/os.sh index 9e628ef..c136f4e 100644 --- a/lib/os/windows/os.sh +++ b/lib/os/windows/os.sh @@ -7,3 +7,6 @@ remove_folder () { echo "Remove-Item \"${1}\" -Recurse -Force" } +reboot() { + echo "Restart-Computer -Force" +} \ No newline at end of file