-
-
Save GeorgeDewar/11386543 to your computer and use it in GitHub Desktop.
Enable and disable nginx sites
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 | |
function usage { | |
echo "Manage nginx sites" | |
echo | |
echo "Usage:" | |
echo | |
echo "ng pull" | |
echo "ng push" | |
echo "ng list" | |
echo "ng list-enabled" | |
echo "ng enable <site>" | |
echo "ng disable <site>" | |
exit 1 | |
} | |
if [ "$#" -lt "1" ]; then | |
usage | |
fi | |
op=$1 | |
shift 1 | |
case "$op" in | |
pull) | |
git -C /home/mars/nginx-dg pull | |
;; | |
push) | |
git -C /home/mars/nginx-dg add . | |
git -C /home/mars/nginx-dg commit | |
git -C /home/mars/nginx-dg push | |
;; | |
list) | |
ls /etc/nginx/sites-available | |
;; | |
list-enabled) | |
ls /etc/nginx/sites-enabled | |
;; | |
enable) | |
site=$1 | |
if [ ! -f "/etc/nginx/sites-available/$site" ]; then | |
echo "No such site \"$site\"" | |
exit 1 | |
fi | |
sudo ln -s /etc/nginx/sites-available/$site /etc/nginx/sites-enabled/$site | |
sudo service nginx reload | |
;; | |
disable) | |
site=$1 | |
if [ ! -f "/etc/nginx/sites-enabled/$site" ]; then | |
echo "No such enabled site \"$site\"" | |
exit 1 | |
fi | |
sudo rm /etc/nginx/sites-enabled/$site | |
sudo service nginx reload | |
;; | |
*) | |
usage | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment