#!/bin/sh # # Update_conf # # This function searchs a key entry in a file and updates its value with the new # one. # # Syntax: # # update_conf new_val key conffile # -> new_val ... : Value to set for the key value # -> key ....... : Name of the key to be updated # -> conffile .. : File to search # update_conf () { local new_val local key local conffile new_val=$1 key=$2 conffile=$3 cp $conffile $conffile.old old_val=`awk '$1 == "'$key'" { print $2 }' $conffile` awk '$1 == "'$key'" { gsub("'$old_val'","'$new_val';",$0); \ print $0 } \ $1 != "'$key'" { print $0 }' \ $conffile.old > $conffile rm $conffile.old } if [ "$1" = "upgrade" -o "$1" = "install" ]; then # Revert changes added to the configuration file by the postinst script # if we are upgrading from a version which changed it (#688891) # or if we are installed with a prior version (#675231) if [ -n "$2" ] && dpkg --compare-versions 2.2-3 gt $2 ; then update_conf "_CHANGEME_" "HOSTNAME" "/etc/psad/psad.conf" fi fi if [ "$1" = "upgrade" ]; then # This script is only intended to fix bug #497574. # We check for an upgrade from Psad older than 2.1.5 and remove the old # Psad process if needed. # # NB: As some commands can return an exit code other than 0 we do not use # *set -e* at the beginning. status=1; if [ -x "`which dpkg 2>/dev/null`" ]; then dpkg --compare-versions 2.1.5 gt $2 status=$? fi if [ $status = 0 ]; then echo -n "Removing old Psad process ... " process_list="psadwatchd kmsgsd psad" for process in $process_list; do pkill $process 2>/dev/null done echo "Done." fi fi set -e # Automatically added by dh_installinit/13.11.9 if [ "$1" = "install" ] && [ -n "$2" ] && [ -e "/etc/init.d/psad" ] ; then chmod +x "/etc/init.d/psad" >/dev/null || true fi # End automatically added section exit 0