Command that removes domain dir and its nginx config
This file contains 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