diff options
author | Daniel Hansson <daniel@techandme.se> | 2017-04-09 23:43:30 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-09 23:43:30 +0300 |
commit | ab649db479a05da1589a2158f446eda699480c37 (patch) | |
tree | 3b88db4f4a2d5487db1f0edf3f5e14b165ede498 /static/adduser.sh | |
parent | 05001d9d2fe479f7a3f8fabdfb47f172c8b183e6 (diff) |
Rewrite is now done! (#196)
Diffstat (limited to 'static/adduser.sh')
-rw-r--r-- | static/adduser.sh | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/static/adduser.sh b/static/adduser.sh index 9289e959..64eb9ad2 100644 --- a/static/adduser.sh +++ b/static/adduser.sh @@ -1,29 +1,27 @@ #!/bin/bash +# shellcheck disable=2034,2059 +true +# shellcheck source=lib.sh +. <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh) -# This runs the startup script with a new user that has sudo permissions +# Tech and Me © - 2017, https://www.techandme.se/ + +# Check for errors + debug code and abort if something isn't right +# 1 = ON +# 0 = OFF +DEBUG=0 +debug_mode -function ask_yes_or_no() { - read -p "$1 ([y]es or [N]o): " - case $(echo $REPLY | tr '[A-Z]' '[a-z]') in - y|yes) echo "yes" ;; - *) echo "no" ;; - esac -} if [[ "no" == $(ask_yes_or_no "Do you want to create a new user?") ]] then -echo "Not adding another user..." -sleep 1 -else -echo "Enter name of the new user:" -read NEWUSER -useradd -m $NEWUSER -G sudo -passwd $NEWUSER -if [[ $? > 0 ]] -then - echo "Try again please...(2/2)" - passwd $NEWUSER -else + echo "Not adding another user..." sleep 1 -fi -sudo -u $NEWUSER sudo bash nextcloud_install_production.sh +else + read -r -p "Enter name of the new user: " NEWUSER + useradd -m "$NEWUSER" -G sudo + while true + do + sudo passwd "$NEWUSER" && break + done + sudo -u "$NEWUSER" sudo bash nextcloud_install_production.sh fi |