Skip to content

Instantly share code, notes, and snippets.

@mateusg
Created August 3, 2012 21:22
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mateusg/3251671 to your computer and use it in GitHub Desktop.
Save mateusg/3251671 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
@pahofmann
Copy link

Thanks for the good script :)
But the first line should be: #!/bin/bash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment