From 880a10b0ab493898916195bc82ca2cde10201334 Mon Sep 17 00:00:00 2001 From: Dragan Dosen Date: Thu, 19 Feb 2009 22:51:46 +0100 Subject: [PATCH] Backup konfiguracijskih datoteka u /var/backups/xinetd-cn/. Koristenje -r (--regexp-extended) za sed, manje izmjene u regularnim izrazima za egrep i sed. --- debian/changelog | 2 ++ debian/postinst | 31 ++++++++++++++++++------------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/debian/changelog b/debian/changelog index 47d1adc..a799cef 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,8 @@ xinetd-cn (1:2.3.14-2) stable; urgency=low migracija na odvojenu xinetd konfiguraciju nije uspjesna, + deaktivacija novog 'INETD_COMPAT=Yes' zapisa unutar datoteke /etc/default/xinetd - isti se postavlja u 'INETD_COMPAT=No', + + backup konfiguracijskih datoteka od sada se nalazi unutar + direktorija /var/backups/xinetd-cn/, + dodatne manje izmjene. * Datoteka debian/control: + ovisnost o xinetd (>= 1:2.3.14-7~cn1). diff --git a/debian/postinst b/debian/postinst index 20e4b9d..b7878b6 100644 --- a/debian/postinst +++ b/debian/postinst @@ -12,9 +12,11 @@ PKG=xinetd-cn CONF=/etc/xinetd.conf INETDCONF=/etc/inetd.conf DEFAULT=/etc/default/xinetd +BACKUPDIR=/var/backups/xinetd-cn need_restart=0 temp_files= +xinetd_conf_did=0 # cleanup() # @@ -39,11 +41,11 @@ trap cleanup 0 1 2 15 # First, we do backup (inetd, xinetd) # -if cp_check_and_backup "$INETDCONF"; then - cp_echo "CN: Old $INETDCONF saved as /var/backups/`basename $INETDCONF`.bak." +if cp_backup_conffile -r -d $BACKUPDIR -p $INETDCONF; then + cp_echo "CN: Old $INETDCONF saved as $BACKUPDIR/`basename $INETDCONF`.bak." fi -if cp_check_and_backup "$CONF"; then - cp_echo "CN: Old $CONF saved as /var/backups/`basename $CONF`.bak." +if cp_backup_conffile -r -d $BACKUPDIR -p $CONF; then + cp_echo "CN: Old $CONF saved as $BACKUPDIR/`basename $CONF`.bak." fi CONFTMP=`mktemp $CONF.tmp.XXXXXX` @@ -60,9 +62,12 @@ fi # conffile_list="$CONFTMP" if [ -f "$CONF" ]; then - conffile_list="$CONF $conffile_list" + if egrep -q "^service[[:space:]]+" "$CONF"; then + conffile_list="$CONF $conffile_list" + xinetd_conf_did=1 + fi fi -services_list="`cat $conffile_list | grep "^service " | uniq | sed 's/service //g'`" || true +services_list="`cat $conffile_list | egrep "^service[[:space:]]+" | sed -r 's/service[[:space:]]+//g' | uniq`" || true if [ -n "$services_list" ]; then @@ -70,8 +75,8 @@ if [ -n "$services_list" ]; then if [ -f "/etc/xinetd.d/$service" ]; then - if cp_check_and_backup "/etc/xinetd.d/$service"; then - cp_echo "CN: Old /etc/xinetd.d/$service saved as /var/backups/`basename /etc/xinetd.d/$service`.bak." + if cp_backup_conffile -r -d $BACKUPDIR -p /etc/xinetd.d/$service; then + cp_echo "CN: Old /etc/xinetd.d/$service saved as $BACKUPDIR/`basename /etc/xinetd.d/$service`.bak." fi rm -f /etc/xinetd.d/$service @@ -79,17 +84,17 @@ if [ -n "$services_list" ]; then touch /etc/xinetd.d/$service || true # cat "$CONF" "$CONFTMP" | sed -n "/^service $service/,/^}/p" | cp-update "$PKG" "/etc/xinetd.d/$service" - cat "$CONF" "$CONFTMP" | sed -n "/^service $service/,/^}/p" >> "/etc/xinetd.d/$service" + cat $conffile_list | sed -rn "/^service[[:space:]]+$service/,/^}/p" >> "/etc/xinetd.d/$service" need_restart=1 done - if egrep -q "service " "$CONFTMP"; then + if egrep -q "^service[[:space:]]+" "$CONFTMP"; then cp_echo "CN: All services were converted from $INETDCONF file to separated" cp_echo "CN: configuration files located in /etc/xinetd.d/ directory." fi - if [ -f "$CONF" ]; then + if [ $xinetd_conf_did -eq 1 ]; then cp_echo "CN: All services were converted from $CONF file to separated" cp_echo "CN: configuration files located in /etc/xinetd.d/ directory." fi @@ -105,8 +110,8 @@ fi # Remove services from /etc/xinetd.conf file # -cp_check_and_sed "^service " \ - "/^service/,/^}/d" \ +cp_check_and_sed "^service[[:space:]]+" \ + "/^service[[:space:]]/,/^}/d" \ "$CONF" && need_restart=1 || true # Check if there is no defaults block in /etc/xinetd.conf -- 1.7.10.4