diff --git a/setup/argparser.sh b/setup/argparser.sh index 838e47a17..710767fb1 100644 --- a/setup/argparser.sh +++ b/setup/argparser.sh @@ -10,7 +10,8 @@ arg_fqdn="" arg_is_custom_domain="false" arg_restore_key="" arg_restore_url="" -arg_retire="" +arg_retire_reason="" +arg_retire_info="" arg_tls_config="" arg_tls_cert="" arg_tls_key="" @@ -23,13 +24,17 @@ arg_update_config="" arg_provider="" arg_app_bundle="" -args=$(getopt -o "" -l "data:,retire:" -n "$0" -- "$@") +args=$(getopt -o "" -l "data:,retire-reason:retire-info:" -n "$0" -- "$@") eval set -- "${args}" while true; do case "$1" in - --retire) - arg_retire="$2" + --retire-reason) + arg_retire_reason="$2" + shift 2 + ;; + --retire-info) + arg_retire_info="$2" shift 2 ;; --data) diff --git a/setup/splashpage.sh b/setup/splashpage.sh index 1c1cc066a..f8a4a1a89 100755 --- a/setup/splashpage.sh +++ b/setup/splashpage.sh @@ -25,8 +25,8 @@ cp -r "${script_dir}/splash/website/"* "${SETUP_WEBSITE_DIR}" readonly current_infra=$(node -e "console.log(require('${script_dir}/../src/infra_version.js').version);") existing_infra="none" [[ -f "${DATA_DIR}/INFRA_VERSION" ]] && existing_infra=$(node -e "console.log(JSON.parse(require('fs').readFileSync('${DATA_DIR}/INFRA_VERSION', 'utf8')).version);") -if [[ "${arg_retire}" != "" || "${existing_infra}" != "${current_infra}" ]]; then - echo "Showing progress bar on all subdomains in retired mode or infra update. retire: ${arg_retire} existing: ${existing_infra} current: ${current_infra}" +if [[ "${arg_retire_reason}" != "" || "${existing_infra}" != "${current_infra}" ]]; then + echo "Showing progress bar on all subdomains in retired mode or infra update. retire: ${arg_retire_reason} existing: ${existing_infra} current: ${current_infra}" rm -f ${DATA_DIR}/nginx/applications/* ${BOX_SRC_DIR}/node_modules/.bin/ejs-cli -f "${script_dir}/start/nginx/appconfig.ejs" \ -O "{ \"vhost\": \"~^(.+)\$\", \"adminOrigin\": \"${admin_origin}\", \"endpoint\": \"splash\", \"sourceDir\": \"${SETUP_WEBSITE_DIR}\", \"certFilePath\": \"cert/host.cert\", \"keyFilePath\": \"cert/host.key\" }" > "${DATA_DIR}/nginx/applications/admin.conf" @@ -36,8 +36,8 @@ else -O "{ \"vhost\": \"${admin_fqdn}\", \"adminOrigin\": \"${admin_origin}\", \"endpoint\": \"splash\", \"sourceDir\": \"${SETUP_WEBSITE_DIR}\", \"certFilePath\": \"cert/host.cert\", \"keyFilePath\": \"cert/host.key\" }" > "${DATA_DIR}/nginx/applications/admin.conf" fi -if [[ "${arg_retire}" == "migrate" ]]; then - echo '{ "migrate": { "percent": "10", "message": "Migrating cloudron. This could take up to 15 minutes." }, "backup": null }' > "${SETUP_WEBSITE_DIR}/progress.json" +if [[ "${arg_retire_reason}" == "migrate" ]]; then + echo "{ \"migrate\": { \"percent\": \"10\", \"message\": \"Migrating cloudron. This could take up to 15 minutes.\", \"info\": \"${arg_retire_info}\" }, \"backup\": null }" > "${SETUP_WEBSITE_DIR}/progress.json" else echo '{ "update": { "percent": "10", "message": "Updating cloudron software" }, "backup": null }' > "${SETUP_WEBSITE_DIR}/progress.json" fi diff --git a/src/cloudron.js b/src/cloudron.js index 4b1f96031..b6e18228f 100644 --- a/src/cloudron.js +++ b/src/cloudron.js @@ -705,15 +705,16 @@ function checkDiskSpace(callback) { }); } -function retire(reason, callback) { +function retire(reason, info, callback) { assert(reason === 'migrate' || reason === 'upgrade'); + info = info || { }; callback = callback || NOOP_CALLBACK; var data = { isCustomDomain: config.isCustomDomain(), fqdn: config.fqdn() }; - shell.sudo('retire', [ RETIRE_CMD, reason, JSON.stringify(data) ], callback); + shell.sudo('retire', [ RETIRE_CMD, reason, JSON.stringify(info), JSON.stringify(data) ], callback); } function doMigrate(options, callback) { @@ -751,7 +752,7 @@ function doMigrate(options, callback) { progress.set(progress.MIGRATE, 10, 'Migrating'); - retire('migrate'); + retire('migrate', _.pick(options, 'domain', 'size', 'region')); }); }); diff --git a/src/scripts/retire.sh b/src/scripts/retire.sh index 7d903711b..09a88b672 100755 --- a/src/scripts/retire.sh +++ b/src/scripts/retire.sh @@ -20,7 +20,7 @@ if [[ "${BOX_ENV}" != "cloudron" ]]; then exit 0 fi -"${BOX_SRC_DIR}/setup/splashpage.sh" --retire "$1" --data "$2" # show splash +"${BOX_SRC_DIR}/setup/splashpage.sh" --retire-reason "$1" --retire-info "$2" --data "$3" # show splash echo "Stopping apps" systemctl stop docker # stop the apps