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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
#!/bin/bash -e
##DEBHELPER##
if [ -n "$_DEBIAN_DEBUG_MASON_EXAMPLES" ]; then
vflag="-v"
else
vflag=""
fi
vecho() {
if [ -n "$_DEBIAN_DEBUG_MASON_EXAMPLES" ]; then echo "DebianMason: $*" >&2; fi
}
vcmd() {
if [ -n "$_DEBIAN_DRYRUN_MASON_EXAMPLES" ]; then
echo "DebianMason<cmd>: $*" >&2
else
command "$@"
fi
}
cp_or_gunzip() {
if [ -f "$1.gz" ]; then
vcmd gzip $vflag -dc <"$1.gz" >"$2"
else
vcmd cp $vflag "$1" "$2"
fi
}
dc_true() {
db_get "$1"
vecho "debconf: $1=$RET"
[ "$RET" = "true" ]
}
. /usr/share/debconf/confmodule
# Check for apache-perl/apache-ssl ?
EXAMPLE_DOCROOT=/var/www/mason_example
case "$1" in
configure)
for variant in "" "perl" "ssl" "apache2"; do
if [ "$variant" = "apache2" ]; then
APACHE_CONF_DIR=/etc/apache2/conf.d
APACHE_CTL=/usr/sbin/apache2ctl
APACHE_CONF_SOURCE=/usr/share/doc/libhtml-mason-perl-examples/examples/mason_apache2_example.conf
APACHE_INIT_SCRIPT=apache2
else
APACHE_CONF_DIR=/etc/apache${variant:+-${variant}}/conf.d
APACHE_CTL=/usr/sbin/apache${variant:+-${variant}}ctl
APACHE_CONF_SOURCE=/usr/share/doc/libhtml-mason-perl-examples/examples/mason_example.conf
APACHE_INIT_SCRIPT=apache${variant:+-${variant}}
fi
APACHE_CONF_FRAGMENT=$APACHE_CONF_DIR/libhtml-mason-perl-examples.conf
vecho variant=$variant APACHE_INIT_SCRIPT=$APACHE_INIT_SCRIPT APACHE_CONF_DIR=$APACHE_CONF_DIR APACHE_CTL=$APACHE_CTL
# Only if apache is installed
if [ -d $APACHE_CONF_DIR -a -x $APACHE_CTL ]; then
if [ ! -f $APACHE_CONF_FRAGMENT ] && dc_true libhtml-mason-perl/install_examples; then
# If the configs are not installed, and the user wants them
vecho Installing in $APACHE_CONF_DIR
if [ -f $APACHE_CONF_DIR/libhtml-mason-perl ]; then
# If 1.25-2 era config found, just use that
vcmd mv $vflag -- $APACHE_CONF_DIR/libhtml-mason-perl $APACHE_CONF_FRAGMENT
else
cp_or_gunzip $APACHE_CONF_SOURCE $APACHE_CONF_FRAGMENT
fi
if [ -d /usr/lib/cgi-bin ]; then
cp_or_gunzip /usr/share/doc/libhtml-mason-perl-examples/examples/mason_example.cgi /usr/lib/cgi-bin/mason_example.cgi
vcmd chmod $vflag 0755 /usr/lib/cgi-bin/mason_example.cgi
fi
vcmd cp -R $vflag /usr/share/doc/libhtml-mason-perl-examples/examples/mason_example /var/www
vcmd find $EXAMPLE_DOCROOT -name '*.gz' | xargs gunzip $vflag -f --
if [ -x $APACHE_CTL ] && dc_true libhtml-mason-perl/auto_restart_apache; then
invoke-rc.d $APACHE_INIT_SCRIPT reload || true
fi
elif [ -f $APACHE_CONF_FRAGMENT ] && ! dc_true libhtml-mason-perl/install_examples; then
# If the configs are installed, and the user doesn't want them
vecho Uninstalling from $APACHE_CONF_DIR
vcmd rm $vflag -f $APACHE_CONF_FRAGMENT
vcmd rm $vflag -f /usr/lib/cgi-bin/mason_example.cgi
vcmd rm -rf $vflag $EXAMPLE_DOCROOT
if [ -x $APACHE_CTL ] && dc_true libhtml-mason-perl/auto_restart_apache; then
invoke-rc.d $APACHE_INIT_SCRIPT reload || true
fi
fi
fi
done
;;
esac
exit 0
|