#!/bin/sh -e # ----------------------------------------------------------------- # # # # Enables a configuration file for Apache2 Web server # # # # Author : Jonathan Dray # # Version : 1.0 # # Date : 2008.03.14 # # License : lgpl # # Usage : a2enconf [configuration file name] # # # # ----------------------------------------------------------------- # SYSCONFDIR='/etc/apache2' if [ -z $1 ]; then echo "Which configuration file would you like to enable?" echo -n "Your choices are: " ls $SYSCONFDIR/conf-available/* | \ sed -e "s,$SYSCONFDIR/conf-available/,,g" | xargs echo echo -n "Configuration file name? " read CONFNAME else CONFNAME=$1 fi if [ $CONFNAME = "default" ]; then PRIORITY="000" fi if [ -e $SYSCONFDIR/conf-enabled/$CONFNAME -o \ -e $SYSCONFDIR/conf-enabled/"$PRIORITY"-"$CONFNAME" ]; then echo "This configuration file is already enabled!" exit 0 fi if ! [ -e $SYSCONFDIR/conf-available/$CONFNAME ]; then echo "This configuration file does not exist!" >&2 exit 1 fi if [ $CONFNAME = "default" ]; then ln -sf $SYSCONFDIR/conf-available/$CONFNAME \ $SYSCONFDIR/conf-enabled/"$PRIORITY"-"$CONFNAME" else ln -sf $SYSCONFDIR/conf-available/$CONFNAME $SYSCONFDIR/conf-enabled/$CONFNAME fi echo "Configuration file $CONFNAME added; run /etc/init.d/apache2 reload to enable."