X-Git-Url: https://git.rohieb.name/iserv-mod-error-reporter.git/blobdiff_plain/ae87133905d183987eb75369fe94bb739a2b1cb9..e9f2b961b77ab316f83a603e6e3fed7f402217cd:/maint/update-config.sh?ds=inline diff --git a/maint/update-config.sh b/maint/update-config.sh index 43e3820..651a387 100755 --- a/maint/update-config.sh +++ b/maint/update-config.sh @@ -1,24 +1,28 @@ #!/bin/bash -OLDCFG=/old/opt/iserv/idesk/inc/error-reporter/config.inc.rpmsave -NEWCFG=/usr/share/iserv/www/inc/mod_error-reporter/config.inc +# called by iservchk +# convert the old, PHP based config file to /etc/iserv/config -if [ ! -e "$OLDCFG" ]; then - echo "$OLDCFG does not exist." - exit 1; +OLDCFG=/usr/share/iserv/www/inc/mod_error-reporter/config.inc +NEWCFG=/etc/iserv/config +TMPCFG=`mktemp` +rm -rf $TMPCFG + +# mail notify +if [ -n "`grep 'setMailNotify(' $OLDCFG|grep false`" ]; then + sed 's/^ErrorReporterMailNotify.\+/ErrorReporterMailNotify = false/' $NEWCFG > $TMPCFG + mv $TMPCFG $NEWCFG || (echo "Could not save config!" && exit 255); fi; -touch $NEWCFG || exit 1; -chmod u+wr $NEWCFG || exit 1; -chown www-data $NEWCFG || exit 1; +# 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 || (echo "Could not save config!" && exit 255); +fi; -# filter unused options -cat $OLDCFG|grep -v setAdminGroups|grep -v setLog|grep -v @package > $NEWCFG +mv $OLDCFG $OLDCFG.converted +[ -e "$OLDCFG" ] && echo "Done. Please remove the old config file ($OLDCFG) by hand!" && exit 255; -# convert admin groups to group privileges -ADMGROUPS=$(grep setAdminGroups $OLDCFG|sed -e 's/,//g' -e "s/.*array[^(]*(\([^)]*\)).*/\1/" -e "s/[\"\']//g") -for i in $ADMGROUPS; do - psql -c "INSERT INTO privileges_assign (act,privilege) VALUES('$i','mod_errorreporter_admin');" > /dev/null || exit 1; - echo "added adminship for group '$i'" -done; +# write new config +iservchk config -rm -f $OLDCFG || (echo "Error: Please remove the old config file by hand!" && exit 1);