#!/bin/sh -e

SYSCONFDIR='/etc/httpd2/conf'

if [ -z "$1" ]; then
	echo "Which port config would you like to enable?"
	echo -n "Your choices are: "
	ls $SYSCONFDIR/ports-available/*.conf | \
	sed -e "s,$SYSCONFDIR/ports-available/\(.*\).conf,\1,g" | xargs echo
	echo -n "Port config name? "
	read CONFNAME
else
	CONFNAME=$1
fi

if [ -e "$SYSCONFDIR/ports-enabled/$CONFNAME.conf" ]; then
	echo "Port config $CONFNAME.conf is already enabled!"
	exit 0
fi

if ! [ -e "$SYSCONFDIR/ports-available/$CONFNAME.conf" ]; then
	echo "Port config $CONFNAME.conf does not exist!"
	exit 1
fi

ln -sf ../ports-available/$CONFNAME.conf \
	$SYSCONFDIR/ports-enabled/$CONFNAME.conf

echo "Port config $CONFNAME installed;"
echo "	run service httpd2 condreload to fully enable."
