From 7dd9459ea08b03b2d860dd1f0a5f7c64e30b4987 Mon Sep 17 00:00:00 2001 From: Marc Aymerich Date: Fri, 2 Oct 2015 12:22:43 +0000 Subject: [PATCH] Fixes on deployment --- scripts/containers/deploy.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/containers/deploy.sh b/scripts/containers/deploy.sh index 4e5e5528..0a4b1b64 100644 --- a/scripts/containers/deploy.sh +++ b/scripts/containers/deploy.sh @@ -8,23 +8,27 @@ set -ue function main () { noinput='' user=$USER - if [[ $# -eq 3 ]]; then + if [[ $# -eq 2 ]]; then if [[ $1 != '--noinput' ]]; then - echo "What argument is $1?" >&2 + echo -e "\nErr. What argument is $1?\n" >&2 exit 2 elif ! id $2; then - echo "User $2 does not exist" >&2 + echo -e "\nErr. User $2 does not exist\n" >&2 exit 3 fi + [ $(whoami) != 'root' ] && { + echo -e "\nErr. --noinput should run as root\n" >&2 + exit 1 + } noinput='--noinput' alias run=surun_ alias sudorun=run_ user=$2 - elif [[ $# -eq 2 ]]; then + elif [[ $# -eq 1 ]]; then if [[ $1 != '--noinput' ]]; then - echo "What argument is $1?" >&2 + echo -e "\nErr. What argument is $1?\n" >&2 else - echo "--noinput should provide a username" >&2 + echo -e "\nErr. --noinput should provide a username\n" >&2 fi exit 1 else @@ -132,4 +136,4 @@ function main () { } # Wrap it all on a function to avoid partial executions when running through wget/curl -main +main $@