postinst is in pcp 3.10.8build1.
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 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | #!/bin/sh -e
#
# The goal here is to live-migrate PCP temporary files from places
# they may have been stashed away in previous versions. This is
# important as they may be in-use by instrumented applications and
# we want to avoid loss of service as a result of the switch.
#
# The new place ... this should match the setting in /etc/pcp.conf
# _after_ the installation
#
PCP_TMP_DIR=/var/lib/pcp/tmp
# Function to do all of the temporary dir/file migration work
#
_clean_tmpdirs()
{
#
# Usage: _clean_tmpdirs [-v] new_dir old_dir ...
#
# Move temporary directories (which may be actively in use as
# with pmdammv files) from one temporary directory to another
# so as to transparently upgrade without loss of service.
#
# -v option is verbose mode for debugging
#
_verbose=false
if [ $# -gt 0 -a X"$1" = "X-v" ]
then
_verbose=true
shift
fi
if [ $# -lt 2 ]
then
echo >&2 "Usage: _clean_tmpdirs [-v] new_dir old_dir subdirs ..."
return
fi
_new_tmp_dir="$1"
_old_tmp_dir="$2"
[ "$_new_tmp_dir" != "$old_tmp_dir" ] || return
for _subdir
do
d="$_old_tmp_dir/$_subdir"
test -d "$d" -a -k "$d" || continue
cd "$d" || continue
for f in * ; do
[ "$f" != "*" ] || continue
source="$d/$f"
target="$_new_tmp_dir/$_subdir/$f"
[ "$source" != "$target" ] || continue
[ ! -f "$target" ] || continue
$_verbose && echo + mv -fu "$source" "$target"
mv -fu "$source" "$target" || true
done
$_verbose && echo + rmdir "$d"
cd && rmdir "$d" 2>/dev/null || true
done
}
_version_configs()
{
# Use the supported conffile move method (no prompts)
local FILE
local NPMCD=/etc/pcp/pmcd
local PMCD1=/etc/pmcd
local PMCD2=/var/lib/pcp/config/pmcd
for FILE in pmcd.conf pmcd.options rc.local; do
dpkg-maintscript-helper mv_conffile $PMCD2/$FILE $NPMCD/$FILE 3.7.0~ pcp -- "$@"
dpkg-maintscript-helper mv_conffile $PMCD1/$FILE $NPMCD/$FILE 3.6.1~ pcp -- "$@"
done
local NPMIE=/etc/pcp/pmie
local PMIE1=/etc/pmie
local PMIE2=/var/lib/pcp/config/pmie
for FILE in control; do
dpkg-maintscript-helper mv_conffile $PMIE2/$FILE $NPMIE/$FILE 3.7.0~ pcp -- "$@"
dpkg-maintscript-helper mv_conffile $PMIE1/$FILE $NPMIE/$FILE 3.6.1~ pcp -- "$@"
done
local NPMPROXY=/etc/pcp/pmproxy
local PMPROXY1=/etc/pmproxy
local PMPROXY2=/var/lib/pcp/config/pmproxy
for FILE in pmproxy.options; do
dpkg-maintscript-helper mv_conffile $PMPROXY2/$FILE $NPMPROXY/$FILE 3.7.0~ pcp -- "$@"
dpkg-maintscript-helper mv_conffile $PMPROXY1/$FILE $NPMPROXY/$FILE 3.6.1~ pcp -- "$@"
done
local NPMLOGGER=/etc/pcp/pmlogger
local PMLOGGER1=/etc/pmlogger
local PMLOGGER2=/var/lib/pcp/config/pmlogger
for FILE in control; do
dpkg-maintscript-helper mv_conffile $PMLOGGER2/control $NPMLOGGER/control 3.7.0~ pcp -- "$@"
dpkg-maintscript-helper mv_conffile $PMLOGGER1/control $NPMLOGGER/control 3.6.1~ pcp -- "$@"
done
}
if dpkg-maintscript-helper supports mv_conffile
then
_version_configs "$@"
fi
touch /var/lib/pcp/pmns/.NeedRebuild
chmod 644 /var/lib/pcp/pmns/.NeedRebuild
getent group pcp >/dev/null || groupadd -r pcp
getent passwd pcp >/dev/null || \
useradd -c "Performance Co-Pilot" -g pcp -d /var/lib/pcp -M -r -s /usr/sbin/nologin pcp
# must match GNUmakefile
chown pcp:pcp /var/lib/pcp/config/pmda
chmod 775 /var/lib/pcp/config/pmda
chown pcp:pcp /var/lib/pcp/tmp
chmod 775 /var/lib/pcp/tmp
chown pcp:pcp /var/log/pcp
chmod 775 /var/log/pcp
# must match src/pmcd/GNUmakefile
chown pcp:pcp /var/log/pcp/pmcd
chmod 775 /var/log/pcp/pmcd
# must match src/pmie/GNUmakefile
chown pcp:pcp /var/lib/pcp/config/pmie
chmod 775 /var/lib/pcp/config/pmie
chown pcp:pcp /var/lib/pcp/tmp/pmie
chmod 775 /var/lib/pcp/tmp/pmie
chown pcp:pcp /var/log/pcp/pmie
chmod 775 /var/log/pcp/pmie
# must match src/pmlogger/GNUmakefile
chown pcp:pcp /var/lib/pcp/config/pmlogger
chmod 775 /var/lib/pcp/config/pmlogger
chown pcp:pcp /var/lib/pcp/tmp/pmlogger
chmod 775 /var/lib/pcp/tmp/pmlogger
chown pcp:pcp /var/log/pcp/pmlogger
chmod 775 /var/log/pcp/pmlogger
# must match src/pmproxy/GNUmakefile
chown pcp:pcp /var/log/pcp/pmproxy
chmod 775 /var/log/pcp/pmproxy
# and fixup the change in deployment plan for these ones in the case
# of an upgrade, rather than an install ... they used to be pcp:pcp
chown root:root /etc/pcp/pmie
chmod 755 /etc/pcp/pmie
chown root:root /etc/pcp/pmie/control
chmod 644 /etc/pcp/pmie/control
chown root:root /etc/pcp/pmlogger
chmod 755 /etc/pcp/pmlogger
chown root:root /etc/pcp/pmlogger/control
chmod 644 /etc/pcp/pmlogger/control
# migrate generated config files from /etc/pcp/* to /var/lib/pcp/config/*
#
if [ -f /etc/pcp/pmie/config.default ]
then
cp /etc/pcp/pmie/config.default /var/lib/pcp/config/pmie/config.default
rm -f /etc/pcp/pmie/config.default
chown pcp:pcp /var/lib/pcp/config/pmie/config.default
chmod 644 /var/lib/pcp/config/pmie/config.default
fi
if [ -f /etc/pcp/pmlogger/config.default ]
then
cp /etc/pcp/pmlogger/config.default /var/lib/pcp/config/pmlogger/config.default
rm -f /etc/pcp/pmlogger/config.default
chown pcp:pcp /var/lib/pcp/config/pmlogger/config.default
chmod 644 /var/lib/pcp/config/pmlogger/config.default
fi
update-rc.d pmcd defaults >/dev/null
update-rc.d pmlogger defaults >/dev/null
update-rc.d pmie defaults >/dev/null
update-rc.d pmproxy defaults >/dev/null
# migrate existing statistics files to their new (permanent!) home
#
for dir in /var/tmp/mmv /var/tmp/pmdabash
do
[ -d $dir ] || continue
[ "$(LC_ALL=C stat -c '%u %g %F' $dir)" = "0 0 directory" ] && mv $dir /var/lib/pcp/tmp
done
_clean_tmpdirs $PCP_TMP_DIR /var/tmp pmie pmlogger
# transition pmdadmcache over to pmdadm (device mapper)
#
PCP_PMCDCONF_PATH=/etc/pcp/pmcd/pmcd.conf
PCP_PMDAS_DIR=/var/lib/pcp/pmdas/
if grep -q ^dmcache $PCP_PMCDCONF_PATH 2>/dev/null
then
mkdir -p -m 755 "$PCP_PMDAS_DIR/dm"
touch "$PCP_PMDAS_DIR/dm/.NeedInstall"
touch "$PCP_PMDAS_DIR/dmcache/.NeedRemove"
fi
if which invoke-rc.d >/dev/null 2>&1; then
invoke-rc.d pmcd start
invoke-rc.d pmlogger start
else
/etc/init.d/pmcd start
/etc/init.d/pmlogger start
fi
|