Last active
December 10, 2015 07:58
-
-
Save tonyseek/4404339 to your computer and use it in GitHub Desktop.
A script to manage 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
#!/usr/bin/env sh | |
SITES_AVAILABLE_DIR="/etc/nginx/sites-available" | |
SITES_ENABLED="/etc/nginx/sites-enabled" | |
case "$1" in | |
enable) | |
if [ -f "${SITES_AVAILABLE_DIR}/$2" ] | |
then | |
ln -s "${SITES_AVAILABLE_DIR}/$2" "${SITES_ENABLED}/$2" | |
exit 0 | |
else | |
echo "The site configuration is not located at ${SITES_AVAILABLE_DIR}/$2." >&2 | |
fi | |
;; | |
disable) | |
if [ -f "${SITES_ENABLED}/$2" ] | |
then | |
rm -f "${SITES_ENABLED}/$2" | |
exit 0 | |
else | |
echo "The site configuration is not located at ${SITES_ENABLED}/$2." >&2 | |
fi | |
;; | |
*) | |
echo "Usage: $0 {enable|disable} site_configuration_name" >&2 | |
;; | |
esac | |
exit 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment