1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#!/bin/sh -e
SYSCONFDIR='/etc/apache2'
if [ -z $1 ]; then
echo "Which module would you like to enable?"
echo -n "Your choices are: "
ls /etc/apache2/mods-available/*.load | \
sed -e "s,$SYSCONFDIR/mods-available/,,g" | sed -e 's/\.load$//g;' | xargs echo
echo -n "Module name? "
read MODNAME
else
MODNAME=$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 [ $MODNAME = "cgi" ] && [ -z $PREFORK ]; then
MODNAME="cgid"
fi
if [ -e $SYSCONFDIR/mods-enabled/$MODNAME.load ]; then
echo "This module is already enabled!"
exit 0
fi
if ! [ -e $SYSCONFDIR/mods-available/$MODNAME.load ]; then
echo "This module does not exist!"
exit 1
fi
DEPENDS=`grep "# Depends:" $SYSCONFDIR/mods-available/$MODNAME.load|cut -f2 -d:`
if [ ! -z "$DEPENDS" ]; then
for i in $DEPENDS; do
echo "Enabling $i as a dependency"
/usr/sbin/a2enmod "$i";
done
fi
for i in conf load; do
if [ -e $SYSCONFDIR/mods-available/$MODNAME.$i -a ! -e $SYSCONFDIR/mods-enabled/$MODNAME.$i ]; then
cd $SYSCONFDIR/mods-enabled;
ln -sf ../mods-available/$MODNAME.$i $MODNAME.$i;
fi
done
echo "Module $MODNAME installed; run /etc/init.d/apache2 force-reload to enable."
|