This file is indexed.

postinst is in varnish 3.0.2-1.

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
#!/bin/sh

# Postinst script for varnish.
# Stig Sandbeck Mathisen <ssm@debian.org>

set -e
set -u

# Settings
daemon_user="varnish"
log_user="varnishlog"
daemon_dir=/var/lib/varnish/$(uname -n)
log_dir="/var/log/varnish"
secret_file=/etc/varnish/secret

varnish_setup_user() {
    if ! getent passwd $1 2>&1 >/dev/null; then
        adduser --quiet --system --no-create-home --group $1
    fi
}

varnish_create_storagedir() {
    if ! [ -d "$daemon_dir" ]; then
        install -o $daemon_user -g $daemon_user -d $daemon_dir
    fi
}

varnish_setup_logdir() {
    if ! dpkg-statoverride --list $log_dir >/dev/null; then
        dpkg-statoverride --update --add $log_user $log_user 0750 $log_dir
    fi
}

varnish_create_secret() {
    if ! [ -f "${secret_file}" ]; then
        if [ -f /proc/sys/kernel/random/uuid ]; then
            install -m 0600 /proc/sys/kernel/random/uuid "${secret_file}"
        else
            install -m 0600 /dev/null "${secret_file}"
            dd if=/dev/urandom count=1 bs=128 2>/dev/null \
                | tr -dc "A-Za-z0-9" > "${secret_file}"
        fi
    fi
}

# varnish version 2.1.3-1 and older ran the log demons as root, we
# need to change the owner of the old logs for upgrading clients
upgrade_change_log_permissions() {
    chown -Rhf ${log_user}: ${log_dir}
}

# varnish version 2.1.3-1 and older started varnishd at boot, we keep
# this default for upgrading clients
upgrade_enable_varnishd() {
    sed -i '/^START=/s/no/yes/g' /etc/default/varnish
}

case ${1:-} in
    configure)

        varnish_setup_user $daemon_user
        varnish_setup_user $log_user
        
        varnish_create_storagedir
        varnish_setup_logdir

        varnish_create_secret

        if dpkg --compare-versions "2.1.3-2" "gt-nl" "${2:-}" ; then
            upgrade_change_log_permissions
            upgrade_enable_varnishd
        fi
        ;;
esac

# Automatically added by dh_installinit
if [ -x "/etc/init.d/varnish" ]; then
	if [ ! -e "/etc/init/varnish.conf" ]; then
		update-rc.d varnish defaults >/dev/null
	fi
	invoke-rc.d varnish start || exit $?
fi
# End automatically added section
# Automatically added by dh_installinit
if [ -x "/etc/init.d/varnishlog" ]; then
	if [ ! -e "/etc/init/varnishlog.conf" ]; then
		update-rc.d varnishlog defaults >/dev/null
	fi
	invoke-rc.d varnishlog start || exit $?
fi
# End automatically added section
# Automatically added by dh_installinit
if [ -x "/etc/init.d/varnishncsa" ]; then
	if [ ! -e "/etc/init/varnishncsa.conf" ]; then
		update-rc.d varnishncsa defaults >/dev/null
	fi
	invoke-rc.d varnishncsa start || exit $?
fi
# End automatically added section