added php5-cli to Depends
[iserv-mod-error-reporter.git] / maint / update-config.sh
index 43e3820..24d1a7e 100755 (executable)
@@ -1,24 +1,25 @@
 #!/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;
-fi;
+OLDCFG=/usr/share/iserv/www/inc/mod_error-reporter/config.inc
+NEWCFG=/etc/iserv/config
+TMPCFG=`mktemp`
+rm -rf $TMPCFG
 
-touch $NEWCFG || exit 1;
-chmod u+wr $NEWCFG || exit 1;
-chown www-data $NEWCFG || exit 1;
+# 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;
 
-# filter unused options
-cat $OLDCFG|grep -v setAdminGroups|grep -v setLog|grep -v @package > $NEWCFG
+# 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;
 
-# 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;
+mv $OLDCFG $OLDCFG.converted
+[ -e "$OLDCFG" ] && echo "Done. Please remove the old config file ($OLDCFG) by hand!" && exit 255;
 
-rm -f $OLDCFG || (echo "Error: Please remove the old config file by hand!" && exit 1);
This page took 0.023048 seconds and 4 git commands to generate.