This file is indexed.

postinst is in greylistd 0.8.8.6.

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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/bin/sh
# Post-installation script for greylistd.
# see: dh_installdeb(1)
#
# 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

set -e

. /usr/share/debconf/confmodule                                         
db_version 2.0

owner=greylistd
initscript=/etc/init.d/greylist


running_exim4()
{
    test -x /usr/sbin/exim4 -a -d /etc/exim4
}



copyfile ()
{
    if [ -f "$1" -a '!' -f "$2" ]
    then
	echo -n "Copying $1 to ${2%/*}: "
	cp -f "$1" "$2" && echo " Done."
    fi
}


movefile ()
{
    if [ -f "$1" -a '!' -f "$2" ]
    then
	echo -n "Moving $1 to $2: "
	mv -f "$1" "$2" && echo " Done."
    fi
}


removefile ()
{
    if [ -f "$1" ]
    then
	echo -n "Removing $1:"
	rm -f "$1" && echo " Done."
    fi
}


set_config_value()
{
    file=$1
    option=$2
    value=$3

    text=$(sed "s/\($option[[:space:]]*=[[:space:]]*\).*/\1$value/" "$file") &&
        echo "$text" > "$file"
}


add_user ()
{
    user=$1
    group=$2

    for membership in $(id -Gn "$user" 2>/dev/null)
    do
        [ "$membership" = "$group" ] && return 1
    done

    adduser "$user" "$group"
    return 0
}


do_configure()
{
    oldversion=$1

    username=greylist
    groupname=greylist
    datadir=/var/lib/greylistd
    rundir=/var/run/greylistd
    docdir=/usr/share/doc/greylistd
    confdir=/etc/greylistd

    ### The following keeps "make" silent during adduser/deluser operations
    ### on YP/NIS systems.
    export MAKEFLAGS
    MAKEFLAGS=-s

    ### If the user does not already exist, create it.
    id -u "$username" >/dev/null 2>&1 ||
	adduser --system --group --disabled-password \
	    --home "$datadir" --no-create-home "$username"

    ### If we are using Exim 4, and the Debian-exim user is not in the
    ### group, add it and then restart Exim.
    restart_exim=no
    if running_exim4 && add_user Debian-exim "$groupname"
    then
        db_get "$owner/restartexim"
	$RET && restart_exim=yes

    ### Otherwise, if we are updating from 0.7 or prior versions, we add
    ### the greylist user from the "ugid" DebConf setting
    elif dpkg --compare-versions "$oldversion" le "0.7" && db_get "$owner/ugid"
    then
	uid="${RET%:*}"
	add_user "$uid" "$groupname" || true

    fi

    db_stop || true
    [ "$restart_exim" != 'no' ] && invoke-rc.d exim4 restart

    ### Create working directories
    for dir in "$datadir" "$rundir"
    do
        if [ ! -d "$dir" ]
	then
	    echo -n "Creating directory $dir:"
	    mkdir "$dir" &&
	    echo " Done."
	fi
	chown -R "$username:$groupname" "$dir"
    done

    removefile /etc/default/greylistd
    removefile /etc/default/greylist
    movefile   "$datadir/data" "$datadir/states"
    copyfile   "$docdir/examples/whitelist-hosts" "$confdir/whitelist-hosts"

}


case "$1" in 
    configure|reconfigure)
	do_configure $2
	;;

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

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

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
# Automatically added by dh_installinit
if [ -x "/etc/init.d/greylistd" ]; then
	update-rc.d greylistd defaults >/dev/null
fi
if [ -x "/etc/init.d/greylistd" ] || [ -e "/etc/init/greylistd.conf" ]; then
	invoke-rc.d greylistd start || exit $?
fi
# End automatically added section
# Automatically added by dh_installdeb
dpkg-maintscript-helper rm_conffile /etc/init.d/greylist 0.8.8.5~ -- "$@"
# End automatically added section


exit 0