Skip to content

Instantly share code, notes, and snippets.

@mmstick
Created March 9, 2015 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmstick/070d9a9e6457972c03fd to your computer and use it in GitHub Desktop.
Save mmstick/070d9a9e6457972c03fd to your computer and use it in GitHub Desktop.
An Apache2 script for disabling websites.
#!/bin/bash
avail=/etc/httpd/conf/sites-enabled/$1.conf
enabled=/etc/httpd/conf/sites-enabled
site=`ls /etc/httpd/conf/sites-enabled`
if [ "$#" != "1" ]; then
echo "Use script: n2dissite virtual_site"
echo -e "\nAvailable virtual hosts: \n$site"
exit 0
else
if test -e $avail; then
sudo rm $avail
else
echo -e "$avail virtual host does not exist! Exiting"
exit 0
fi
if test -e $enabled/$1.conf; then
echo "Error!! Could not remove $avail virtual host!"
else
echo -e "Success! $avail has been removed!\nsudo systemctl restart httpd"
exit 0
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment