Skip to content

Instantly share code, notes, and snippets.

@MKorostoff
Last active November 15, 2018 20:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MKorostoff/7517143 to your computer and use it in GitHub Desktop.
Save MKorostoff/7517143 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# @author Matt Korostoff <mkorostoff@gmail.com>
#
# @internal stop varnish, restart apache on port 80
#
# @category apache
#
# @copyright Licensed under the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version. http://www.gnu.org/licenses/
varnish_process=$(curl -I -silent localhost|grep Varnish)
apache_process=$(curl -I -silent localhost:8000|grep Apache)
if [ ! -z "$varnish_process" ]; then
if [ ! -z "$apache_process" ]; then
sudo pkill varnishd >> /dev/null 2>&1
#Change every instance of '8000' to '80' in apache config, then restart
sudo sed -i .bak 's/8000/80/g' /etc/apache2/httpd.conf
sudo sed -i .bak 's/8000/80/g' /etc/apache2/extra/httpd-vhosts.conf
sudo apachectl restart
sleep 1
#Report sucess or failure
varnish_process=$(curl -I -silent localhost|grep Varnish)
if [ -z "$varnish_process" ]; then
echo "Varnish killed"
else
echo "Varnish could not be stopped"
fi
apache_process=$(curl -I -silent localhost|grep Apache)
if [ ! -z "$apache_process" ]; then
echo "Apache restarted on port 80"
else
echo "Apache failed to start on port 80"
fi
else
echo "Apache is not running on port 8000"
fi
else
echo "Varnish is not running on port 80"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment