-
Notifications
You must be signed in to change notification settings - Fork 13
/
abdal-ocserv-mgr.sh
104 lines (100 loc) · 2.58 KB
/
abdal-ocserv-mgr.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
echo -e "
+-+-+-+-+-+ +-+-+-+-+-+-+ +-+-+-+
|A|b|d|a|l| |O|c|S|e|r|v| |M|G|R|
+-+-+-+-+-+ +-+-+-+-+-+-+ +-+-+-+
Programmer : Ebrahim Shafiei (EbraSha)
Email: Prof.Shafiei@Gmail.com
"
echo "Please select your action"
echo "--1. Create a user"
echo "--2. Change user pass"
echo "--3. Lock user account"
echo "--4. unlock user account"
echo "--5. delete user account"
echo "--6. Show All Users"
echo "--7. Show connecting users"
echo "--8. Disconnect the specified user"
echo "--9. Prints the banned IP addresses"
echo "--10. Unban the specified IP"
echo "--11. Show Users Connection Software Type"
read -r
user_selection=$REPLY
if [ $user_selection -eq "1" ]
then
echo "Please enter the user name"
read -r
user_name=$REPLY
ocpasswd -c /etc/ocserv/ocpasswd $user_name
echo "user created successfully"
elif [ $user_selection -eq "2" ]
then
echo "Please enter the user name"
read -r
user_name=$REPLY
ocpasswd -c /etc/ocserv/ocpasswd $user_name
echo "password has been changed successfully"
elif [ $user_selection -eq "3" ]
then
echo "Please enter the user name"
read -r
user_name=$REPLY
ocpasswd -l -c /etc/ocserv/ocpasswd $user_name
echo "user locked successfully"
elif [ $user_selection -eq "4" ]
then
echo "Please enter the user name"
read -r
user_name=$REPLY
ocpasswd -u -c /etc/ocserv/ocpasswd $user_name
echo "user unlocked successfully"
elif [ $user_selection -eq "5" ]
then
echo "Please enter the user name"
read -r
user_name=$REPLY
ocpasswd -d -c /etc/ocserv/ocpasswd $user_name
echo "user deleted successfully"
elif [ $user_selection -eq "6" ]
then
clear
echo ""
echo ""
echo "########################################################################"
cat /etc/ocserv/ocpasswd
echo "########################################################################"
echo ""
echo ""
elif [ $user_selection -eq "7" ]
then
occtl show events
echo ""
elif [ $user_selection -eq "8" ]
then
echo "Please enter the user name"
read -r
user_name=$REPLY
occtl disconnect user $user_name
echo ""
elif [ $user_selection -eq "9" ]
then
occtl show ip bans
echo ""
elif [ $user_selection -eq "10" ]
then
echo "Please enter the user IP address"
read -r
user_ip=$REPLY
occtl unban ip $user_ip
echo ""
elif [ $user_selection -eq "11" ]
then
occtl show sessions all > /etc/ocserv/temp_ocserv
user_connection_info_file="/etc/ocserv/temp_ocserv"
while read line; do echo "---" $line | awk '{print $3, $6 ,$7}'; done < $user_connection_info_file
rm -f /etc/ocserv/temp_ocserv
echo ""
else
echo "You did not select the correct option"
echo ""
fi