Skip to content

Instantly share code, notes, and snippets.

@kenelliott-gists
Created September 11, 2012 01:18
Show Gist options
  • Save kenelliott-gists/3695261 to your computer and use it in GitHub Desktop.
Save kenelliott-gists/3695261 to your computer and use it in GitHub Desktop.
Shell: remove nginx virtual host
#!/bin/bash
# script location
available=/etc/nginx/sites-available
enabled=/etc/nginx/sites-enabled
sites=/media/psf/Home/Sites
www=/var/www
if [ ! $1 ] ; then
echo "no parameter provided"
exit 0
fi
# remove the symlink in the sites-enabled directory
if [ -f "$enabled"/"$1" ] ; then
rm "$enabled"/"$1"
fi
# remove the config in the sites-available directory
if [ -f "$available"/"$1" ] ; then
rm "$available"/"$1"
fi
# remove the access log
if [ -f "$sites"/"$1"/logs/access.log ] ; then
rm "$sites"/"$1"/logs/access.log
fi
# remove the error log
if [ -f "$sites"/"$1"/logs/error.log ] ; then
rm "$sites"/"$1"/logs/error.log
fi
# remove the convience symlink
if [ -f /var/www/"$1" ] ; then
rm /var/www/"$1"
fi
# restart nginx
/etc/init.d/nginx restart
# output success message
echo "Removed site : ${1}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment