postinst is in varnish 3.0.5-2.
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 | #!/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}
}
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
fi
;;
esac
# Automatically added by dh_systemd_enable
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask varnishlog.service >/dev/null || true
# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --quiet was-enabled varnishlog.service; then
# Enables the unit on first installation, creates new
# symlinks on upgrades if the unit file has changed.
deb-systemd-helper enable varnishlog.service >/dev/null || true
else
# Update the statefile to add new symlinks (if any), which need to be
# cleaned up on purge. Also remove old symlinks.
deb-systemd-helper update-state varnishlog.service >/dev/null || true
fi
# End automatically added section
# Automatically added by dh_systemd_enable
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask varnishncsa.service >/dev/null || true
# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --quiet was-enabled varnishncsa.service; then
# Enables the unit on first installation, creates new
# symlinks on upgrades if the unit file has changed.
deb-systemd-helper enable varnishncsa.service >/dev/null || true
else
# Update the statefile to add new symlinks (if any), which need to be
# cleaned up on purge. Also remove old symlinks.
deb-systemd-helper update-state varnishncsa.service >/dev/null || true
fi
# End automatically added section
# Automatically added by dh_systemd_enable
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask varnish.service >/dev/null || true
# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --quiet was-enabled varnish.service; then
# Enables the unit on first installation, creates new
# symlinks on upgrades if the unit file has changed.
deb-systemd-helper enable varnish.service >/dev/null || true
else
# Update the statefile to add new symlinks (if any), which need to be
# cleaned up on purge. Also remove old symlinks.
deb-systemd-helper update-state varnish.service >/dev/null || true
fi
# End automatically added section
# Automatically added by dh_installinit
if [ -x "/etc/init.d/varnish" ] || [ -e "/etc/init/varnish.conf" ]; 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" ] || [ -e "/etc/init/varnishlog.conf" ]; 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" ] || [ -e "/etc/init/varnishncsa.conf" ]; 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
|