2 # -----------------------------------------------------------------------
3 # Copyright (C) 2005-2008 Georgia Public Library Service
4 # Bill Erickson <billserickson@gmail.com>
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 # -----------------------------------------------------------------------
19 # Exit script if any statement returns a non-true return value
21 # Throw an error for uninitialized variables
24 # ---------------------------------------------------------------------------
25 # Make sure we're running as the correct user
26 # ---------------------------------------------------------------------------
27 [ $(whoami) != 'opensrf' ] && echo 'Must run as user "opensrf"' && exit;
31 echo "usage: $0 [-u] [-c <c_config>]";
33 echo "Updates the Evergreen organization tree and fieldmapper IDL.";
34 echo "Run this every time you change the Evergreen organization tree";
35 echo "or update fm_IDL.xml";
37 echo "Optional parameters:";
38 echo -e " -c\t\tfull path to C configuration file (opensrf_core.xml)";
39 echo -e " \t\t - defaults to SYSCONFDIR/opensrf_core.xml";
40 echo -e " -u\t\tupdate proximity of library sites in organization tree";
41 echo -e " \t\t(this is expensive for a large organization tree)";
45 echo " Update organization tree and fieldmapper IDL:";
46 echo " $0 -c SYSCONFDIR/opensrf_core.xml";
48 echo " Update organization tree and refresh proximity:";
49 echo " $0 -u -c SYSCONFDIR/opensrf_core.xml";
57 # Initialize our variables
61 # ---------------------------------------------------------------------------
62 # Load the command line options and set the global vars
63 # ---------------------------------------------------------------------------
64 while getopts "c:u h" flag; do
66 "c") CONFIG="$OPTARG";;
67 "u") PROXIMITY="REFRESH";;
73 if [ -z "$CONFIG" ] && [[ ! -z "${1:-}" ]]; then
74 # Support "autogen.sh /path/to/opensrf_core.xml" for legacy invocation
77 if [ -z "$CONFIG" ]; then
78 # Fall back to the configured default
79 CONFIG="SYSCONFDIR/opensrf_core.xml";
81 if [ ! -f "$CONFIG" ]; then
82 echo "ERROR: could not find configuration file '$CONFIG'";
88 JSDIR="LOCALSTATEDIR/web/opac/common/js/";
89 FMDOJODIR="LOCALSTATEDIR/web/js/dojo/fieldmapper/";
90 SLIMPACDIR="LOCALSTATEDIR/web/opac/extras/slimpac/";
92 echo "Updating Evergreen organization tree and IDL using '$CONFIG'"
95 echo "Updating fieldmapper";
96 perl fieldmapper.pl "$CONFIG" > "$JSDIR/fmall.js";
97 cp "$JSDIR/fmall.js" "$FMDOJODIR/"
99 echo "Updating web_fieldmapper";
100 perl fieldmapper.pl "$CONFIG" "web_core" > "$JSDIR/fmcore.js";
102 echo "Updating OrgTree";
103 perl org_tree_js.pl "$CONFIG" "$JSDIR" "OrgTree.js";
104 cp "$JSDIR/en-US/OrgTree.js" "$FMDOJODIR/"
106 echo "Updating OrgTree HTML";
107 perl org_tree_html_options.pl "$CONFIG" "$SLIMPACDIR" "lib_list.inc";
109 echo "Updating locales selection HTML";
110 perl locale_html_options.pl "$CONFIG" "$SLIMPACDIR/locales.inc";
112 echo "Updating Search Groups";
113 perl org_lasso_js.pl "$CONFIG" > "$JSDIR/OrgLasso.js";
114 cp "$JSDIR/OrgLasso.js" "$FMDOJODIR/"
116 if [ ! -z "$PROXIMITY" ]
118 echo "Refreshing proximity of org units";
119 perl org_tree_proximity.pl "$CONFIG";