bug 6031: play with options passed on to rebuild-zebra.pl
authorSrdjan Jankovic <srdjan@catalyst.net.nz>
Thu, 31 Mar 2011 22:31:31 +0000 (11:31 +1300)
committerChris Nighswonger <chris.nighswonger@gmail.com>
Sat, 16 Apr 2011 18:56:10 +0000 (14:56 -0400)
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
(cherry picked from commit 78829117999e8d8884a56454a37eb514baf2f3ea)

Signed-off-by: Chris Nighswonger <chris.nighswonger@gmail.com>
debian/scripts/koha-rebuild-zebra

index 3ae693b..b8201e8 100755 (executable)
 
 set -e
 
+opt_idx="-z"
+opt_xml="-x"
+opts_other=""
+
+while [ -n "$*" ]; do
+    case "$1" in
+        -u|--usmarc)
+             opt_xml=""
+             ;;
+        -f|--full)
+             opt_idx="-r"
+             ;;
+        -*)
+            opts_other="$opts_other $1";
+            ;;
+        *)
+            break
+            ;;
+    esac
 
-if [ "$1" = --full ]
-then
-    opts="-r"
     shift
-else
-    opts="-z"
-fi
+done
 
 
-for name in "$@"
-do
+
+function run_zebra () {
+    name=$1; shift
+
     sudo -u "$name-koha" -H \
     env PERL5LIB=/usr/share/koha/lib \
         KOHA_CONF="/etc/koha/sites/$name/koha-conf.xml" \
-        /usr/share/koha/bin/migration_tools/rebuild_zebra.pl -b -a $opts
+        /usr/share/koha/bin/migration_tools/rebuild_zebra.pl $@
+}
+
+for name in "$@"
+do
+    run_zebra $name -b $opt_idx $opt_xml $opts_other
+    run_zebra $name -a $opt_idx $opts_other
 done