Files
cloudron-box/installer/bin/cloudron-setup
T

49 lines
1.2 KiB
Bash
Raw Normal View History

2016-10-24 16:18:02 +02:00
#!/bin/bash
set -eu -o pipefail
readonly PROVISION_FILEPATH="/root/userdata.json"
# TODO do we allow specifying version?
# TODO add restore arguments (accessable url and encryption key)
domain=""
provider="generic"
# Only GNU getopt supports long options. OS X comes bundled with the BSD getopt
# brew install gnu-getopt to get the GNU getopt on OS X
[[ $(uname -s) == "Darwin" ]] && GNU_GETOPT="/usr/local/opt/gnu-getopt/bin/getopt" || GNU_GETOPT="getopt"
readonly GNU_GETOPT
args=$(${GNU_GETOPT} -o "" -l "domain:,provider:," -n "$0" -- "$@")
eval set -- "${args}"
while true; do
case "$1" in
--domain) domain="$2"; shift 2;;
--provider) provider="$2"; shift 2;;
--) break;;
*) echo "Unknown option $1"; exit 1;;
esac
done
if [[ -z "${domain}" ]]; then
echo "--domain is required"
exit 1
fi
# TODO validate input
cat > "${PROVISION_FILEPATH}" <<EOF
{
"data": {
"fqdn": "${domain}",
"provider": "${provider}"
}
}
EOF
# TODO print further instructions
echo "The Cloudron is being initialized"
echo "Create DNS record for this ip if not done already"
echo "Once DNS is ready, visit https://my.${domain} to finish setup"