source: main/trunk/greenstone2/gsicontrol.sh@ 23776

Last change on this file since 23776 was 23726, checked in by ak19, 13 years ago

Sam's changes for Mac's libiconv seem to work so that word docs get processed even in the remote Mac GS Server case, therefore am undoing recent changes to gsicontrol.sh (resetting to revision 23252) and setup.bash (resetting to revision 23588) which got the old apache libiconv to only be found and used by apache which needed it, so wvware processing of word docs on a local Mac GS server worked using the system libiconv. But this fix hadn't solved the case for the remote Mac GS2 Server situation, since wvware then found apache's libiconv which was not right for it.

  • Property svn:executable set to *
File size: 6.6 KB
Line 
1#!/bin/bash
2
3testdone=0
4
5function test-gsdlhome {
6 if [ $testdone == "0" ] ; then
7 if test -z "$GSDLHOME" ; then
8 echo "" ;
9 echo "Environment variable GSDLHOME not set." ;
10 echo " This needs to be set to run this gsicontrol command." ;
11 echo " Have you run 'source setup.bash'?" ;
12 echo "" ;
13 exit 1
14 else
15 echo "Using: " ;
16 echo " GSDLHOME = $GSDLHOME" ;
17 echo " GSDLOS = $GSDLOS" ;
18 fi
19 testdone=1
20 fi
21}
22
23function configure-cgi {
24 test-gsdlhome
25 if test ! -e $GSDLHOME/cgi-bin/gsdlsite.cfg ; then
26 echo "Configuring cgi-bin/gsdlsite.cfg" ;
27 sed "s@\*\*GSDLHOME\*\*@$GSDLHOME@g" cgi-bin/gsdlsite.cfg.in > cgi-bin/gsdlsite.cfg ;
28 else
29 echo "WARNING: Nothing done for make configure-cgi." ;
30 echo " If you wish to regenerate the file " ;
31 echo " $GSDLHOME/cgi-bin/gsdlsite.cfg" ;
32 echo " from scratch, delete the existing file first." ;
33 fi
34}
35
36function configure-admin {
37 test-gsdlhome
38 echo "" ;
39 echo "Configuring admin user password:" ;
40 encrypted_password=`getpw` ;
41 if [ $? = "0" ] ; then
42 echo -e "[admin]\n<enabled>true\n<groups>administrator,colbuilder,all-collections-editor\n<password>$encrypted_password\n<username>admin" \
43 | txt2db -append "$GSDLHOME/etc/users.gdb" ;
44 else
45 echo "Did not set password" ;
46 fi
47 echo ""
48}
49
50
51function configure-port-and-connection {
52 test-gsdlhome
53
54 echo "Enter port number to use:"
55 read port ;
56 echo "Enter host IP to allow (127.0.0.1 is included by default):"
57 read hostIP ;
58 echo "Enter hostname or list of hosts to allow (localhost included by default):"
59 read hosts ;
60 echo "Allow external connections [yes/no]:"
61 read connection ;
62 if [ "x$connection" = "xyes" ] || [ "x$connection" = "xy" ] ; then
63 allowfromall="Allow"
64 else
65 allowfromall="Deny"
66 fi
67
68 lib_path_var="LD_LIBRARY_PATH" ;
69 if [ $GSDLOS = "darwin" ] ; then
70 lib_path_var="DYLD_LIBRARY_PATH"
71 fi
72
73 if test -e $GSDLHOME/cgi-bin/gsdlsite.cfg ; then
74 collecthome=`egrep "^collecthome" $GSDLHOME/cgi-bin/gsdlsite.cfg | awk '{print $2}'` ;
75 fi
76 if test -z $collecthome ; then
77 collecthome="$GSDLHOME/collect" ;
78 fi
79
80 if test ! -z $port ; then
81 echo "Port: $port" ;
82 echo "Stopping web server (if running)" ;
83 web-stop-tested ;
84 echo "Setting config file to use port $port";
85 cat "$GSDLHOME/apache-httpd/$GSDLOS/conf/httpd.conf.in" \
86 | sed "s@\*\*PORT\*\*@$port@g" \
87 | sed "s@\*\*CONNECTPERMISSION\*\*@$allowfromall@g" \
88 | sed "s@\*\*HOST_IP\*\*@$hostIP@g" \
89 | sed "s@\*\*HOSTS\*\*@$hosts@g" \
90 | sed "s@\*\*COLLECTHOME\*\*@$collecthome@g" \
91 | sed "s@\*\*GSDLHOME\*\*@$GSDLHOME@g" \
92 | sed "s@\*\*APACHE_HOME_OS\*\*@$GSDLHOME/apache-httpd/$GSDLOS@g" \
93 | sed "s@\*\*LIBRARY_PATH_VAR\*\*@$lib_path_var@g" \
94 > "$GSDLHOME/apache-httpd/$GSDLOS/conf/httpd.conf" ;
95 echo "Type '$0 web-start' to start the web server running on port $port" ;
96 fi ;
97 echo "Done" ;
98}
99
100
101MONITOR_SUCCESS="MAKE SUCCESSFUL"
102MONITOR_FAILED="MAKE FAILED"
103MONITOR_FINISHED="MAKE DONE"
104
105function configure-apache {
106 test-gsdlhome
107 configfile=$1 ;
108# if no configfile given, launch it with llssite.cfg. Create it from the template if needed.
109 if [ "x$configfile" = "x" ]; then
110 if test ! -e "$GSDLHOME/llssite.cfg" && test -e "$GSDLHOME/llssite.cfg.in" ; then
111 cp "$GSDLHOME/llssite.cfg.in" "$GSDLHOME/llssite.cfg" ;
112 fi
113 configfile="$GSDLHOME/llssite.cfg";
114 fi ;
115 echo "Configuring the apache webserver..." ;
116 port=`egrep "^portnumber" $configfile | awk -F= '{print $2}'` ;
117 hostIP=`egrep "^hostIP" $configfile | awk -F= '{print $2}'` ;
118 hosts=`egrep "^hosts" $configfile | awk -F= '{print $2}'` ;
119
120 externalaccess=`egrep "^externalaccess" $configfile | awk -F= '{print $2}'` ;
121 if [ "x$externalaccess" = "x1" ] ; then
122 externalaccess="yes"
123 else
124 externalaccess="no"
125 fi
126
127 echo -e "$port\n$hostIP\n$hosts\n$externalaccess" | configure-port-and-connection ;
128 if test -e "$GSDLHOME/apache-httpd/$GSDLOS/conf/httpd.conf" ; then
129 echo $MONITOR_SUCCESS;
130 else
131 echo $MONITOR_FAILED;
132 fi
133 echo $MONITOR_FINISHED
134}
135
136function configure-web {
137 configure-cgi
138 configure-apache $1
139}
140
141function web-status {
142 test-gsdlhome
143 $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl status
144}
145
146function web-start {
147 test-gsdlhome
148 $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl start
149 if [ $? = 0 ] ; then
150 echo $MONITOR_SUCCESS;
151 else
152 echo $MONITOR_FAILED;
153 fi
154 echo $MONITOR_FINISHED;
155}
156
157function web-restart {
158 test-gsdlhome
159 $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl restart
160 if [ $? = 0 ] ; then
161 echo $MONITOR_SUCCESS;
162 else
163 echo $MONITOR_FAILED;
164 fi
165 echo $MONITOR_FINISHED;
166}
167
168function web-graceful {
169 test-gsdlhome
170 $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl graceful
171 if [ $? = 0 ] ; then
172 echo $MONITOR_SUCCESS;
173 else
174 echo $MONITOR_FAILED;
175 fi
176 echo $MONITOR_FINISHED;
177}
178
179function web-stop-tested {
180# This version runs without testing for GSDLHOME
181# Useful to be run as a target when we know test-gsdlhome has already
182# been done. This avoids an unnecessary repetition of printing
183# out the values of GSDLHOME and GSDLOS
184 if test -e "$GSDLHOME/apache-httpd/$GSDLOS/conf/httpd.conf" ; then
185 $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl stop ;
186 fi
187}
188
189function web-stop {
190 test-gsdlhome
191 web-stop-tested
192 if [ $? = 0 ] ; then
193 echo $MONITOR_SUCCESS;
194 else
195 echo $MONITOR_FAILED;
196 fi
197 echo $MONITOR_FINISHED;
198}
199
200function usage {
201 echo ""
202 echo " Usage: $0 <command>"
203 echo " where <command> is any of the following: "
204 echo " web-start"
205 echo " web-stop"
206 echo " web-restart"
207 echo " web-status"
208 echo " web-graceful"
209 echo " configure-admin"
210 echo " configure-web [config-filename]"
211 echo " configure-apache [config-filename]"
212 echo " configure-cgi"
213 echo " test-gsdlhome"
214 echo " web-stop-tested"
215 echo ""
216}
217
218
219if [[ $# < 1 || $# > 2 ]] ; then
220 usage
221 exit 0
222fi
223
224target=$1
225configfile=$2
226
227# remove any extraneous double quotes
228configfile=${configfile//\"/}
229
230case $target in
231 web-start)
232 web-start;;
233 web-stop)
234 web-stop;;
235 web-restart)
236 web-restart;;
237 web-status)
238 web-status;;
239 web-graceful)
240 web-graceful;;
241 configure-admin)
242 configure-admin;;
243 configure-web)
244 configure-web $configfile;;
245 configure-apache)
246 configure-apache $configfile;;
247 configure-cgi)
248 configure-cgi;;
249 set-port)
250 configure-port-and-connection;;
251 test-gsdlhome)
252 test-gsdlhome;;
253 web-stop-tested)
254 web-stop-tested;;
255 *)
256 echo
257 echo "Command unrecognised: $target"
258 usage;;
259
260esac
261
262exit;
Note: See TracBrowser for help on using the repository browser.