]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/extras/autogen.sh
Enable slimpac and dynamic OPAC to have localized org trees
[working/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 SYSCONFDIR/opensrf_core.xml";
39         echo "    $0 SYSCONFDIR/opensrf_core.xml";
40         echo "";
41         echo "  Update organization tree and refresh proximity:";
42         echo "    $0 -u -c SYSCONFDIR/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="LOCALSTATEDIR/web/opac/common/js/";
73 FMDOJODIR="LOCALSTATEDIR/web/js/dojo/fieldmapper/";
74 SLIMPACDIR="LOCALSTATEDIR/web/opac/extras/slimpac/";
75
76 echo "Updating fieldmapper";
77 perl fieldmapper.pl "$CONFIG"   > "$JSDIR/fmall.js";
78 cp "$JSDIR/fmall.js" "$FMDOJODIR/"
79
80 echo "Updating web_fieldmapper";
81 perl fieldmapper.pl "$CONFIG" "web_core"        > "$JSDIR/fmcore.js";
82
83 echo "Updating OrgTree";
84 perl org_tree_js.pl "$CONFIG" "$JSDIR" "OrgTree.js";
85 cp "$JSDIR/en-US/OrgTree.js" "$FMDOJODIR/"
86
87 echo "Updating OrgTree HTML";
88 perl org_tree_html_options.pl "$CONFIG" "$SLIMPACDIR" "lib_list.inc";
89
90 echo "Updating locales selection HTML";
91 perl locale_html_options.pl "$CONFIG" "$SLIMPACDIR/locales.inc";
92
93 echo "Updating Search Groups";
94 perl org_lasso_js.pl "$CONFIG" > "$JSDIR/OrgLasso.js";
95 cp "$JSDIR/OrgLasso.js" "$FMDOJODIR/"
96
97 if [ "$PROXIMITY" ]
98 then
99         echo "Refreshing proximity of org units";
100         perl org_tree_proximity.pl "$CONFIG";
101 fi
102
103 echo "";
104 echo "Done";
105
106 )
107