diff --git a/setup/argparser.sh b/setup/argparser.sh index 4ecde6e14..9869492ec 100644 --- a/setup/argparser.sh +++ b/setup/argparser.sh @@ -7,8 +7,9 @@ json="${source_dir}/../node_modules/.bin/json" arg_api_server_origin="" arg_fqdn="" arg_admin_location="" +arg_admin_fqdn="" arg_zone_name="" -arg_is_custom_domain="false" +arg_is_custom_domain="false" # can be removed after 1.9 arg_retire_reason="" arg_retire_info="" arg_token="" @@ -33,9 +34,11 @@ while true; do --data) # these params must be valid in all cases arg_fqdn=$(echo "$2" | $json fqdn) + arg_admin_fqdn=$(echo "$2" | $json adminFqdn) arg_zone_name=$(echo "$2" | $json zoneName) [[ "${arg_zone_name}" == "" ]] && arg_zone_name="${arg_fqdn}" + # can be removed after 1.9 arg_is_custom_domain=$(echo "$2" | $json isCustomDomain) [[ "${arg_is_custom_domain}" == "" ]] && arg_is_custom_domain="true" diff --git a/setup/splashpage.sh b/setup/splashpage.sh index 354f62d0d..88d17d947 100755 --- a/setup/splashpage.sh +++ b/setup/splashpage.sh @@ -18,8 +18,7 @@ fi source "${script_dir}/argparser.sh" "$@" # this injects the arg_* variables used below # keep this is sync with config.js appFqdn() -admin_fqdn=$([[ "${arg_is_custom_domain}" == "true" ]] && echo "${arg_admin_location}.${arg_fqdn}" || echo "${arg_admin_location}-${arg_fqdn}") -admin_origin="https://${admin_fqdn}" +admin_origin="https://${arg_admin_fqdn}" # copy the website rm -rf "${SETUP_WEBSITE_DIR}" && mkdir -p "${SETUP_WEBSITE_DIR}" @@ -37,7 +36,7 @@ if [[ "${arg_retire_reason}" != "" || "${existing_infra}" != "${current_infra}" else echo "Show progress bar only on admin domain for normal update" ${box_src_dir}/node_modules/.bin/ejs-cli -f "${script_dir}/start/nginx/appconfig.ejs" \ - -O "{ \"vhost\": \"${admin_fqdn}\", \"adminOrigin\": \"${admin_origin}\", \"endpoint\": \"splash\", \"sourceDir\": \"${SETUP_WEBSITE_DIR}\", \"certFilePath\": \"cert/host.cert\", \"keyFilePath\": \"cert/host.key\", \"xFrameOptions\": \"SAMEORIGIN\", \"robotsTxtQuoted\": null, \"hasIPv6\": false }" > "${PLATFORM_DATA_DIR}/nginx/applications/admin.conf" + -O "{ \"vhost\": \"${arg_admin_fqdn}\", \"adminOrigin\": \"${admin_origin}\", \"endpoint\": \"splash\", \"sourceDir\": \"${SETUP_WEBSITE_DIR}\", \"certFilePath\": \"cert/host.cert\", \"keyFilePath\": \"cert/host.key\", \"xFrameOptions\": \"SAMEORIGIN\", \"robotsTxtQuoted\": null, \"hasIPv6\": false }" > "${PLATFORM_DATA_DIR}/nginx/applications/admin.conf" fi if [[ "${arg_retire_reason}" == "migrate" ]]; then diff --git a/setup/start.sh b/setup/start.sh index 15adf671b..5375c169a 100755 --- a/setup/start.sh +++ b/setup/start.sh @@ -206,6 +206,13 @@ cd "${BOX_SRC_DIR}" BOX_ENV=cloudron DATABASE_URL=mysql://root:${mysql_root_password}@127.0.0.1/box "${BOX_SRC_DIR}/node_modules/.bin/db-migrate" up EOF +if [[ -z "${arg_admin_fqdn:-}" ]]; then + # can be removed after 1.9 + admin_fqdn=$([[ "${arg_is_custom_domain}" == "true" ]] && echo "${arg_admin_location}.${arg_fqdn}" || echo "${arg_admin_location}-${arg_fqdn}") +else + admin_fqdn="${arg_admin_fqdn}" +fi + echo "==> Creating cloudron.conf" cat > "${CONFIG_DIR}/cloudron.conf" < "${CONFIG_DIR}/cloudron.conf" <63 length subdomains', function () { diff --git a/src/test/config-test.js b/src/test/config-test.js index eb4e3bb2f..19842de2e 100644 --- a/src/test/config-test.js +++ b/src/test/config-test.js @@ -31,8 +31,8 @@ describe('config', function () { }); it('did set default values', function () { - expect(config.isCustomDomain()).to.equal(true); expect(config.fqdn()).to.equal(''); + expect(config.adminFqdn()).to.equal(''); expect(config.zoneName()).to.equal(''); expect(config.adminLocation()).to.equal('my'); }); @@ -63,20 +63,20 @@ describe('config', function () { it('uses dotted locations with custom domain', function () { config.setFqdn('example.com'); - config.set('isCustomDomain', true); + config.setAdminFqdn('my.example.com'); - expect(config.isCustomDomain()).to.equal(true); expect(config.fqdn()).to.equal('example.com'); + expect(config.adminFqdn()).to.equal('my.example.com'); expect(config.adminOrigin()).to.equal('https://my.example.com'); expect(config.zoneName()).to.equal('example.com'); }); it('uses hyphen locations with non-custom domain', function () { config.setFqdn('test.example.com'); - config.set('isCustomDomain', false); + config.setAdminFqdn('my-test.example.com'); - expect(config.isCustomDomain()).to.equal(false); expect(config.fqdn()).to.equal('test.example.com'); + expect(config.adminLocation()).to.equal('my'); expect(config.adminOrigin()).to.equal('https://my-test.example.com'); expect(config.zoneName()).to.equal('example.com'); }); diff --git a/webadmin/src/js/client.js b/webadmin/src/js/client.js index 15b56be7f..f2b3e0200 100644 --- a/webadmin/src/js/client.js +++ b/webadmin/src/js/client.js @@ -737,6 +737,7 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N Client.prototype.setupDnsConfig = function (domain, zoneName, provider, dnsConfig, callback) { var data = { domain: domain, + adminFqdn: 'my.' + domain, zoneName: zoneName, provider: provider, config: dnsConfig