Created
August 3, 2012 21:22
-
-
Save mateusg/3251671 to your computer and use it in GitHub Desktop.
Script for enabling a site, just like a2ensite, from Apache2.
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 | |
# Enables a site, just like a2ensite command, from Apache2. | |
SITES_AVAILABLE_CONFIG_DIR="/opt/nginx/sites-available"; | |
SITES_ENABLED_CONFIG_DIR="/opt/nginx/sites-enabled"; | |
if [ $1 ]; then | |
if [ -f "${SITES_ENABLED_CONFIG_DIR}/${1}" ]; then | |
echo "Site ${1} was already enabled!"; | |
elif [ ! -w $SITES_ENABLED_CONFIG_DIR ]; then | |
echo "You don't have permission to do this. Try to run the command as root." | |
elif [ -f "${SITES_AVAILABLE_CONFIG_DIR}/${1}" ]; then | |
echo "Enabling site ${1}..."; | |
ln -s $SITES_AVAILABLE_CONFIG_DIR/$1 $SITES_ENABLED_CONFIG_DIR/$1 | |
echo "done!" | |
else | |
echo "Site not found!" | |
fi | |
else | |
echo "Please, inform the name of the site to be enabled." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the good script :)
But the first line should be: #!/bin/bash