#!/bin/sh


enable() {
	if [ -n $1 ]; then
		echo "Enabling '$1'"
		sudo a2ensite $1
		op=$?
		sudo systemctl reload apache2
		return $op
	else
		return 16
	fi
}

disable() {
	if [ -n $1 ]; then
		echo "Disabling '$1'"
		sudo a2dissite $1
		op=$?
		sudo systemctl reload apache2
		return $op
	else
		return 16
	fi
}

usage() {
	echo "////// ProxyChad //////"
	echo "Usage: proxychad <enable|disable|reload> <vhost>"
}


case $1 in
	"enable" | "e")
		enable $2
		;;
	"disable" | "d")
		disable $2
		;;
	"reload" | "r")
		disable $2
		enable $2
		;;

	*)
		usage
		;;
esac
