#!/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);