Skip to content

Commit 48ed9bb

Browse files
committed
use snap installed certbot. exclude staging. improve output and error handling.
1 parent 607b3f7 commit 48ed9bb

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

update.sh

+16-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ checkoutdir="${workdir}/${reponame}"
2323
resourcedir="${workdir}/magical-pony"
2424
statusfile='/var/www/html/index.html'
2525
certbotargs='-w /var/www/html -d legal.creativecommons.org'
26+
no_errors=1
2627

2728
rm -rf "${checkoutdir}"
2829

@@ -120,6 +121,10 @@ echo ' <h2 class="clear">Branches</h2>' >> "${statusfile}"
120121

121122
for branchname in $(git branch -r | grep -v 'HEAD\|main')
122123
do
124+
if [[ "${branchname}" == 'origin/staging' ]]
125+
then
126+
continue
127+
fi
123128
echo "# ${branchname}"
124129
branchid="${branchname##*/}"
125130
if [[ -n "${branchid//[-.[:alnum:]]/}" ]]
@@ -200,16 +205,19 @@ echo
200205
echo '# apache2 restart'
201206
/usr/sbin/service apache2 restart
202207
sleep 1
208+
echo
203209

204210
echo
205211
echo '# cerbotargs:'
206212
echo "${certbotargs}"
213+
echo
214+
207215
echo
208216
echo '# run cerbot'
209217
echo
210218
# Get any new certificates, incorporate old one, refresh expiring, install any
211219
# new http->https redirects, and do so automatically.
212-
if /usr/bin/certbot \
220+
if /snap/bin/certbot \
213221
--agree-tos -m webmaster@creativecommons.org \
214222
--non-interactive \
215223
--cert-name legal.creativecommons.org \
@@ -222,8 +230,10 @@ if /usr/bin/certbot \
222230
then
223231
echo ' <h2>And we are done!</h2>' >> "${statusfile}"
224232
else
233+
es=${?}
234+
no_errors=0
225235
{
226-
echo ' <h2>certbot ERROR</h2>'
236+
echo " <h2>certbot ERROR (exit status <code>${es}</code>)</h2>"
227237
echo ' <p>See:'
228238
echo ' <pre>/var/log/letsencrypt/letsencrypt.log</pre>'
229239
echo ' <pre>/var/log/magical-pony</pre>'
@@ -261,4 +271,7 @@ echo
261271
echo '# apache2 restart'
262272
/usr/sbin/service apache2 restart
263273

264-
sed -e's/"run-error"/"run-success"/' -i "${statusfile}"
274+
if [[ ${no_errors} == 1 ]]
275+
then
276+
sed -e's/"run-error"/"run-success"/' -i "${statusfile}"
277+
fi

0 commit comments

Comments
 (0)