File: /var/lib/dpkg/info/webmin.postinst
#!/bin/sh
# Fix old versions of Webmin that might kill the UI process on upgrade
if [ -d /etc/webmin ]; then
cat >/etc/webmin/stop 2>/dev/null <<'EOD'
#!/bin/sh
echo Stopping Webmin server in /usr/libexec/webmin
pidfile=`grep "^pidfile=" /etc/webmin/miniserv.conf | sed -e 's/pidfile=//g'`
pid=`cat $pidfile`
if [ "$pid" != "" ]; then
kill $pid || exit 1
if [ "$1" = "--kill" ]; then
sleep 1
(kill -9 -- -$pid || kill -9 $pid) 2>/dev/null
fi
exit 0
else
exit 1
fi
EOD
fi
inetd=`grep "^inetd=" /etc/webmin/miniserv.conf 2>/dev/null | sed -e 's/inetd=//g'`
if [ "$1" = "upgrade" -a "$1" != "abort-upgrade" ]; then
# Upgrading the package, so stop the old webmin properly
if [ "$inetd" != "1" ]; then
/etc/webmin/stop >/dev/null 2>&1 </dev/null
fi
fi
cd /usr/share/webmin
config_dir=/etc/webmin
var_dir=/var/webmin
perl=/usr/bin/perl
autoos=1
if [ "$WEBMIN_PORT" != "" ]; then
port=$WEBMIN_PORT
else
port=10000
fi
login=root
if [ -r /etc/shadow ]; then
crypt=x
else
crypt=`grep "^root:" /etc/passwd | cut -f 2 -d :`
fi
host=`hostname`
ssl=1
atboot=1
makeboot=1
nochown=1
autothird=1
noperlpath=1
nouninstall=1
nostart=1
export config_dir var_dir perl autoos port login crypt host ssl nochown autothird noperlpath nouninstall nostart allow atboot makeboot
tempdir=/tmp/.webmin
if [ ! -d $tempdir ]; then
tempdir=/tmp
fi
./setup.sh >/webmin-setup.out 2>&1
if [ "webmin" = "webmin" ]; then
grep sudo= /etc/webmin/miniserv.conf >/dev/null 2>&1
if [ "$?" = 1 ]; then
# Allow sudo-based logins for Ubuntu
echo sudo=1 >>/etc/webmin/miniserv.conf
fi
fi
rm -f /var/lock/subsys/webmin
if [ "" != "1" ]; then
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
invoke-rc.d webmin stop >/dev/null 2>&1 </dev/null
invoke-rc.d webmin start >/dev/null 2>&1 </dev/null
else
/etc/webmin/stop >/dev/null 2>&1 </dev/null
/etc/webmin/start >/dev/null 2>&1 </dev/null
fi
fi
if [ "webmin" = "usermin" ]; then
(insserv webmin || update-rc.d webmin defaults) >/dev/null 2>&1
fi
cat >/etc/webmin/uninstall.sh <<EOFF
#!/bin/sh
printf "Are you sure you want to uninstall Webmin? (y/n) : "
read answer
printf "\n"
if [ "\$answer" = "y" ]; then
echo "Removing Webmin package .."
dpkg --remove webmin
echo "Done!"
fi
EOFF
chmod +x /etc/webmin/uninstall.sh
port=`grep "^port=" /etc/webmin/miniserv.conf | sed -e 's/port=//g'`
perl -e 'use Net::SSLeay' >/dev/null 2>/dev/null
sslmode=0
if [ "$?" = "0" ]; then
grep ssl=1 /etc/webmin/miniserv.conf >/dev/null 2>/dev/null
if [ "$?" = "0" ]; then
sslmode=1
fi
fi
if [ "$sslmode" = "1" ]; then
echo "Webmin install complete. You can now login to https://$host:$port/"
else
echo "Webmin install complete. You can now login to http://$host:$port/"
fi
if [ "webmin" = "webmin" ]; then
echo "as root with your root password, or as any user who can use sudo"
echo "to run commands as root."
else
echo "as any user on the system."
fi