debian/postinst
author Markus Bröker <mbroeker@largo.dyndns.tv>
Sat, 05 Jun 2010 03:32:57 +0200
changeset 55 02afddde7b94
parent 35 3fedae1f6ceb
permissions -rw-r--r--
changelog entry added committer: Markus Bröker <mbroeker@largo.homelinux.org>

#!/bin/sh
# postinst script for mcbot
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <postinst> `abort-remove'
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    configure)
	if [ ! -f /var/lib/mcbot/data/mcbot.dat ];
	then
		echo "Creating initial database in /var/lib/mcbot/data";
		dbtool -a -k 1 -v 1;
		dbtool -d 1;
	fi

	if [ -f /var/lib/mcbot/.mcbotrc.dpkg-old ];
	then
		mv -f /var/lib/mcbot/.mcbotrc.dpkg-old /var/lib/mcbot/.mcbotrc;
	fi

	echo "Changing ownership in /var/lib/mcbot"
	useradd -K UID_MIN=100 -K UID_MAX=999 -K GID_MIN=100 -K GID_MAX=999 -c "MCBOT" -s /bin/bash -d /var/lib/mcbot mcbot
	chown -R mcbot:mcbot /var/lib/mcbot
	echo "Setting permissions for /var/lib/mcbot/.mcbotrc to 600"
	chmod 600 /var/lib/mcbot/.mcbotrc
	echo "ENTER /etc/init.d/mcbot restart after editing .mcbotrc"
	update-rc.d mcbot defaults >/dev/null 2>&1
	invoke-rc.d mcbot restart
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0