Skip to content

Instantly share code, notes, and snippets.

@ssmulders
Last active June 22, 2018 10:37
Show Gist options
  • Save ssmulders/1ee6e3f6a63ed7f9402c1471666bba26 to your computer and use it in GitHub Desktop.
Save ssmulders/1ee6e3f6a63ed7f9402c1471666bba26 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Delete vhost / site from nginx on macOS
DOMAIN=$1
SITES_AVAILABLE="/usr/local/etc/nginx/sites-available"
SITES_ENABLED="/usr/local/etc/nginx/sites-enabled"
read -p "Are you sure you want to delete $DOMAIN? " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo "Removing $DOMAIN from Nginx"
rm -rf $SITES_AVAILABLE/$DOMAIN
rm -rf $SITES_ENABLED/$DOMAIN
rm -rf /Users/stan/Dropbox/_LocalServer/$DOMAIN
sudo nginx -s reload
awk '!/'$DOMAIN'/' /etc/hosts > temp && sudo mv temp /etc/hosts
fi
echo "All done! $DOMAIN is a goner.."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment