#!/bin/sh -e # # The goal here is to collect PCP configuration files from places # they may have been stashed away in previous versions # PCP_ETC_DIR=/etc for crontab in pmlogger pmie do test -f "$PCP_ETC_DIR/cron.d/$crontab" || continue mv -f "$PCP_ETC_DIR/cron.d/$crontab" "$PCP_ETC_DIR/cron.d/pcp-$crontab" done # Function to do all of the configuration file migration work # _clean_configs() { # # Usage: _clean_configs [-n|-v] new_dir old_dir ... # # Across all the files in the new_dir and old_dir args, match # names and pick the most recently modified version and leave # this (same mode and modification date) in new_dir # # -n option is show-me for benign debugging # -v option is verbose mode for active debugging # if [ $# -gt 0 -a X"$1" = "X-n" ] then MKDIR="echo + mkdir " CP="echo + cp " shift else MKDIR=mkdir CP=cp fi _verbose=false if [ $# -gt 0 -a X"$1" = "X-v" ] then _verbose=true shift fi if [ $# -lt 2 ] then echo >&2 "Usage: _clean_configs [-n|-v] new_dir old_dir ..." return fi _new="$1" if [ ! -d "$_new" ] then $verbose && echo >&2 + mkdir -p "$_new" $MKDIR -p "$_new" fi shift for _dir do [ "$_dir" = "$_new" ] && continue if [ -d "$_dir" ] then ( cd "$_dir" ; find . -type f -print ) \ | sed -e 's/^\.\///' \ | while read _file do _want=false if [ -f "$_new/$_file" ] then # file exists in both directories, pick the more # recently modified one # _try=`find "$_dir/$_file" -newer "$_new/$_file" -print` [ -n "$_try" ] && _want=true else _want=true fi if $_want then _dest=`dirname $_new/$_file` if [ ! -d "$_dest" ] then $verbose && >&2 echo + mkdir "$_dest" $MKDIR "$_dest" fi $_verbose && echo >&2 + cp -p "$_dir/$_file" "$_new/$_file" $CP -p "$_dir/$_file" "$_new/$_file" fi done fi 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 } # remove any retired conffiles # if dpkg-maintscript-helper supports rm_conffile then for conf in \ /etc/bash_completion.d/pcp \ /etc/cron.d/pcp-pmie \ /etc/cron.d/pcp-pmlogger \ /etc/cron.d/pcp-pmlogger-daily-report \ /etc/pcp.sh \ /etc/pcp/htop/columns/container \ /etc/pcp/htop/columns/delayacct \ /etc/pcp/htop/columns/fdcount \ /etc/pcp/htop/columns/guest \ /etc/pcp/htop/columns/memory \ /etc/pcp/htop/columns/sched \ /etc/pcp/htop/columns/swap \ /etc/pcp/htop/columns/tcp \ /etc/pcp/htop/columns/udp \ /etc/pcp/htop/columns/wchan \ /etc/pcp/htop/meters/entropy \ /etc/pcp/htop/meters/freespace \ /etc/pcp/htop/meters/ipc \ /etc/pcp/htop/meters/locks \ /etc/pcp/htop/meters/memcache \ /etc/pcp/htop/meters/mysql \ /etc/pcp/htop/meters/postfix \ /etc/pcp/htop/meters/redis \ /etc/pcp/htop/meters/tcp \ /etc/pcp/openmetrics/config.d/collectd.url \ /etc/pcp/openmetrics/config.d/etcd.url \ /etc/pcp/openmetrics/config.d/grafana.url \ /etc/pcp/pmlogconf/kernel/interrupts-irix \ /etc/pcp/pmlogconf/kernel/memory-irix \ /etc/pcp/pmlogconf/kernel/queues-irix \ /etc/pcp/pmlogconf/kernel/syscalls-irix \ /etc/pcp/pmlogconf/kernel/syscalls-percpu-irix \ /etc/pcp/pmlogconf/memory/tlb-irix \ /etc/pcp/pmlogconf/networking/socket-irix \ /etc/pcp/pmlogconf/networking/tcp-activity-irix \ /etc/pcp/pmlogconf/networking/udp-packets-irix \ /etc/pcp/pmlogconf/sgi/cpu-evctr \ /etc/pcp/pmlogconf/sgi/craylink \ /etc/pcp/pmlogconf/sgi/efs \ /etc/pcp/pmlogconf/sgi/hub \ /etc/pcp/pmlogconf/sgi/kaio \ /etc/pcp/pmlogconf/sgi/node-memory \ /etc/pcp/pmlogconf/sgi/numa \ /etc/pcp/pmlogconf/sgi/numa-summary \ /etc/pcp/pmlogconf/sgi/xbow \ /etc/pcp/pmlogconf/sgi/xlv-activity \ /etc/pcp/pmlogconf/sgi/xlv-stripe-io \ /etc/pcp/pmlogconf/sgi/xvm-all \ /etc/pcp/pmlogconf/sgi/xvm-ops \ /etc/pcp/pmlogconf/sgi/xvm-stats \ /etc/pcp/pmlogconf/v1.0/C2 \ /etc/pcp/pmlogconf/v1.0/C3 \ /etc/pcp/pmlogconf/v1.0/D3 \ /etc/pcp/pmlogconf/v1.0/K0 \ /etc/pcp/pmlogconf/v1.0/S0 \ /etc/pcp/pmlogconf/v1.0/S1 \ /etc/pcp/pmproxy/pmproxy.defaults \ /etc/pcp/pmrep/iostat_v12_3.conf \ /etc/pcp/pmrep/pmrep.conf \ /etc/pcp/pmrep/sar-old-kernel.conf \ # end do # these ones are from botched packaging over a long time, so # there is no "prior-version" release that is going to work ... # dpkg-maintscript-helper rm_conffile $conf -- "$@" done # newer ones where the change can be tagged to a release go here # where is the first release when was no longer # packaged, e.g. "3.4.4-1~" if we stopped packaging # in PCP 3.4.4 # # dpkg-maintscript-helper rm_conffile -- "$@" fi # migrate and clean configs if dpkg-maintscript-helper supports mv_conffile then _version_configs "$@" else # Fallback to our homebrew method (might prompt user) #echo >>$PCP_LOG_DIR/install.log #date >>$PCP_LOG_DIR/install.log for base in pmcd pmie pmlogger pmproxy do _clean_configs -v $PCP_SYSCONF_DIR/$base \ /var/lib/pcp/config/$base \ /etc/$base /etc/pcp/$base \ /etc/sysconfig/$base \ # 2>>$PCP_LOG_DIR/install.log done fi