File: dpsyco-lib.postinst

package info (click to toggle)
dpsyco 1.0.29
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 732 kB
  • ctags: 19
  • sloc: sh: 2,189; makefile: 134
file content (112 lines) | stat: -rw-r--r-- 3,618 bytes parent folder | download | duplicates (4)
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
#! /bin/sh
# postinst script for dpsyco
#
# 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 /usr/share/doc/packaging-manual/
#
# 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'.

case "$1" in
    configure)
#############################################################################
######################### Adduser config generation #########################
#############################################################################
	. /etc/dpsyco/defaults.conf

	if [ ! -e $DPADDUSERCFG ] ; then

	    ADDUSERCFG=/etc/adduser.conf

	    . $ADDUSERCFG
	    . /usr/share/dpsyco/change.func

	    LAST_SYSTEM_UID=$(($BASE_UID-1))

	    if ! grep "LAST_SYSTEM_UID=$LAST_SYSTEM_UID" $ADDUSERCFG > /dev/null 2>&1 ; then
		echo "Updates $ADDUSERCFG and sets LAST_SYSTEM_UID=$LAST_SYSTEM_UID."
		changefile \
		    "s|LAST_SYSTEM_UID=[0-9]*|LAST_SYSTEM_UID=$LAST_SYSTEM_UID|g;" \
		    $ADDUSERCFG
	    fi

	    LAST_UID=$(($FIRST_UID-1))
	    FIRST_UID=$BASE_UID

	    echo "# This file was automaticly generated from /etc/adduser.conf."\
	        > $DPADDUSERCFG
	    echo "# So if you change this file you have to change that file"\
		>> $DPADDUSERCFG
	    echo "# acordingly." \
		>> $DPADDUSERCFG
	    cat $ADDUSERCFG | sed -e "
	    s|LAST_UID=[0-9]*|LAST_UID=$LAST_UID|g;
	    s|FIRST_UID=[0-9]*|FIRST_UID=$FIRST_UID|g;" >> $DPADDUSERCFG
	fi
	if ! grep "FIRST_GID=" $DPADDUSERCFG > /dev/null 2>&1 ; then
	    echo "" >> $DPADDUSERCFG
	    echo "# The first GID to be used when autocreating a new group." \
		>> $DPADDUSERCFG
	    echo "FIRST_GID=300" >> $DPADDUSERCFG
	fi

	if ! grep "UID_MATCH=" $DPADDUSERCFG > /dev/null 2>&1 ; then
	    echo "" >> $DPADDUSERCFG
	    echo "# The UID match to use. NOTE that it is only possible to" \
		>> $DPADDUSERCFG
	    echo "# have UID ranges for whole 100 or 1000 number ranges." \
		>> $DPADDUSERCFG
	    echo "UID_MATCH=[5-9][0-9][0-9]" >> $DPADDUSERCFG
	fi

	if ! grep "GID_MATCH=" $DPADDUSERCFG > /dev/null 2>&1 ; then
	    echo "" >> $DPADDUSERCFG
	    echo "# The GID match to use. NOTE that it is only possible to" \
		>> $DPADDUSERCFG
	    echo "# have GID ranges for whole 100 or 1000 number ranges." \
		>> $DPADDUSERCFG
	    echo "GID_MATCH=[3-4][0-9][0-9]" >> $DPADDUSERCFG
	fi

#############################################################################
#################### Permissions to fix some security flaws #################
#############################################################################
	chmod o+x /etc/dpsyco
	chmod o+x /usr/share/dpsyco
	chmod o-rw /usr/share/dpsyco
	chmod o-rw /etc/dpsyco
    ;;

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

    ;;

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

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

#DEBHELPER#

exit 0