diff --git a/installer/bin/cloudron-setup b/installer/bin/cloudron-setup new file mode 100755 index 000000000..dc104c6c4 --- /dev/null +++ b/installer/bin/cloudron-setup @@ -0,0 +1,48 @@ +#!/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}" <