forked from openWB/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupgrade2openwbuser.sh
executable file
·48 lines (38 loc) · 1.32 KB
/
upgrade2openwbuser.sh
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
41
42
43
44
45
46
47
48
#!/bin/bash
OPENWBBASEDIR=/var/www/html/openWB
OPENWB_USER=openwb
OPENWB_GROUP=openwb
if (($(id -u) != 0)); then
echo "this script has to be run as user root or with sudo"
exit 1
fi
echo "upgrading openWB 2 in \"${OPENWBBASEDIR}\""
echo "stopping openWB2 system service..."
systemctl stop openwb2.service
echo "done"
echo "create group $OPENWB_GROUP"
# Will do nothing if group already exists:
/usr/sbin/groupadd "$OPENWB_GROUP"
echo "done"
echo "create user $OPENWB_USER"
# Will do nothing if user already exists:
/usr/sbin/useradd "$OPENWB_USER" -g "$OPENWB_GROUP" --create-home
echo "done"
# The user "openwb" is still new and we might need sudo in many places. Thus for now we give the user
# unrestricted sudo. This should be restricted in the future
echo "adding new user to sudoers"
echo "$OPENWB_USER ALL=(ALL) NOPASSWD: ALL" >/etc/sudoers.d/openwb
chmod 440 /etc/sudoers.d/openwb
echo "done"
echo "updating crontab..."
cp "${OPENWBBASEDIR}/data/config/openwb.cron" /etc/cron.d/openwb
echo "installed"
echo "updating openwb2 system service..."
systemctl daemon-reload
systemctl enable openwb2.service
echo "done"
echo "setting permissions in $OPENWBBASEDIR to $OPENWB_USER:$OPENWB_GROUP..."
chown -R "$OPENWB_USER:$OPENWB_GROUP" "$OPENWBBASEDIR"
echo "done"
echo "upgrade to openwb user finished, rebooting..."
/usr/sbin/reboot