diff --git a/installer/src/scripts/retire.sh b/installer/src/scripts/retire.sh deleted file mode 100755 index d93fc7c8e..000000000 --- a/installer/src/scripts/retire.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -# This script is called once at the end of a cloudrons lifetime - -set -eu -o pipefail - -readonly BOX_SRC_DIR=/home/yellowtent/box - -arg_data="" - -args=$(getopt -o "" -l "data:" -n "$0" -- "$@") -eval set -- "${args}" - -while true; do - case "$1" in - --data) arg_data="$2";; - --) break;; - *) echo "Unknown option $1"; exit 1;; - esac - - shift 2 -done - -echo "Setting up splash screen" -"${BOX_SRC_DIR}/setup/splashpage.sh" --retire --data "${arg_data}" # show splash -"${BOX_SRC_DIR}/setup/stop.sh" # stop the cloudron code - -systemctl stop docker # stop the apps -systemctl stop cloudron-installer # stop the installer - diff --git a/setup/container/sudoers b/setup/container/sudoers index a1b048c8f..95ab388a7 100644 --- a/setup/container/sudoers +++ b/setup/container/sudoers @@ -30,3 +30,7 @@ yellowtent ALL=(root) NOPASSWD: /home/yellowtent/box/src/scripts/backupswap.sh Defaults!/home/yellowtent/box/src/scripts/collectlogs.sh env_keep="HOME BOX_ENV" yellowtent ALL=(root) NOPASSWD: /home/yellowtent/box/src/scripts/collectlogs.sh + +Defaults!/home/yellowtent/box/src/scripts/retire.sh env_keep="HOME BOX_ENV" +yellowtent ALL=(root) NOPASSWD: /home/yellowtent/box/src/scripts/retire.sh + diff --git a/src/cloudron.js b/src/cloudron.js index 86fbff3f5..a99975e10 100644 --- a/src/cloudron.js +++ b/src/cloudron.js @@ -790,5 +790,10 @@ function checkDiskSpace(callback) { } function retire(callback) { - shell.sudo('retire', [ RETIRE_CMD ], callback); + var data = { + isCustomDomain: config.isCustomDomain(), + fqdn: config.fqdn() + }; + shell.sudo('retire', [ RETIRE_CMD, JSON.stringify(data) ], callback); } + diff --git a/src/scripts/retire.sh b/src/scripts/retire.sh new file mode 100755 index 000000000..cc856596f --- /dev/null +++ b/src/scripts/retire.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# This script is called once at the end of a cloudrons lifetime + +set -eu -o pipefail + +if [[ ${EUID} -ne 0 ]]; then + echo "This script should be run as root." > /dev/stderr + exit 1 +fi + +readonly BOX_SRC_DIR=/home/yellowtent/box + +if [[ $# == 1 && "$1" == "--check" ]]; then + echo "OK" + exit 0 +fi + +echo "Retiring cloudron" + +if [[ "${BOX_ENV}" != "cloudron" ]]; then + exit 0 +fi + +"${BOX_SRC_DIR}/setup/splashpage.sh" --retire --data "$1" # show splash + +echo "Stopping apps" +systemctl stop docker # stop the apps + +echo "Stopping installer" +systemctl stop cloudron-installer # stop the installer + +# do this at the end since stopping the box will kill this script as well +echo "Stopping Cloudron Smartserver" +"${BOX_SRC_DIR}/setup/stop.sh"