Add cert and appstore info to provision script
This commit is contained in:
@@ -9,8 +9,12 @@ zone=""
|
||||
subdomain=""
|
||||
cloudflare_token=""
|
||||
cloudflare_email=""
|
||||
tls_cert=""
|
||||
tls_key=""
|
||||
appstore_id=""
|
||||
appstore_token=""
|
||||
|
||||
args=$(getopt -o "" -l "subdomain:,zone:,ip:,cloudflare-token:,cloudflare-email:" -n "$0" -- "$@")
|
||||
args=$(getopt -o "" -l "subdomain:,zone:,ip:,cloudflare-token:,cloudflare-email:,tls-cert:,tls-key:" -n "$0" -- "$@")
|
||||
eval set -- "${args}"
|
||||
|
||||
while true; do
|
||||
@@ -20,6 +24,10 @@ while true; do
|
||||
--zone) zone="$2"; shift 2;;
|
||||
--cloudflare-token) cloudflare_token="$2"; shift 2;;
|
||||
--cloudflare-email) cloudflare_email="$2"; shift 2;;
|
||||
--tls-cert) tls_cert_file="$(cat $2)"; shift 2;;
|
||||
--tls-key) tls_key_file="$(cat $2)"; shift 2;;
|
||||
--appstore-id) appstore_id="$2"; shift 2;;
|
||||
--appstore-token) appstore_token="$2"; shift 2;;
|
||||
--) break;;
|
||||
*) echo "Unknown option $1"; exit 1;;
|
||||
esac
|
||||
@@ -56,7 +64,17 @@ echo "=> Waiting for cloudron to be ready"
|
||||
wait_for_status "version" '*'
|
||||
|
||||
echo "Provisioning Cloudron ${subdomain}.${zone}"
|
||||
setupData=$(printf '{ "dnsConfig": { "domain": "%s", "provider": "cloudflare", "config": { "token": "%s", "email": "%s", "hyphenatedSubdomains": true }, "tlsConfig": { "provider": "fallback" } } }' "${subdomain}.${zone}" "${cloudflare_token}" "${cloudflare_email}")
|
||||
if [[ -z "${tls_cert}" || -z "${tls_key}" ]]; then
|
||||
echo "Creating selfsigned certs"
|
||||
openssl req -newkey rsa:2048 -nodes -keyout "/tmp/${zone}.key" -x509 -days 3650 -out "/tmp/${zone}.crt"
|
||||
tls_cert="$(cat /tmp/${zone}.crt)"
|
||||
tls_key="$(cat /tmp/${zone}.key)"
|
||||
fi
|
||||
|
||||
setupData=$(printf '{ "dnsConfig": { "domain": "%s", "provider": "cloudflare", "config": { "token": "%s", "email": "%s", "hyphenatedSubdomains": true }, "tlsConfig": { "provider": "fallback", "tlsCert": "%s", "tlsKey": "%s" } }, "autoconf": { "appstoreConfig": { "userId": "%s", "token: "%s" } } }' "${subdomain}.${zone}" "${cloudflare_token}" "${cloudflare_email}" "${tls_cert}" "${tls_key}" "${appstore_id}" "${appstore_token}")
|
||||
|
||||
echo $setupData
|
||||
exit 1
|
||||
|
||||
if ! setupResult=$($curl -k -X POST -H "Content-Type: application/json" -d "${setupData}" https://${ip}/api/v1/cloudron/setup); then
|
||||
echo "Failed to setup with ${setupData}: ${setupResult}"
|
||||
|
||||
Reference in New Issue
Block a user