Created
May 5, 2016 14:00
-
-
Save insane-dev/135e025f7de98ec145c73e6e6c91aa19 to your computer and use it in GitHub Desktop.
Command that removes domain dir and its nginx config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Removedomain command | |
# --- | |
# script can run with the domain as a command line input | |
# `sudo ./nginx_domain.sh my_domain.com` or without and | |
# the script will prompt the user for input | |
# | |
# BTW: You can make it global e.g. by: | |
# sudo ln -s /opt/delagics/removedomain.sh /usr/bin/removedomain | |
# Configiguration | |
web_root='/var/www' | |
config_dir='/etc/nginx' | |
if [ -z "$1" ] | |
then | |
echo -e "Enter domain name:" | |
read DOMAIN | |
echo "Removing Nginx domain settings for: $DOMAIN" | |
if [ -z "$DOMAIN" ] | |
then | |
echo "Domain required" | |
exit 1 | |
fi | |
fi | |
if [ -z "$DOMAIN" ] | |
then | |
DOMAIN=$1 | |
fi | |
sudo unlink $config_dir/sites-enabled/$DOMAIN.conf | |
sudo rm -f $config_dir/sites-available/$DOMAIN.conf | |
echo "Removing web directories (recursively)" | |
sudo rm -rf $web_root/"$DOMAIN" | |
sudo /etc/init.d/nginx reload | |
echo "Nginx - reload" | |
echo "$DOMAIN has been removed" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment