Skip to content

Instantly share code, notes, and snippets.

@tonyseek
Last active December 10, 2015 07:58
Show Gist options
  • Save tonyseek/4404339 to your computer and use it in GitHub Desktop.
Save tonyseek/4404339 to your computer and use it in GitHub Desktop.
A script to manage nginx sites.
#!/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