@@ -9,6 +9,8 @@ error="${red}ERROR: ${normal}"
9
9
nginx_conf_url=" https://raw.githubusercontent.com/webdna/serverpilot-scripts/master/nginx.app.conf"
10
10
nginx_expires_conf_url=" https://raw.githubusercontent.com/webdna/serverpilot-scripts/master/nginx.expires.conf"
11
11
12
+ certbot_bash_url=" https://raw.githubusercontent.com/webdna/serverpilot-scripts/master/certbot.sh"
13
+
12
14
run_all=false
13
15
# === /Variables ===
14
16
@@ -70,7 +72,7 @@ if [[ $run_all = false ]]; then
70
72
fi
71
73
72
74
if [ " $lemp " = " y" ] || [ $run_all = true ]; then
73
- show_notice " Creating LEMP Stack... "
75
+ show_notice " Creating LEMP Stack… "
74
76
75
77
echo -n " What is the appname? : "
76
78
read appname
@@ -86,27 +88,61 @@ if [ "$lemp" = "y" ] || [ $run_all = true ]; then
86
88
if [[ -e " ${app_vhost_dir} /main.custom.conf" ]]; then
87
89
show_warning " ${appname} has already been customised. Skipping.."
88
90
else
89
- show_info " Backing up main conf file... "
91
+ show_info " Backing up main conf file… "
90
92
(eval " mv ${app_vhost_dir} /main.conf ${app_vhost_dir} /main.conf.bak" )
91
93
92
- show_info " Creating new nginx conf... "
94
+ show_info " Creating new nginx conf… "
93
95
(eval " wget --no-cache -O ${app_vhost_dir} /main.custom.conf ${nginx_conf_url} " )
94
96
95
97
show_info " Inserting system user and appanme"
96
98
(eval " sed -i -e 's/SYSUSER/${system_user} /g' ${app_vhost_dir} /main.custom.conf" )
97
99
(eval " sed -i -e 's/APPNAME/${appname} /g' ${app_vhost_dir} /main.custom.conf" )
98
100
99
- show_info " Restarting nginx... "
101
+ show_info " Restarting nginx… "
100
102
service nginx-sp restart
101
103
fi
102
104
103
105
else
104
106
show_error " You must provide a valid appname"
105
107
fi
106
108
107
- show_notice " Finished Creating LEMP Stack... "
109
+ show_notice " Finished Creating LEMP Stack… "
108
110
fi
109
111
# === /LEMP Stack ===
112
+ #
113
+ # === Install Certbot ===
114
+ if [[ $run_all = false ]]; then
115
+ echo -n " Install Certbot (for Lets Encrypt)? (y/n) [default: n] : "
116
+ read cartbot
117
+ fi
118
+
119
+ if [ " $certbot " = " y" ] || [ $run_all = true ]; then
120
+ show_notice " Installing Certbot…"
121
+
122
+ show_info " Updating packages…"
123
+ apt-get update
124
+
125
+ show_info " Installing software-properties-common…"
126
+ apt-get install -y software-properties-common
127
+
128
+ show_info " Add Certbot repository…"
129
+ add-apt-repository -y ppa:certbot/certbot
130
+
131
+ show_info " Updating packages…"
132
+ apt-get update
133
+
134
+ show_info " Installing Certbot cli…"
135
+ apt-get install -y certbot
136
+
137
+ show_info " Adding certbot renew to dail cron…"
138
+ (eval " wget --no-cache -O /etc/cron.daily/certbot ${certbot_bash_url} " )
139
+
140
+ show_info " Making certbot cron is executable…"
141
+ (eval " chmod +x /etc/cron.daily/certbot" )
142
+
143
+ show_notice " Finished Installing Certbox…"
144
+ fi
145
+ # === /Install Certbot ===
110
146
111
147
# === Imagick ===
112
148
if [[ $run_all = false ]]; then
@@ -115,23 +151,23 @@ if [[ $run_all = false ]]; then
115
151
fi
116
152
117
153
if [ " $imagick " = " y" ] || [ $run_all = true ]; then
118
- show_notice " Installing Imagick... "
154
+ show_notice " Installing Imagick… "
119
155
show_info " When asked for a prefix simply press enter."
120
156
121
- show_info " Installing Pacakges... "
157
+ show_info " Installing Pacakges… "
122
158
apt-get install -y gcc make autoconf libc-dev pkg-config
123
159
apt-get install -y libmagickwand-dev
124
160
125
- show_info " Pecl Installing Imagick... "
161
+ show_info " Pecl Installing Imagick… "
126
162
(eval " pecl${php_version} -sp install imagick" )
127
163
128
- show_info " Enabling Imagick Extension... "
164
+ show_info " Enabling Imagick Extension… "
129
165
bash -c " echo extension=imagick.so > /etc/php${php_version} -sp/conf.d/imagick.ini"
130
166
131
- show_info " Restarting PHP FPM... "
167
+ show_info " Restarting PHP FPM… "
132
168
(eval " service php${php_version} -fpm-sp restart" )
133
169
134
- show_notice " Finished Installing Imagick... "
170
+ show_notice " Finished Installing Imagick… "
135
171
fi
136
172
# === /Imagick ===
137
173
@@ -142,11 +178,11 @@ if [[ $run_all = false ]]; then
142
178
fi
143
179
144
180
if [ " $automysqlbackup " = " y" ] || [ $run_all = true ]; then
145
- show_notice " Installing AutoMySQLBackup... "
181
+ show_notice " Installing AutoMySQLBackup… "
146
182
147
183
apt-get install -y automysqlbackup
148
184
149
- show_notice " Finished Installing AutoMySQLBackup... "
185
+ show_notice " Finished Installing AutoMySQLBackup… "
150
186
fi
151
187
# === /AutoMySQLBackup ===
152
188
@@ -157,20 +193,20 @@ if [[ $run_all = false ]]; then
157
193
fi
158
194
159
195
if [ " $mysql_strict " = " y" ] || [ $run_all = true ]; then
160
- show_notice " Disabling MySQL Strict Mode... "
196
+ show_notice " Disabling MySQL Strict Mode… "
161
197
162
198
if [ -e /etc/mysql/conf.d/disable_strict_mode.cnf ]; then
163
199
show_info " Disable strict mode config already exists"
164
200
else
165
- show_info " Creating file... "
201
+ show_info " Creating file… "
166
202
touch /etc/mysql/conf.d/disable_strict_mode.cnf
167
- show_info " Adding config... "
203
+ show_info " Adding config… "
168
204
printf " [mysqld]\nsql_mode=IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\n" > /etc/mysql/conf.d/disable_strict_mode.cnf
169
- show_info " Restarting MySql... "
205
+ show_info " Restarting MySql… "
170
206
service mysql restart
171
207
fi
172
208
173
- show_notice " Finished Disabling MySQL Strict Mode... "
209
+ show_notice " Finished Disabling MySQL Strict Mode… "
174
210
fi
175
211
# === /Disable MySQL 5.7 Strict Mode ===
176
212
@@ -181,33 +217,33 @@ if [[ $run_all = false ]]; then
181
217
fi
182
218
183
219
if [ " $imgopt " = " y" ] || [ $run_all = true ]; then
184
- show_notice " Installing image optimisation libraries... "
220
+ show_notice " Installing image optimisation libraries… "
185
221
186
222
# jpegoptim
187
- show_info " Installing jpegoptim... "
223
+ show_info " Installing jpegoptim… "
188
224
apt-get install -y jpegoptim
189
225
190
226
# optipng
191
- show_info " Installing optipng... "
227
+ show_info " Installing optipng… "
192
228
apt-get install -y optipng
193
229
194
230
# pngquant
195
- show_info " Installing pngquant... "
231
+ show_info " Installing pngquant… "
196
232
apt-get install -y pngquant
197
233
198
234
# pngcrush
199
- show_info " Installing pngcrush... "
235
+ show_info " Installing pngcrush… "
200
236
apt-get install -y pngcrush
201
237
202
238
# gifsicle
203
- show_info " Installing gifsicle... "
239
+ show_info " Installing gifsicle… "
204
240
apt-get install -y gifsicle
205
241
206
242
# webp
207
- show_info " Installing webp... "
243
+ show_info " Installing webp… "
208
244
apt-get install -y webp
209
245
210
- show_notice " Finished Installing image optimisation libraries... "
246
+ show_notice " Finished Installing image optimisation libraries… "
211
247
fi
212
248
# === /Image optimisation libraries ===
213
249
@@ -218,7 +254,7 @@ if [[ $run_all = false ]]; then
218
254
fi
219
255
220
256
if [ " $pwd_protect " = " y" ] || [ $run_all = true ]; then
221
- show_notice " Starting Password protect app process... "
257
+ show_notice " Starting Password protect app process… "
222
258
223
259
echo -n " What is the appname of the app you would like to password? :"
224
260
read appname
@@ -245,7 +281,7 @@ if [ "$pwd_protect" = "y" ] || [ $run_all = true ]; then
245
281
fi
246
282
247
283
# Create password file
248
- show_info " Creating password file... "
284
+ show_info " Creating password file… "
249
285
pwd_dir=" /srv/users/${system_user} /pwd/${appname} "
250
286
mkdir -p " ${pwd_dir} "
251
287
pwd_path=" ${pwd_dir} /.htpasswd"
@@ -259,7 +295,7 @@ if [ "$pwd_protect" = "y" ] || [ $run_all = true ]; then
259
295
260
296
nginx_pwd_conf=" /etc/nginx-sp/vhosts.d/${appname} .d/password.conf"
261
297
if [[ ! -e " ${nginx_pwd_conf} " ]]; then
262
- show_info " Creating nginx password conf file... "
298
+ show_info " Creating nginx password conf file… "
263
299
264
300
auth_basic=' auth_basic "' " ${pwd_title} " ' ";'
265
301
auth_basic_user_file=" auth_basic_user_file ${pwd_path} ;"
@@ -275,7 +311,7 @@ if [ "$pwd_protect" = "y" ] || [ $run_all = true ]; then
275
311
show_info " ${appname} not found."
276
312
fi
277
313
278
- show_notice " Finished Password protect app process... "
314
+ show_notice " Finished Password protect app process… "
279
315
fi
280
316
# === /Password Protect App ===
281
317
@@ -286,7 +322,7 @@ if [[ $run_all = false ]]; then
286
322
fi
287
323
288
324
if [ " $expires_nginx " = " y" ] || [ $run_all = true ]; then
289
- show_notice " Adding Expires Nginx Conf... "
325
+ show_notice " Adding Expires Nginx Conf… "
290
326
291
327
echo -n " What is the appname? : "
292
328
read appname
@@ -299,17 +335,17 @@ if [ "$expires_nginx" = "y" ] || [ $run_all = true ]; then
299
335
show_warning " ${appname} already has expires file. Skipping.."
300
336
else
301
337
302
- show_info " Creating expires nginx conf... "
338
+ show_info " Creating expires nginx conf… "
303
339
(eval " wget --no-cache -O ${expires_conf_file} ${nginx_expires_conf_url} " )
304
340
305
- show_info " Restarting nginx... "
341
+ show_info " Restarting nginx… "
306
342
service nginx-sp restart
307
343
fi
308
344
309
345
else
310
346
show_error " You must provide a valid appname"
311
347
fi
312
348
313
- show_notice " Finished Adding Expires Nginx Conf... "
349
+ show_notice " Finished Adding Expires Nginx Conf… "
314
350
fi
315
351
# === /Expires Nginx Conf ===
0 commit comments