Created
December 24, 2017 20:54
-
-
Save BytewaveMLP/44c177e441e484b00dc2b53023c1f57e to your computer and use it in GitHub Desktop.
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 | |
op="$1" | |
site="$2" | |
script="$0" | |
error_exit() { | |
echo "$(basename "$script"): $1" >&2 | |
exit $2 | |
} | |
case "$op" in | |
"enable") | |
if [ ! -f "/etc/nginx/sites-available/$site" ]; then | |
error_exit "invalid site: $site" 2 | |
fi | |
if [ -f "/etc/nginx/sites-enabled/$site" ]; then | |
error_exit "site already enabled: $site" 2 | |
fi | |
sudo ln -s "/etc/nginx/sites-available/$site" "/etc/nginx/sites-enabled/$site" | |
error_exit "site enabled: $site" 0 | |
;; | |
"disable") | |
if [ ! -f "/etc/nginx/sites-enabled/$site" ]; then | |
error_exit "invalid site: $site" 2 | |
fi | |
sudo rm "/etc/nginx/sites-enabled/$site" | |
error_exit "site disabled: $site" 0 | |
;; | |
*) | |
error_exit "invalid operation: $op" 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment