Bug#349716: apache2-common: please consider giving a2[en|dis][mod|site] more flexibility
tags #349716 patch
thanks
On Tue, Jan 24, 2006 at 09:38:04PM +0100, Marc Haber wrote:
> I would like to submit a complete rewrite for a2[en|dis][mod|site].
Attached.
Greetings
Marc
--
-----------------------------------------------------------------------------
Marc Haber | "I don't trust Computers. They | Mailadresse im Header
Mannheim, Germany | lose things." Winona Ryder | Fon: *49 621 72739834
Nordisch by Nature | How to make an American Quilt | Fax: *49 621 72739835
#!/bin/sh -e
if [ -z "$SYSCONFDIR" ]; then
SYSCONFDIR='/etc/apache2'
fi
if [ -z "$LOCCONFDIR" ]; then
LOCCONFDIR="$SYSCONFDIR"
fi
if [ -z "$INITSCRIPT" ]; then
INITSCRIPT="/etc/init.d/apache2"
fi
case "$(basename $0)" in
a2enmod) OBJ="module"; ACT="enable";;
a2dismod) OBJ="module"; ACT="disable";;
a2ensite) OBJ="site"; ACT="enable";;
a2dissite) OBJ="site"; ACT="disable";;
*) echo >&2 "$0 call name unknown"; exit 1 ;;
esac
case "$OBJ" in
module) PRIORITY=""
NAME="Module"; DIR="mods"; SFFX=".load"; RELOAD="force-reload";;
site) NAME="Site"; DIR="sites"; SFFX=""; RELOAD="reload";;
*) echo >&2 "unexpected OBJ value $OBJ"; exit 1;;
esac
if [ -z "$AVAILDIR" ]; then
AVAILDIR="$SYSCONFDIR/$DIR-available"
fi
if [ -z "$ENABLDIR" ]; then
ENABLDIR="$LOCCONFDIR/$DIR-enabled"
fi
if [ -z $1 ]; then
echo "Which $OBJ would you like to ${ACT}?"
echo -n "Your choices are: "
find $AVAILDIR -name "*$SFFX" -mindepth 1 -maxdepth 1 \
-exec basename '{}' $SFFX \; | tr '\n' ' '
echo
echo -n "$NAME name? "
read ACTON
else
ACTON=$1
fi
#figure out if we're on a prefork or threaded mpm
if [ -x /usr/sbin/apache2 ]; then
PREFORK=`/usr/sbin/apache2 -l | grep prefork || true`
fi
if [ "$OBJ" = "module" ] && [ "$ACTON" = "cgi" ] && [ -z "$PREFORK" ]; then
ACTON="cgid"
fi
if [ "$OBJ" = "site" ] && [ "$ACTON" = "default" ]; then
PRIORITY="000-"
fi
if [ "$ACT" = "enable" ]; then
if [ -e "$ENABLDIR/$PRIORITY$ACTON$SFFX" ]; then
echo "This $OBJ is already enabled!"
exit 0
fi
if ! [ -e "$AVAILDIR/$ACTON$SFFX" ]; then
echo "This $OBJ does not exist!"
exit 1
fi
fi
if [ "$ACT" = "disable" ]; then
if ! [ -e "$ENABLDIR/$PRIORITY$ACTON$SFFX" ]; then
echo "This $OBJ is already disabled, or does not exist!"
exit 1
fi
fi
if [ "$OBJ" = "module" ] && [ "$ACT" = "enable" ]; then
for i in conf load; do
if [ -e "$AVAILDIR/$ACTON.$i" -a ! -e "$ENABLDIR/$ACTON.$i" ]; then
ln -sf "$AVAILDIR/$ACTON.$i" "$ENABLDIR/$ACTON.$i"
fi
done
elif [ "$OBJ" = "site" ] && [ "$ACT" = "enable" ]; then
ln -sf $AVAILDIR/$ACTON $ENABLDIR/$PRIORITY$ACTON
elif [ "$OBJ" = "module" ] && [ "$ACT" = "disable" ]; then
rm -f "$ENABLDIR/$ACTON.conf" "$ENABLDIR/$ACTON.load"
elif [ "$OBJ" = "site" ] && [ "$ACT" = "disable" ]; then
rm -f "$ENABLDIR/$PRIORITY$ACTON"
fi
echo "$NAME $ACTON ${ACT}d; run $INITSCRIPT $RELOAD to activate."
exit 0
Reply to: