update scripts: safely exit 0 on exit
[iserv-mod-error-reporter.git] / maint / update-config-from-iserv1.sh
1 #!/bin/bash
2 # called from iservchk if old config exists
3 OLDCFG=/old/opt/iserv/idesk/inc/error-reporter/config.inc.rpmsave
4 NEWCFG=/usr/share/iserv/www/inc/mod_error-reporter/config.inc
5
6 touch $NEWCFG || (echo "FATAL: Could not create $NEWCFG!" && exit 255);
7 chmod u+wr $NEWCFG || (echo "FATAL: Could not chmod +uwr $NEWCFG!" && exit 255);
8 chown www-data $NEWCFG || (echo "FATAL: Could not chown www-data $NEWCFG!" && exit 255);
9
10 # filter unused options
11 cat $OLDCFG|grep -v setAdminGroups|grep -v setLog|grep -v @package > $NEWCFG
12
13 # convert admin groups to group privileges
14 ADMGROUPS=$(grep setAdminGroups $OLDCFG|sed -e 's/,//g' -e "s/.*array[^(]*(\([^)]*\)).*/\1/" -e "s/[\"\']/ /g")
15 for i in $ADMGROUPS; do
16 psql -c "INSERT INTO privileges_assign (act,privilege) VALUES('$i','mod_errorreporter_admin');" > /dev/null || exit 1;
17 echo "added adminship for group '$i'"
18 done;
19
20 mv $OLDCFG $OLDCFG.converted
21 [ -e $OLDCFG ] && echo "Done. Please remove the old config file ($OLDCFG) by hand!" && exit 255;
22
23 exit 0;
24
This page took 0.049268 seconds and 5 git commands to generate.