-
Notifications
You must be signed in to change notification settings - Fork 37
/
1pctl
200 lines (183 loc) · 4.04 KB
/
1pctl
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#!/bin/bash
action=$1
target=$2
args=$@
BASE_DIR=directory
ORIGINAL_PORT=port
ORIGINAL_VERSION=version
ORIGINAL_ENTRANCE=entrance
ORIGINAL_USERNAME=username
ORIGINAL_PASSWORD=password
LANGUAGE=en
source /usr/local/bin/lang/$LANGUAGE.sh
function usage() {
echo "$PANEL_CONTROL_SCRIPT"
echo
echo "Usage: "
echo " ./1pctl [COMMAND] [ARGS...]"
echo " ./1pctl --help"
echo
echo "Commands: "
echo " status $TXT_PANEL_SERVICE_STATUS"
echo " start $TXT_PANEL_SERVICE_START"
echo " stop $TXT_PANEL_SERVICE_STOP"
echo " restart $TXT_PANEL_SERVICE_RESTART"
echo " uninstall $TXT_PANEL_SERVICE_UNINSTALL"
echo " user-info $TXT_PANEL_SERVICE_USER_INFO"
echo " listen-ip $TXT_PANEL_SERVICE_LISTEN_IP"
echo " version $TXT_PANEL_SERVICE_VERSION"
echo " update $TXT_PANEL_SERVICE_UPDATE"
echo " reset $TXT_PANEL_SERVICE_RESET"
echo " restore $TXT_PANEL_SERVICE_RESTORE"
}
function status() {
systemctl status 1panel.service
}
function start() {
systemctl start 1panel.service
status
}
function stop() {
systemctl stop 1panel.service
status
}
function restart() {
systemctl restart 1panel.service
status
}
function uninstall() {
read -p "$TXT_PANEL_SERVICE_UNINSTALL_NOTICE : " yn
if [ "$yn" == "Y" ] || [ "$yn" == "y" ]; then
echo -e "$TXT_PANEL_SERVICE_UNINSTALL_START"
systemctl stop 1panel.service
systemctl disable 1panel.service >/dev/null 2>&1
echo -e "$TXT_PANEL_SERVICE_UNINSTALL_REMOVE"
rm -rf $BASE_DIR/1panel /usr/local/bin/{1pctl,1panel} /etc/systemd/system/1panel.service
systemctl daemon-reload
systemctl reset-failed
echo -e "$TXT_PANEL_SERVICE_UNINSTALL_SUCCESS"
else
exit 0
fi
}
function user-info() {
1panel user-info
}
function listen-ip() {
case "${target}" in
ipv4)
1panel listen-ip ipv4
restart
;;
ipv6)
1panel listen-ip ipv6
restart
;;
*)
1panel listen-ip
;;
esac
}
function restore() {
read -p "$TXT_PANEL_SERVICE_RESTORE_NOTICE : " yn
if [ "$yn" == "Y" ] || [ "$yn" == "y" ]; then
1panel restore
systemctl daemon-reload
restart
1panel version
else
exit 0
fi
}
function version() {
1panel version
}
function reset() {
case "${target}" in
domain)
1panel reset domain
;;
entrance)
1panel reset entrance
;;
https)
1panel reset https
restart
;;
ips)
1panel reset ips
;;
mfa)
1panel reset mfa
;;
*)
1panel reset
;;
esac
}
function update() {
case "${target}" in
username)
1panel update username
;;
password)
1panel update password
;;
port)
1panel update port
;;
*)
1panel update
;;
esac
}
function main() {
case "${action}" in
status)
status
;;
start)
start
;;
stop)
stop
;;
restart)
restart
;;
restore)
restore
;;
uninstall)
uninstall
;;
user-info)
user-info
;;
listen-ip)
listen-ip
;;
version)
version
;;
reset)
reset
;;
update)
update
;;
help)
usage
;;
--help)
usage
;;
"")
usage
;;
*)
echo "$TXT_PANEL_SERVICE_UNSUPPORTED_PARAMETER"
;;
esac
}
main