From 53f4eedd6e44bd954a22723f70b8c8d453d03847 Mon Sep 17 00:00:00 2001 From: Roland Hieber Date: Sun, 7 Mar 2010 05:26:39 +0100 Subject: [PATCH] iservchk: Test does not allow output, better use Shell; more exit codes in update scripts --- iservchk/20base | 17 ++++++++++------- maint/update-config-from-iserv1.sh | 9 +++++---- maint/update-config.sh | 7 +++++-- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/iservchk/20base b/iservchk/20base index cfe9937..1f59f88 100644 --- a/iservchk/20base +++ b/iservchk/20base @@ -1,8 +1,11 @@ -Test 'import configuration from IServ 1' - '[ ! -f /old/opt/iserv/idesk/inc/error-reporter/config.inc.rpmsave ]' - /usr/share/iserv/modules/error-reporter/update-config-from-iserv1.sh -Test 'update old config' - '[ ! -f /usr/share/iserv/www/inc/mod_error-reporter/config.inc ]' - /usr/share/iserv/modules/error-reporter/update-config -Shell 'update database' /usr/share/iserv/modules/error-reporter/update-database +Shell 'import configuration from IServ 1' + if [ -f /old/opt/iserv/idesk/inc/error-reporter/config.inc.rpmsave ]; then + /usr/share/iserv/modules/error-reporter/update-config-from-iserv1.sh + fi; +Shell 'update old config' + if [ -f /usr/share/iserv/www/inc/mod_error-reporter/config.inc ]; then + /usr/share/iserv/modules/error-reporter/update-config.sh + fi; +Shell 'update database' + /usr/share/iserv/modules/error-reporter/update-database.php diff --git a/maint/update-config-from-iserv1.sh b/maint/update-config-from-iserv1.sh index 7779e76..467e17a 100755 --- a/maint/update-config-from-iserv1.sh +++ b/maint/update-config-from-iserv1.sh @@ -3,9 +3,9 @@ OLDCFG=/old/opt/iserv/idesk/inc/error-reporter/config.inc.rpmsave NEWCFG=/usr/share/iserv/www/inc/mod_error-reporter/config.inc -touch $NEWCFG || exit 1; -chmod u+wr $NEWCFG || exit 1; -chown www-data $NEWCFG || exit 1; +touch $NEWCFG || (echo "FATAL: Could not create $NEWCFG!" && exit 255); +chmod u+wr $NEWCFG || (echo "FATAL: Could not chmod +uwr $NEWCFG!" && exit 255); +chown www-data $NEWCFG || (echo "FATAL: Could not chown www-data $NEWCFG!" && exit 255); # filter unused options cat $OLDCFG|grep -v setAdminGroups|grep -v setLog|grep -v @package > $NEWCFG @@ -17,4 +17,5 @@ for i in $ADMGROUPS; do echo "added adminship for group '$i'" done; -rm -f $OLDCFG || (echo "Error: Please remove the old config file by hand!" && exit 1); +mv $OLDCFG $OLDCFG.converted +[ -e $OLDCFG ] && echo "Done. Please remove the old config file ($OLDCFG) by hand!" && exit 255; diff --git a/maint/update-config.sh b/maint/update-config.sh index 3cc0677..24d1a7e 100755 --- a/maint/update-config.sh +++ b/maint/update-config.sh @@ -10,13 +10,16 @@ rm -rf $TMPCFG # mail notify if [ -n "`grep 'setMailNotify(' $OLDCFG|grep false`" ]; then sed 's/^ErrorReporterMailNotify.\+/ErrorReporterMailNotify = false/' $NEWCFG > $TMPCFG - mv $TMPCFG $NEWCFG + mv $TMPCFG $NEWCFG || (echo "Could not save config!" && exit 255); fi; # mail notify address mailNotifyAddress=`grep setMailNotifyAddr $OLDCFG | sed -e 's/\$cfgErrors->setMailNotifyAddr//' | tr -d '();'|tr "'();" '"'` if [ -n "$mailNotifyAddress" ]; then sed "s/^ErrorReporterMailAddress.\+/ErrorReporterMailAddress = $mailNotifyAddress/" $NEWCFG > $TMPCFG - mv $TMPCFG $NEWCFG + mv $TMPCFG $NEWCFG || (echo "Could not save config!" && exit 255); fi; +mv $OLDCFG $OLDCFG.converted +[ -e "$OLDCFG" ] && echo "Done. Please remove the old config file ($OLDCFG) by hand!" && exit 255; + -- 2.20.1