83 lines
2.5 KiB
Bash
Executable File
83 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -u -o pipefail
|
|
|
|
# change this to a hash when we make a upgrade release
|
|
readonly INSTALLER_REVISION=master
|
|
readonly INIT_BASESYSTEM_SCRIPT_URL="https://git.cloudron.io/cloudron/box/raw/${INSTALLER_REVISION}/baseimage/initializeBaseUbuntuImage.sh"
|
|
readonly INSTALLER_SOURCE_DIR="/home/yellowtent/installer"
|
|
readonly LOG_FILE="/var/logs/cloudron-setup.log"
|
|
|
|
domain=""
|
|
provider="generic"
|
|
restoreKey=""
|
|
restoreUrl=""
|
|
tlsProvider="letsencrypt-prod"
|
|
versionsUrl="https://s3.amazonaws.com/prod-cloudron-releases/versions.json"
|
|
version="latest"
|
|
|
|
args=$(getopt -o "" -l "domain:,provider:,restore-key:,restore-url:,tls-provider:,version:,versions-url:" -n "$0" -- "$@")
|
|
eval set -- "${args}"
|
|
|
|
while true; do
|
|
case "$1" in
|
|
--domain) domain="$2"; shift 2;;
|
|
--provider) provider="$2"; shift 2;;
|
|
--restore-key) restoreKey="$2"; shift 2;;
|
|
--restore-url) restoreUrl="$2"; shift 2;;
|
|
--tls-provider) tlsProvider="$2"; shift 2;;
|
|
--version) version="$2"; shift 2;;
|
|
--versions-url) versionsUrl="$2"; shift 2;;
|
|
--) break;;
|
|
*) echo "Unknown option $1"; exit 1;;
|
|
esac
|
|
done
|
|
|
|
if [[ -z "${domain}" ]]; then
|
|
echo "--domain is required"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Downloading initialization script"
|
|
curl "${INIT_BASESYSTEM_SCRIPT_URL}" > /tmp/initializeBaseUbuntuImage.sh
|
|
|
|
echo "Installing dependancies ... (this takes some time)"
|
|
/bin/bash /tmp/initializeBaseUbuntuImage.sh "${INSTALLER_REVISION}" "${provider}" &>> "${LOG_FILE}"
|
|
rm /tmp/initializeBaseUbuntuImage.sh
|
|
|
|
# start the update server
|
|
systemctl start cloudron-installer
|
|
|
|
echo "Get sourcetarball url from version"
|
|
NPM_BIN=$(npm bin -g)
|
|
sourceTarballUrl=$(${NPM_BIN}/cloudron-version --out tarballUrl --versions-url "${versionsUrl}" --version "${version}")
|
|
version=$(${NPM_BIN}/cloudron-version --out version --versions-url "${versionsUrl}" --version "${version}")
|
|
|
|
read -d '' data <<EOF
|
|
{
|
|
"boxVersionsUrl": "${versionsUrl}",
|
|
"fqdn": "${domain}",
|
|
"provider": "${provider}",
|
|
"restoreKey": "${restoreKey}",
|
|
"restoreUrl": "${restoreUrl}",
|
|
"tlsConfig": {
|
|
"provider": "${tlsProvider}"
|
|
},
|
|
"version": "${version}"
|
|
}
|
|
EOF
|
|
|
|
echo "Run installer.sh with ${sourceTarballUrl} ... (this takes some time)"
|
|
${INSTALLER_SOURCE_DIR}/src/scripts/installer.sh --sourcetarballurl "${sourceTarballUrl}" --data "${data}" &>> "${LOG_FILE}"
|
|
|
|
echo -n "Waiting for cloudron to be ready"
|
|
while true; do
|
|
echo -n "."
|
|
if journalctl -u box -a | grep -q "Cloudron is up and running"; then
|
|
break
|
|
fi
|
|
sleep 10
|
|
done
|
|
|
|
echo "Visit https://my.${domain} to finish setup"
|