Skip to content

Instantly share code, notes, and snippets.

@mbenegas
Forked from mateusg/ensite.sh
Created September 22, 2012 17:59
Show Gist options
  • Select an option

  • Save mbenegas/3767201 to your computer and use it in GitHub Desktop.

Select an option

Save mbenegas/3767201 to your computer and use it in GitHub Desktop.
Script for enabling a site, just like a2ensite, from Apache2.
#! 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