view debian/dcc-common.postinst @ 3:b689077d4918

Ignore old patches
author Peter Gervai <grin@grin.hu>
date Tue, 10 Mar 2009 14:31:24 +0100
parents f6716cb00029
children
line wrap: on
line source

#!/bin/sh
# postinst script for dcc
#
# 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>
#        * <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
#
# quoting from the policy:
#     Any necessary prompting should almost always be confined to the
#     post-installation script, and should be protected with a conditional
#     so that unnecessary prompting doesn't happen if a package's
#     installation fails and the `postinst' is called with `abort-upgrade',
#     `abort-remove' or `abort-deconfigure'.
#SCRIPTSCOMMON#


case "$1" in
    configure)
	# creating dcc group if he isn't already there
	if ! getent group dcc >/dev/null; then
		echo Adding system group: dcc.
		addgroup --system dcc
	fi

	# creating dcc user if he isn't already there
	if ! getent passwd dcc >/dev/null; then
		echo Adding system user: dcc.
		adduser --system --ingroup dcc --no-create-home --home /var/lib/dcc dcc
		usermod -c "DCC System User"       dcc
#		usermod -d "/var/lib/dcc"          dcc
#		usermod -g "dcc"                   dcc
		usermod -s "/bin/false"            dcc
	fi
		


	
    	PASSWD1=`ps|cksum|tr '        ' 'xy'`
	PASSWD2=`ps|cksum|tr '        ' 'xy'`
    	if ! [ -d /var/log/dcc ]; then
		mkdir -p /var/log/dcc
		ln -s /var/log/dcc /var/lib/dcc/log
	fi

	if ! [ -f /etc/dcc/ids ]; then
		sed -e "s/secret1/$PASSWD1/" -e "s/secret2/$PASSWD2/" /usr/share/dcc/ids > /etc/dcc/ids
		chmod 0600 /etc/dcc/ids
		chown dcc:dcc /etc/dcc/ids
	fi

	if ! [ -f /etc/dcc/map.txt ]; then
		sed -e "s/secret1/$PASSWD1/" /usr/share/dcc/map.txt > /etc/dcc/map.txt
		/usr/sbin/update-dccmaps
		chmod 0600 /etc/dcc/map.txt /var/lib/dcc/map
		chown dcc:dcc /var/lib/dcc/map /etc/dcc/map.txt
	fi

	if [ `stat -c%U /var/lib/dcc/map` != "dcc" ] || [ `stat -c%G /var/lib/dcc/map` != "dcc" ]; then 
		chown dcc:dcc /var/lib/dcc/map
	fi

	if dpkg --compare-versions "$2" lt "1.2.58-1"; then 
		rm -f /var/lib/dcc/map
		/usr/sbin/update-dccmaps
	fi
	

	if [ -x /usr/bin/cdcc ]; then
		chown dcc:dcc /usr/bin/cdcc
		chmod 04755 /usr/bin/cdcc
	fi
	
	if [ -x /usr/bin/dccsight ]; then
		chown dcc:dcc /usr/bin/dccsight
		chmod 04755 /usr/bin/dccsight
	fi
	
	if [ -d /var/lib/dcc ]; then
		chown dcc:dcc /var/lib/dcc
	fi

	if ! [ -d /var/run/dcc ]; then
		mkdir -p /var/run/dcc
	fi

	if [ -d /var/run/dcc ]; then
		chown dcc:dcc /var/run/dcc
	fi
    ;;

    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