From afef548097725c584ed4e8880b4e77a5c9ec210d Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Fri, 9 Mar 2018 10:37:18 -0800 Subject: [PATCH] cloudron-setup: make sure --help runs as non-root --- scripts/cloudron-setup | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/scripts/cloudron-setup b/scripts/cloudron-setup index 6faa14c82..e9bae1ca6 100755 --- a/scripts/cloudron-setup +++ b/scripts/cloudron-setup @@ -2,16 +2,6 @@ set -eu -o pipefail -if [[ ${EUID} -ne 0 ]]; then - echo "This script should be run as root." > /dev/stderr - exit 1 -fi - -if [[ $(lsb_release -rs) != "16.04" ]]; then - echo "Cloudron requires Ubuntu 16.04" > /dev/stderr - exit 1 -fi - # change this to a hash when we make a upgrade release readonly LOG_FILE="/var/log/cloudron-setup.log" readonly DATA_FILE="/root/cloudron-install-data.json" @@ -85,6 +75,18 @@ while true; do esac done +# Only --help works as non-root +if [[ ${EUID} -ne 0 ]]; then + echo "This script should be run as root." > /dev/stderr + exit 1 +fi + +# Only --help works with mismatched ubuntu +if [[ $(lsb_release -rs) != "16.04" ]]; then + echo "Cloudron requires Ubuntu 16.04" > /dev/stderr + exit 1 +fi + # validate arguments in the absence of data if [[ -z "${provider}" ]]; then echo "--provider is required (azure, cloudscale, digitalocean, ec2, exoscale, hetzner, lightsail, linode, ovh, rosehosting, scaleway, vultr or generic)"