diff --git a/setup/argparser.sh b/setup/argparser.sh index 6d9b5caf0..306ecfd78 100644 --- a/setup/argparser.sh +++ b/setup/argparser.sh @@ -10,7 +10,7 @@ arg_fqdn="" arg_is_custom_domain="false" arg_restore_key="" arg_restore_url="" -arg_retire="false" +arg_retire="" arg_tls_config="" arg_tls_cert="" arg_tls_key="" @@ -23,14 +23,14 @@ arg_update_config="" arg_provider="" arg_app_bundle="" -args=$(getopt -o "" -l "data:,retire" -n "$0" -- "$@") +args=$(getopt -o "" -l "data:,retire:" -n "$0" -- "$@") eval set -- "${args}" while true; do case "$1" in --retire) - arg_retire="true" - shift + arg_retire="$2" + shift 2 ;; --data) # only read mandatory non-empty parameters here diff --git a/setup/splashpage.sh b/setup/splashpage.sh index a4588b68b..6684f30c4 100755 --- a/setup/splashpage.sh +++ b/setup/splashpage.sh @@ -25,7 +25,7 @@ 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}" == "true" || "${existing_infra}" != "${current_infra}" ]]; then +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}" rm -f ${DATA_DIR}/nginx/applications/* ${BOX_SRC_DIR}/node_modules/.bin/ejs-cli -f "${script_dir}/start/nginx/appconfig.ejs" \ @@ -36,6 +36,10 @@ 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 -echo '{ "update": { "percent": "10", "message": "Updating cloudron software" }, "backup": null }' > "${SETUP_WEBSITE_DIR}/progress.json" +if [[ "${arg_retire}" == "migrate" ]]; then + echo '{ "migrate": { "percent": "10", "message": "Migrating cloudron" }, "backup": null }' > "${SETUP_WEBSITE_DIR}/progress.json" +else + echo '{ "update": { "percent": "10", "message": "Updating cloudron software" }, "backup": null }' > "${SETUP_WEBSITE_DIR}/progress.json" +fi nginx -s reload diff --git a/src/cloudron.js b/src/cloudron.js index 51ffb98bf..0c8967cc9 100644 --- a/src/cloudron.js +++ b/src/cloudron.js @@ -587,7 +587,7 @@ function doUpgrade(boxUpdateInfo, callback) { // no need to unlock since this is the last thing we ever do on this box callback(); - retire(); + retire('upgrade'); }); }); } @@ -702,14 +702,15 @@ function checkDiskSpace(callback) { }); } -function retire(callback) { +function retire(reason, callback) { + assert(reason === 'migrate' || reason === 'upgrade'); callback = callback || NOOP_CALLBACK; var data = { isCustomDomain: config.isCustomDomain(), fqdn: config.fqdn() }; - shell.sudo('retire', [ RETIRE_CMD, JSON.stringify(data) ], callback); + shell.sudo('retire', [ RETIRE_CMD, reason, JSON.stringify(data) ], callback); } function migrate(size, region, callback) { @@ -746,7 +747,7 @@ function migrate(size, region, callback) { progress.set(progress.MIGRATE, 10, 'Migrating'); - retire(); + retire('migrate'); }); }); diff --git a/src/scripts/retire.sh b/src/scripts/retire.sh index 0c69d98c4..7d903711b 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 --data "$1" # show splash +"${BOX_SRC_DIR}/setup/splashpage.sh" --retire "$1" --data "$2" # show splash echo "Stopping apps" systemctl stop docker # stop the apps