certbot/letsencrypt-apache/letsencrypt_apache/tests/apache-conf-files/hackish-apache-test

71 lines
1.8 KiB
Text
Raw Normal View History

#!/bin/bash
# A hackish script to see if the client is behaving as expected
# with each of the "passing" conf files.
# TODO presently this requires interaction and human judgement to
# assess, but it should be automated
export EA=/etc/apache2/
TESTDIR="`dirname $0`"
LEROOT="`realpath \"$TESTDIR/../../../../\"`"
cd $TESTDIR/passing
LETSENCRYPT="${LETSENCRYPT:-$LEROOT/venv/bin/letsencrypt}"
function CleanupExit() {
echo control c, exiting tests...
if [ "$f" != "" ] ; then
2015-12-16 22:41:35 -05:00
Cleanup
fi
exit 1
}
2015-12-16 22:51:45 -05:00
function Setup() {
if [ "$APPEND_APACHECONF" = "" ] ; then
sudo cp "$f" "$EA"/sites-available/
sudo ln -sf "$EA/sites-available/$f" "$EA/sites-enabled/$f"
sudo echo """
<VirtualHost *:80>
ServerName example.com
DocumentRoot /tmp/
ErrorLog /tmp/error.log
CustomLog /tmp/requests.log combined
</VirtualHost>""" >> $EA/sites-available/throwaway-example.conf
2015-12-16 22:51:45 -05:00
else
TMP="/tmp/`basename \"$APPEND_APACHECONF\"`.$$"
sudo cp -a "$APPEND_APACHECONF" "$TMP"
sudo bash -c "cat \"$f\" >> \"$APPEND_APACHECONF\""
fi
}
2015-12-16 22:41:35 -05:00
function Cleanup() {
if [ "$APPEND_APACHECONF" = "" ] ; then
sudo rm /etc/apache2/sites-{enabled,available}/"$f"
sudo rm $EA/sites-available/throwaway-example.conf
2015-12-16 22:41:35 -05:00
else
sudo mv "$TMP" "$APPEND_APACHECONF"
fi
}
FAILS=0
trap CleanupExit INT
for f in *.conf ; do
echo -n testing "$f"...
2015-12-16 22:51:45 -05:00
Setup
echo running from $PWD
2015-12-16 20:21:47 -05:00
RESULT=`echo c | sudo "$LETSENCRYPT" --staging --apache --register-unsafely-without-email --agree-tos certonly -t 2>&1`
if echo $RESULT | grep -Eq \("Please specify --domains"\|"mod_macro is not yet"\) ; then
echo passed
else
echo failed
echo $RESULT
echo
echo
FAILS=`expr $FAILS + 1`
fi
2015-12-16 22:41:35 -05:00
Cleanup
done
if [ "$FAILS" -ne 0 ] ; then
2015-12-16 20:21:47 -05:00
exit 1
fi
2015-12-16 20:21:47 -05:00
exit 0