-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig-DirecAdmin.sh
More file actions
292 lines (223 loc) · 5.75 KB
/
Copy pathConfig-DirecAdmin.sh
File metadata and controls
292 lines (223 loc) · 5.75 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
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
#!/bin/bash
#written by Reza Sharifi (rsharifi210@gmail.com)
function FUNC1() {
spin()
{
spinner="⠁⠂⠄⡀⢀⠠⠐⠈"
while :
do
for i in `seq 0 7`
do
echo -n "${spinner:$i:1}"
echo -n "${spinner:$i:1}"
echo -en "\010"
sleep .08
done
done
}
# Start the Spinner:
spin &
# Make a note of its Process ID (PID):
SPIN_PID=$!
# Kill the spinner on any signal, including our own exit.
trap "kill -9 $SPIN_PID" `seq 0 15`
$COMMAND > /root/script.log 2>&1
# If the script is going to exit here, there is nothing to do.
# The trap above will kill the spinner when this script exits.
# Otherwise, if the script is going to do more stuff, you can
# kill the spinner now:
kill -9 $SPIN_PID
}
#This function is for changing directadmin.conf values and compare them with old value
function FUNC2()
{
OldValue=$( cat /usr/local/directadmin/conf/directadmin.conf | grep "$MyChange" | tr "=" "\n" | awk 'NR==2' )
if [ "$OldValue" != "$NewValue" ]
then
./directadmin set $MyChange $NewValue >> /root/change.log
fi
}
touch /root/change.log
> /root/change.log
echo "This values has been changed :" > /root/change.log
cd /usr/local/directadmin
MyChange="max_username_length"
NewValue="20"
FUNC2;
MyChange="letsencrypt"
NewValue="1"
FUNC2;
MyChange="http2"
NewValue="1"
FUNC2;
MyChange="dkim"
NewValue="1"
FUNC2;
MyChange="dns_ttl"
NewValue="1"
FUNC2;
Core=$( grep -c ^processor /proc/cpuinfo )
Variable=$((Core+=Core))
MyChange="check_load"
NewValue="$Variable"
FUNC2;
MyChange="check_load_minute"
NewValue="5"
FUNC2;
MyChange="zip"
NewValue="1"
FUNC2;
MyChange="da_gzip"
NewValue="1"
FUNC2;
MyChange="one_click_webmail_login"
NewValue="1"
FUNC2;
MyChange="one_click_pma_login"
NewValue="1"
FUNC2;
MyChange="realtime_quota"
NewValue="2"
FUNC2;
MyChange="rotate_httpd_error_log_meg"
NewValue="400"
FUNC2;
MyChange="default_private_html_link"
NewValue="1"
FUNC2;
MyChange="user_helper"
NewValue="ok2.com/1zZlD"
FUNC2;
MyChange="reseller_helper"
NewValue="ok2.com/dUL1N"
FUNC2;
MyChange="admin_helper"
NewValue="ok2.com/KHORv"
FUNC2;
MyChange="user_can_select_skin"
NewValue="1"
FUNC2;
tput setaf 4;cat << "EOF"
+-------------------------------------+
| |
| Configure directadmin version 2.0 |
| powered by rezshar |
+-------------------------------------+
_____ _______ _____ _______
/ ____|__ __|/\ | __ \__ __|
| (___ | | / \ | |__) | | |
\___ \ | | / /\ \ | _ / | |
____) | | |/ ____ \| | \ \ | |
|_____/ |_/_/ \_\_| \_\ |_|
EOF
echo "=============================="
cat /root/change.log
echo "=============================="
COMMAD=" service directadmin restart "
tput setaf 2; echo "Service directadmin restarting";
FUNC1;echo;
if grep -q "failed" /root/script.log
then
tput setaf 1; echo "Directadmin Error ";
cat /root/script.log
tput setaf 9;
exit 1
fi
cd custombuild
if grep -q "one_click_pma_login=1" /root/change.log
then
COMMAND="./build update"
tput setaf 2; echo "Updating Directadmin";
FUNC1;echo;
if grep -q "ERROR" /root/script.log
then
tput setaf 1; echo "Directadmin ./build update Error";
cat /root/script.log
tput setaf 9;
exit 1
fi
COMMAND="./build phpmyadmin"
tput setaf 2; echo "Building phpmyadmin";
FUNC1;echo;
if grep -q "ERROR" /root/script.log
then
tput setaf 1; echo "./build phpmyadmin Error";
cat /root/script.log
tput setaf 9;
exit 1
fi
fi
if grep -q "one_click_webmail_login=1" /root/change.log
then
COMMAND="./build update"
tput setaf 2; echo "Updating Directadmin";
FUNC1;echo;
if grep -q "ERROR" /root/script.log
then
tput setaf 1; echo "Directadmin ./build update Error";
cat /root/script.log
tput setaf 9;
exit 1
fi
COMMAND="./build roundcube"
tput setaf 2; echo "Building roundcube";
FUNC1;echo;
service directadmin restart > /dev/null 2>&1;
if grep -q "ERROR" /root/script.log
then
tput setaf 1; echo "./build roundcube Error";
cat /root/script.log
tput setaf 9;
exit 1
fi
COMMAND="./build update"
tput setaf 2; echo "Updating Directadmin";
FUNC1;echo;
if grep -q "ERROR" /root/script.log
then
tput setaf 1; echo "Directadmin ./build update Error";
cat /root/script.log
tput setaf 9;
exit 1
fi
COMMAND="./build dovecot_conf"
tput setaf 2; echo "Building dovecot_conf";
FUNC1;echo;
if grep -q "ERROR" /root/script.log
then
tput setaf 1; echo "./build dovecot_conf Error";
cat /root/script.log
tput setaf 9;
exit 1
fi
COMMAND="./build exim_conf"
tput setaf 2; echo "Building exim_conf";
FUNC1;echo;
if grep -q "ERROR" /root/script.log
then
tput setaf 1; echo "./build exim_conf Error";
cat /root/script.log
tput setaf 9;
exit 1
fi
COMMAND="./build roundcube"
tput setaf 2; echo "Building roundcube";
FUNC1;echo;
if grep -q "ERROR" /root/script.log
then
tput setaf 1; echo "./build roundcube Error";
cat /root/script.log
tput setaf 9;
exit 1
fi
fi
#rm -f /root/logDA.log /root/change.log
tput setaf 4; cat << "EOF"
______ _____ _ _ _____ _____ _ _
| ____|_ _| \ | |_ _|/ ____| | | |
| |__ | | | \| | | | | (___ | |__| |
| __| | | | . ` | | | \___ \| __ |
| | _| |_| |\ |_| |_ ____) | | | |
|_| |_____|_| \_|_____|_____/|_| |_|
EOF
tput setaf 9;