]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/extras/autogen.sh
Trivial - ensure "Done" gets placed on its own line.
[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 /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 SLIMPACDIR="/openils/var/web/opac/extras/slimpac/";
74
75 echo "Updating fieldmapper";
76 perl fieldmapper.pl "$CONFIG"   > "$JSDIR/fmall.js";
77
78 echo "Updating web_fieldmapper";
79 perl fieldmapper.pl "$CONFIG" "web_core"        > "$JSDIR/fmcore.js";
80
81 echo "Updating OrgTree";
82 perl org_tree_js.pl "$CONFIG" > "$JSDIR/OrgTree.js";
83
84 echo "Updating OrgTree HTML";
85 perl org_tree_html_options.pl "$CONFIG" "$SLIMPACDIR/lib_list.inc";
86
87 if [ "$PROXIMITY" ]
88 then
89         echo "Refreshing proximity of org units";
90         perl org_tree_proximity.pl "$CONFIG";
91 fi
92
93 echo "";
94 echo "Done";
95
96 )
97