blob: ccddf8a82b4ea86db16258524f434eba9e52b5e4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#!/bin/bash
# shellcheck disable=2034,2059
true
SCRIPT_NAME="Add CLI User"
# shellcheck source=lib.sh
. <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh)
# T&M Hansson IT AB © - 2020, https://www.hanssonit.se/
# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=0
debug_mode
if [[ $UNIXUSER != "ncadmin" ]]
then
msg_box "Current user with sudo permissions is: $UNIXUSER.
This script will set up everything with that user.
If the field after ':' is blank you are probably running as a pure root user.
It's possible to install with root, but there will be minor errors.
Please create a user with sudo permissions if you want an optimal installation.
The preferred user is 'ncadmin'."
if ! yesno_box_yes "Do you want to create a new user?"
then
print_text_in_color "$ICyan" "Not adding another user..."
sleep 1
else
read -r -p "Enter name of the new user: " NEWUSER
adduser --disabled-password --gecos "" "$NEWUSER"
sudo usermod -aG sudo "$NEWUSER"
usermod -s /bin/bash "$NEWUSER"
while true
do
sudo passwd "$NEWUSER" && break
done
sudo -u "$NEWUSER" sudo bash "$1"
fi
fi
|