2015-12-11 15:18:41 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
# A hackish script to see if the client is behaving as expected
|
|
|
|
|
# with each of the "passing" conf files.
|
|
|
|
|
|
2019-01-09 15:37:45 -05:00
|
|
|
if [ -z "$SERVER" ]; then
|
|
|
|
|
echo "Please set SERVER to the ACME server's directory URL."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2015-12-11 15:18:41 -05:00
|
|
|
export EA=/etc/apache2/
|
|
|
|
|
TESTDIR="`dirname $0`"
|
|
|
|
|
cd $TESTDIR/passing
|
|
|
|
|
|
|
|
|
|
function CleanupExit() {
|
|
|
|
|
echo control c, exiting tests...
|
|
|
|
|
if [ "$f" != "" ] ; then
|
2015-12-16 22:41:35 -05:00
|
|
|
Cleanup
|
2015-12-11 15:18:41 -05:00
|
|
|
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"
|
2016-04-10 14:52:38 -04:00
|
|
|
echo "
|
2015-12-16 23:04:27 -05:00
|
|
|
<VirtualHost *:80>
|
|
|
|
|
ServerName example.com
|
|
|
|
|
DocumentRoot /tmp/
|
|
|
|
|
ErrorLog /tmp/error.log
|
|
|
|
|
CustomLog /tmp/requests.log combined
|
2016-04-10 14:52:38 -04:00
|
|
|
</VirtualHost>" | sudo tee $EA/sites-available/throwaway-example.conf >/dev/null
|
2017-09-25 15:03:09 -04:00
|
|
|
sudo ln -sf $EA/sites-available/throwaway-example.conf $EA/sites-enabled/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"
|
2015-12-16 23:04:27 -05:00
|
|
|
sudo rm $EA/sites-available/throwaway-example.conf
|
2017-09-25 15:03:09 -04:00
|
|
|
sudo rm $EA/sites-enabled/throwaway-example.conf
|
2015-12-16 22:41:35 -05:00
|
|
|
else
|
|
|
|
|
sudo mv "$TMP" "$APPEND_APACHECONF"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-18 11:48:49 -05:00
|
|
|
# if our environment asks us to enable modules, do our best!
|
|
|
|
|
if [ "$1" = --debian-modules ] ; then
|
2018-07-06 12:08:40 -04:00
|
|
|
sudo apt-get install -y apache2
|
2020-10-28 18:08:16 -04:00
|
|
|
sudo apt-get install -y libapache2-mod-wsgi-py3
|
2015-12-23 13:45:08 -05:00
|
|
|
sudo apt-get install -y libapache2-mod-macro
|
2015-12-18 11:48:49 -05:00
|
|
|
|
2016-01-07 11:57:13 -05:00
|
|
|
for mod in ssl rewrite macro wsgi deflate userdir version mime setenvif ; do
|
2016-01-07 11:59:53 -05:00
|
|
|
echo -n enabling $mod
|
2015-12-18 11:48:49 -05:00
|
|
|
sudo a2enmod $mod
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
|
2019-01-09 15:37:45 -05:00
|
|
|
CERTBOT_CMD="sudo $(command -v certbot) --server $SERVER -vvvv"
|
|
|
|
|
CERTBOT_CMD="$CERTBOT_CMD --debug --apache --register-unsafely-without-email"
|
|
|
|
|
CERTBOT_CMD="$CERTBOT_CMD --agree-tos certonly -t --no-verify-ssl"
|
2015-12-18 11:48:49 -05:00
|
|
|
|
2015-12-16 19:43:24 -05:00
|
|
|
FAILS=0
|
2015-12-11 15:18:41 -05:00
|
|
|
trap CleanupExit INT
|
|
|
|
|
for f in *.conf ; do
|
2015-12-16 19:43:24 -05:00
|
|
|
echo -n testing "$f"...
|
2015-12-16 22:51:45 -05:00
|
|
|
Setup
|
2019-01-09 15:37:45 -05:00
|
|
|
RESULT=`echo c | $CERTBOT_CMD 2>&1`
|
2015-12-21 16:49:46 -05:00
|
|
|
if echo $RESULT | grep -Eq \("Which names would you like"\|"mod_macro is not yet"\) ; then
|
2015-12-16 19:43:24 -05:00
|
|
|
echo passed
|
|
|
|
|
else
|
|
|
|
|
echo failed
|
|
|
|
|
echo $RESULT
|
|
|
|
|
echo
|
|
|
|
|
echo
|
|
|
|
|
FAILS=`expr $FAILS + 1`
|
|
|
|
|
fi
|
2015-12-16 22:41:35 -05:00
|
|
|
Cleanup
|
2015-12-11 15:18:41 -05:00
|
|
|
done
|
2015-12-16 19:43:24 -05:00
|
|
|
if [ "$FAILS" -ne 0 ] ; then
|
2015-12-16 20:21:47 -05:00
|
|
|
exit 1
|
2015-12-16 19:43:24 -05:00
|
|
|
fi
|
2015-12-16 20:21:47 -05:00
|
|
|
exit 0
|