-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathipb_support_user.sh
More file actions
executable file
·66 lines (58 loc) · 1.99 KB
/
Copy pathipb_support_user.sh
File metadata and controls
executable file
·66 lines (58 loc) · 1.99 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Copyright (c) 2017 Fernando Mercês
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <https://www.gnu.org/licenses/>.
ipb_user=
ipb_dir=
mysql_dbname=
mysql_user=
check_perms() {
[ $EUID = 0 ] || { echo 'You are not root. Bye...'; exit 1; }
}
sql_query() {
echo Username: $mysql_user
mysql --database $mysql_dbname -u $mysql_user -p < <(echo "$1")
}
enable_user() {
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
service ssh reload
passwd --unlock $ipb_user
echo "[*] $ipb_user enabled for SSH login"
chown -R $ipb_user: $ipb_dir
chown -R www-data: $ipb_dir/datastore $ipb_dir/uploads
echo "[*] $ipb_dir permissions set"
sql_query "UPDATE core_members SET temp_ban=0 WHERE name='$ipb_user';"
echo "[*] $ipb_user ENABLED on this system and AdminCP"
}
disable_user() {
sed -i 's/PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
service ssh reload
passwd --lock $ipb_user
echo "[*] $ipb_user disabled for SSH login"
chown -R www-data: $ipb_dir
echo "[*] $ipb_dir permissions set"
sql_query "UPDATE core_members SET temp_ban=-1 WHERE name='$ipb_user';"
echo "[*] $ipb_user DISABLED on this system and AdminCP"
}
if [ "$1" == "--enable" -o "$1" == "-e" ]; then
check_perms
enable_user
elif [ "$1" == "--disable" -o "$1" == "-d" ]; then
check_perms
disable_user
else
echo -e "Usage:\n\t$0 [--enable | --disable]"
exit 0
fi