merging admin interface from the dojo-admin branch
[Evergreen.git] / Open-ILS / src / extras / autogen.sh
1 #!/bin/bash
2 # -----------------------------------------------------------------------
3 # Copyright (C) 2005-2008  Georgia Public Library Service
4 # Bill Erickson <billserickson@gmail.com>
5
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.
10
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 # -----------------------------------------------------------------------
16
17 # vim:noet:ts=4
18
19 # ---------------------------------------------------------------------------
20 # Make sure we're running as the correct user
21 # ---------------------------------------------------------------------------
22 [ $(whoami) != 'opensrf' ] && echo 'Must run as user "opensrf"' && exit;
23
24 function usage {
25         echo "";
26         echo "usage: $0 [-u] -c <c_config>";
27         echo "";
28         echo "Mandatory parameters:";
29         echo -e "  -c\t\tfull path to C configuration file (opensrf_core.xml)";
30         echo "";
31         echo "Optional parameters:";
32         echo -e "  -u\t\tupdate proximity of library sites in organization tree";
33         echo -e "    \t\t(this is expensive for a large organization tree)";
34         echo "";
35         echo "Examples:";
36         echo "";
37         echo "  Update organization tree:";
38         echo "    $0 -c /openils/conf/opensrf_core.xml";
39         echo "    $0 /openils/conf/opensrf_core.xml";
40         echo "";
41         echo "  Update organization tree and refresh proximity:";
42         echo "    $0 -u -c /openils/conf/opensrf_core.xml";
43         echo "";
44         exit;
45 }
46
47 (
48
49 BASEDIR=${0%/*}
50 if test "$BASEDIR" = "$0" ; then
51         BASEDIR="$(which $0)"
52         BASEDIR=${BASEDIR%/*}
53 fi
54
55 cd "$BASEDIR"
56
57 CONFIG="$1";
58
59 # ---------------------------------------------------------------------------
60 # Load the command line options and set the global vars
61 # ---------------------------------------------------------------------------
62 while getopts  "c:u h" flag; do
63         case $flag in   
64                 "c")            CONFIG="$OPTARG";;
65                 "u")            PROXIMITY="REFRESH";;
66                 "h")            usage;;
67         esac;
68 done
69
70 [ -z "$CONFIG" ] && usage;
71
72 JSDIR="/openils/var/web/opac/common/js/";
73 FMDOJODIR="/openils/var/web/js/dojo/fieldmapper/";
74 SLIMPACDIR="/openils/var/web/opac/extras/slimpac/";
75
76 echo "Updating fieldmapper";
77 perl fieldmapper.pl "$CONFIG"   > "$JSDIR/fmall.js";
78
79 echo "Updating web_fieldmapper";
80 perl fieldmapper.pl "$CONFIG" "web_core"        > "$JSDIR/fmcore.js";
81
82 echo "Updating OrgTree";
83 perl org_tree_js.pl "$CONFIG" > "$JSDIR/OrgTree.js";
84
85 echo "Updating OrgTree HTML";
86 perl org_tree_html_options.pl "$CONFIG" "$SLIMPACDIR/lib_list.inc";
87 cp "$JSDIR/OrgTree.js" "$FMDOJODIR/"
88
89 echo "Updating Search Groups";
90 perl org_lasso_js.pl "$CONFIG" > "$JSDIR/OrgLasso.js";
91 cp "$JSDIR/OrgLasso.js" "$FMDOJODIR/"
92
93 if [ "$PROXIMITY" ]
94 then
95         echo "Refreshing proximity of org units";
96         perl org_tree_proximity.pl "$CONFIG";
97 fi
98
99 echo "";
100 echo "Done";
101
102 )
103