@@ -9,6 +9,8 @@ error="${red}ERROR: ${normal}"
99nginx_conf_url=" https://raw.githubusercontent.com/webdna/serverpilot-scripts/master/nginx.app.conf"
1010nginx_expires_conf_url=" https://raw.githubusercontent.com/webdna/serverpilot-scripts/master/nginx.expires.conf"
1111
12+ certbot_bash_url=" https://raw.githubusercontent.com/webdna/serverpilot-scripts/master/certbot.sh"
13+
1214run_all=false
1315# === /Variables ===
1416
@@ -70,7 +72,7 @@ if [[ $run_all = false ]]; then
7072fi
7173
7274if [ " $lemp " = " y" ] || [ $run_all = true ]; then
73- show_notice " Creating LEMP Stack... "
75+ show_notice " Creating LEMP Stack… "
7476
7577 echo -n " What is the appname? : "
7678 read appname
@@ -86,27 +88,61 @@ if [ "$lemp" = "y" ] || [ $run_all = true ]; then
8688 if [[ -e " ${app_vhost_dir} /main.custom.conf" ]]; then
8789 show_warning " ${appname} has already been customised. Skipping.."
8890 else
89- show_info " Backing up main conf file... "
91+ show_info " Backing up main conf file… "
9092 (eval " mv ${app_vhost_dir} /main.conf ${app_vhost_dir} /main.conf.bak" )
9193
92- show_info " Creating new nginx conf... "
94+ show_info " Creating new nginx conf… "
9395 (eval " wget --no-cache -O ${app_vhost_dir} /main.custom.conf ${nginx_conf_url} " )
9496
9597 show_info " Inserting system user and appanme"
9698 (eval " sed -i -e 's/SYSUSER/${system_user} /g' ${app_vhost_dir} /main.custom.conf" )
9799 (eval " sed -i -e 's/APPNAME/${appname} /g' ${app_vhost_dir} /main.custom.conf" )
98100
99- show_info " Restarting nginx... "
101+ show_info " Restarting nginx… "
100102 service nginx-sp restart
101103 fi
102104
103105 else
104106 show_error " You must provide a valid appname"
105107 fi
106108
107- show_notice " Finished Creating LEMP Stack... "
109+ show_notice " Finished Creating LEMP Stack… "
108110fi
109111# === /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 ===
110146
111147# === Imagick ===
112148if [[ $run_all = false ]]; then
@@ -115,23 +151,23 @@ if [[ $run_all = false ]]; then
115151fi
116152
117153if [ " $imagick " = " y" ] || [ $run_all = true ]; then
118- show_notice " Installing Imagick... "
154+ show_notice " Installing Imagick… "
119155 show_info " When asked for a prefix simply press enter."
120156
121- show_info " Installing Pacakges... "
157+ show_info " Installing Pacakges… "
122158 apt-get install -y gcc make autoconf libc-dev pkg-config
123159 apt-get install -y libmagickwand-dev
124160
125- show_info " Pecl Installing Imagick... "
161+ show_info " Pecl Installing Imagick… "
126162 (eval " pecl${php_version} -sp install imagick" )
127163
128- show_info " Enabling Imagick Extension... "
164+ show_info " Enabling Imagick Extension… "
129165 bash -c " echo extension=imagick.so > /etc/php${php_version} -sp/conf.d/imagick.ini"
130166
131- show_info " Restarting PHP FPM... "
167+ show_info " Restarting PHP FPM… "
132168 (eval " service php${php_version} -fpm-sp restart" )
133169
134- show_notice " Finished Installing Imagick... "
170+ show_notice " Finished Installing Imagick… "
135171fi
136172# === /Imagick ===
137173
@@ -142,11 +178,11 @@ if [[ $run_all = false ]]; then
142178fi
143179
144180if [ " $automysqlbackup " = " y" ] || [ $run_all = true ]; then
145- show_notice " Installing AutoMySQLBackup... "
181+ show_notice " Installing AutoMySQLBackup… "
146182
147183 apt-get install -y automysqlbackup
148184
149- show_notice " Finished Installing AutoMySQLBackup... "
185+ show_notice " Finished Installing AutoMySQLBackup… "
150186fi
151187# === /AutoMySQLBackup ===
152188
@@ -157,20 +193,20 @@ if [[ $run_all = false ]]; then
157193fi
158194
159195if [ " $mysql_strict " = " y" ] || [ $run_all = true ]; then
160- show_notice " Disabling MySQL Strict Mode... "
196+ show_notice " Disabling MySQL Strict Mode… "
161197
162198 if [ -e /etc/mysql/conf.d/disable_strict_mode.cnf ]; then
163199 show_info " Disable strict mode config already exists"
164200 else
165- show_info " Creating file... "
201+ show_info " Creating file… "
166202 touch /etc/mysql/conf.d/disable_strict_mode.cnf
167- show_info " Adding config... "
203+ show_info " Adding config… "
168204 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… "
170206 service mysql restart
171207 fi
172208
173- show_notice " Finished Disabling MySQL Strict Mode... "
209+ show_notice " Finished Disabling MySQL Strict Mode… "
174210fi
175211# === /Disable MySQL 5.7 Strict Mode ===
176212
@@ -181,33 +217,33 @@ if [[ $run_all = false ]]; then
181217fi
182218
183219if [ " $imgopt " = " y" ] || [ $run_all = true ]; then
184- show_notice " Installing image optimisation libraries... "
220+ show_notice " Installing image optimisation libraries… "
185221
186222 # jpegoptim
187- show_info " Installing jpegoptim... "
223+ show_info " Installing jpegoptim… "
188224 apt-get install -y jpegoptim
189225
190226 # optipng
191- show_info " Installing optipng... "
227+ show_info " Installing optipng… "
192228 apt-get install -y optipng
193229
194230 # pngquant
195- show_info " Installing pngquant... "
231+ show_info " Installing pngquant… "
196232 apt-get install -y pngquant
197233
198234 # pngcrush
199- show_info " Installing pngcrush... "
235+ show_info " Installing pngcrush… "
200236 apt-get install -y pngcrush
201237
202238 # gifsicle
203- show_info " Installing gifsicle... "
239+ show_info " Installing gifsicle… "
204240 apt-get install -y gifsicle
205241
206242 # webp
207- show_info " Installing webp... "
243+ show_info " Installing webp… "
208244 apt-get install -y webp
209245
210- show_notice " Finished Installing image optimisation libraries... "
246+ show_notice " Finished Installing image optimisation libraries… "
211247fi
212248# === /Image optimisation libraries ===
213249
@@ -218,7 +254,7 @@ if [[ $run_all = false ]]; then
218254fi
219255
220256if [ " $pwd_protect " = " y" ] || [ $run_all = true ]; then
221- show_notice " Starting Password protect app process... "
257+ show_notice " Starting Password protect app process… "
222258
223259 echo -n " What is the appname of the app you would like to password? :"
224260 read appname
@@ -245,7 +281,7 @@ if [ "$pwd_protect" = "y" ] || [ $run_all = true ]; then
245281 fi
246282
247283 # Create password file
248- show_info " Creating password file... "
284+ show_info " Creating password file… "
249285 pwd_dir=" /srv/users/${system_user} /pwd/${appname} "
250286 mkdir -p " ${pwd_dir} "
251287 pwd_path=" ${pwd_dir} /.htpasswd"
@@ -259,7 +295,7 @@ if [ "$pwd_protect" = "y" ] || [ $run_all = true ]; then
259295
260296 nginx_pwd_conf=" /etc/nginx-sp/vhosts.d/${appname} .d/password.conf"
261297 if [[ ! -e " ${nginx_pwd_conf} " ]]; then
262- show_info " Creating nginx password conf file... "
298+ show_info " Creating nginx password conf file… "
263299
264300 auth_basic=' auth_basic "' " ${pwd_title} " ' ";'
265301 auth_basic_user_file=" auth_basic_user_file ${pwd_path} ;"
@@ -275,7 +311,7 @@ if [ "$pwd_protect" = "y" ] || [ $run_all = true ]; then
275311 show_info " ${appname} not found."
276312 fi
277313
278- show_notice " Finished Password protect app process... "
314+ show_notice " Finished Password protect app process… "
279315fi
280316# === /Password Protect App ===
281317
@@ -286,7 +322,7 @@ if [[ $run_all = false ]]; then
286322fi
287323
288324if [ " $expires_nginx " = " y" ] || [ $run_all = true ]; then
289- show_notice " Adding Expires Nginx Conf... "
325+ show_notice " Adding Expires Nginx Conf… "
290326
291327 echo -n " What is the appname? : "
292328 read appname
@@ -299,17 +335,17 @@ if [ "$expires_nginx" = "y" ] || [ $run_all = true ]; then
299335 show_warning " ${appname} already has expires file. Skipping.."
300336 else
301337
302- show_info " Creating expires nginx conf... "
338+ show_info " Creating expires nginx conf… "
303339 (eval " wget --no-cache -O ${expires_conf_file} ${nginx_expires_conf_url} " )
304340
305- show_info " Restarting nginx... "
341+ show_info " Restarting nginx… "
306342 service nginx-sp restart
307343 fi
308344
309345 else
310346 show_error " You must provide a valid appname"
311347 fi
312348
313- show_notice " Finished Adding Expires Nginx Conf... "
349+ show_notice " Finished Adding Expires Nginx Conf… "
314350fi
315351# === /Expires Nginx Conf ===
0 commit comments