postinst is in dwww 1.12.1.
This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.
The actual contents of the file can be viewed below.
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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | #!/usr/bin/perl -w
# vim:ft=perl:cindent:ts=4:sts=4:et:sw
#
# postinst for dwww
#
use Debconf::Client::ConfModule qw(:all);
use Debian::Dwww::ConfigFile qw(ReadConfigFile WriteConfigFile);
use strict;
my $stdcgidir = '/usr/lib/cgi-bin';
my $cfgfile = '/etc/dwww/dwww.conf';
my $newcfgfile = '/etc/dwww/dwww.conf.dpkg-new';
$|=1;
version('2.0');
if ($ARGV[0] eq 'configure' or $ARGV[0] eq 'reconfigure')
{
my $dwwwcfg = ReadConfigFile($cfgfile);
# docrootdir
my $old_docdir = $dwwwcfg->{DWWW_DOCROOTDIR}->{cfgval} ? canondir($dwwwcfg->{DWWW_DOCROOTDIR}->{cfgval}) : '';
my $old_cgidir = $dwwwcfg->{DWWW_CGIDIR}->{cfgval} ? canondir($dwwwcfg->{DWWW_CGIDIR}->{cfgval}): '';
$dwwwcfg->{DWWW_DOCROOTDIR}->{cfgval} = canondir(scalar get('dwww/docrootdir'));
$dwwwcfg->{DWWW_CGIDIR}->{cfgval} = canondir(scalar get('dwww/cgidir'));
$dwwwcfg->{DWWW_CGIUSER}->{cfgval} = get('dwww/cgiuser');
$dwwwcfg->{DWWW_SERVERPORT}->{cfgval} = get('dwww/serverport');
$dwwwcfg->{DWWW_SERVERNAME}->{cfgval} = get('dwww/servername');
my $do_index = (-x '/usr/bin/index++'
and not -s '/var/cache/dwww/dwww.swish++.index'
and scalar get('dwww/index_docs') eq 'true') ? 1 : 0;
&SetupDwwwLinks ($old_docdir, $dwwwcfg->{DWWW_DOCROOTDIR}->{cfgval},
$old_cgidir, $dwwwcfg->{DWWW_CGIDIR}->{cfgval});
WriteConfigFile($newcfgfile, $dwwwcfg);
my @cmd = ("ucf","--debconf-ok", "--three-way", $newcfgfile, $cfgfile);
system (@cmd) == 0 or die "system @cmd failed: $!\n";
@cmd = ("ucfr", "dwww", $cfgfile);
system (@cmd) == 0 or die "system @cmd failed: $!\n";
unlink ($newcfgfile);
stop(); # stop debconf
if ( ! -d "/var/cache/dwww" ) {
mkdir "/var/cache/dwww", 0755 or die "Cannot create directory /var/cache/dwww: $!\n";
chown 0, 0, "/var/cache/dwww";
} else {
system("rm", "-rf", "/var/cache/dwww/db");
}
mkdir "/var/cache/dwww/db", 0755 or die "Cannot create directory /var/cache/dwww/db: $!\n";
my $cgiuser = $dwwwcfg->{DWWW_CGIUSER}->{cfgval};
my $uid = (getpwnam($cgiuser))[2] ;
defined $uid or die "User $cgiuser does not exist\n";
$uid or die "You DON'T want to run the dwww CGI script as root!\n";
chown $uid, 0, "/var/cache/dwww/db";
if ( -x "/etc/cron.daily/dwww" )
{
print STDERR "\nBuilding dwww pages in the background...\n";
system("setsid /etc/cron.daily/dwww &");
}
if ($do_index and -x "/usr/sbin/dwww-index++")
{
print STDERR "\nIndexing documentation files in the background...\n";
system("dwww-index++ &");
}
}
else
{
stop(); # stop debconf
}
my $dh_commands="set -- @ARGV\n" . << 'EOF';
set -e
if [ "$1" = "configure" ] && dpkg --compare-versions "$2" lt-nl "1.12.0~"; then
for apache in "apache" "apache-perl" "apache-ssl" "apache2"; do
confd="/etc/$apache/conf.d";
if [ -L "$confd/dwww" ] ; then
rm -f "$confd/dwww"
rmdir --ignore-fail-on-non-empty "$confd" "/etc/$apache"
elif [ -e "$confd/dwww" ]; then
echo "Warning: $confd/dwww exists, but it is not a symbolic link, " \
"please remove it manually." >&2
fi
done
fi
# Automatically added by dh_apache2
if true; then
if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
. /usr/share/apache2/apache2-maintscript-helper
for conf in dwww ; do
apache2_invoke enconf $conf || exit $?
done
fi
fi
# End automatically added section
# Automatically added by dh_installmenu
if [ "$1" = "configure" ] && [ -x "`which update-menus 2>/dev/null`" ]; then
update-menus
fi
# End automatically added section
# Automatically added by dh_installdeb
dpkg-maintscript-helper mv_conffile /etc/dwww/apache.conf /etc/apache2/conf-available/dwww.conf 1.12.0~ -- "$@"
# End automatically added section
EOF
system ($dh_commands) / 256 == 0
or die "Problem with shell scripts: $!";
exit 0;
# SOUBROUTINES
sub SetupDwwwLinks
{
my ($olddocdir, $newdocdir, $oldcgidir, $newcgidir) = @_;
if (($olddocdir ne "") and ($olddocdir ne $newdocdir))
{
system("rm", "-rf", "$olddocdir/dwww");
}
if (($oldcgidir ne $stdcgidir) and ($oldcgidir ne ""))
{
unlink "$oldcgidir/dwww";
}
if (($newcgidir ne $stdcgidir) and ( -d $newcgidir ))
{
unlink "$newcgidir/dwww";
system("cp","-p","$stdcgidir/dwww", "$newcgidir/dwww");
}
}
sub canondir
{
my $dir = $_[0];
$dir =~ s|/+|/|g;
$dir =~ s|/$||;
return $dir;
}
|