source: gsdl/trunk/gsicontrol.sh@ 20603

Last change on this file since 20603 was 20603, checked in by ak19, 15 years ago

Changes to Server.jar and affected files to add address_resolution options. 1. glisite.cfg.in and llssite.cfg.in have a host property where the host as specified or resolved from IP is stored. 2. gsicontrol.sh changed to set AllowFrom value to either the host specified OR to All if allow from all is checked in the GSI dialog. 3. New string properties added to server.properties for the updated GSI dialog for GS2. 4. log4j.properties.in updated so that the logger now can write to the console as well as the logfile specified (server.log in this case). At present only ERROR messages written to the logger are displayed in the console as well as logger message types that are higher up in the log4j hierarchy. 5. Server.jar updated after the changes to the GS3 server code (recompiled with Java 5).

  • Property svn:executable set to *
File size: 5.8 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 echo "Enter port number to use:"
54 read port ;
55 echo "Allow external connections [yes/no]:"
56 read connection ;
57 if [ $connection = "yes" ] || [ $connection = "y" ] ; then
58 allowfrom="all"
59 else
60 echo "Enter host (hostname, IP, localhost, 127.0.0.1) to use:"
61 read host ;
62 allowfrom=$host
63 if [ $allowfrom == "localhost" ]; then
64 allowfrom="127.0.0.1" ;
65 fi
66 fi
67
68 if test ! -z $port ; then
69 echo "Port: $port" ;
70 echo "Stopping web server (if running)" ;
71 web-stop-tested ;
72 echo "Setting config file to use port $port";
73 cat "$GSDLHOME/apache-httpd/$GSDLOS/conf/httpd.conf.in" \
74 | sed "s@\*\*PORT\*\*@$port@g" \
75 | sed "s@\*\*CONNECTION\*\*@$allowfrom@g" \
76 | sed "s@\*\*GSDLHOME\*\*@$GSDLHOME@g" \
77 | sed "s@\*\*APACHE_HOME_OS\*\*@$GSDLHOME/apache-httpd/$GSDLOS@g" \
78 > "$GSDLHOME/apache-httpd/$GSDLOS/conf/httpd.conf" ;
79 echo "Type '$0 web-start' to start the web server running on port $port" ;
80 fi ;
81 echo "Done" ;
82}
83
84
85MONITOR_SUCCESS="MAKE SUCCESSFUL"
86MONITOR_FAILED="MAKE FAILED"
87MONITOR_FINISHED="MAKE DONE"
88
89function configure-apache {
90 test-gsdlhome
91 configfile=$1 ;
92# if no configfile given, launch it with llssite.cfg. Create it from the template if needed.
93 if [ "x$configfile" = "x" ]; then
94 if test ! -e "$GSDLHOME/llssite.cfg" && test -e "$GSDLHOME/llssite.cfg.in" ; then
95 cp "$GSDLHOME/llssite.cfg.in" "$GSDLHOME/llssite.cfg" ;
96 fi
97 configfile="$GSDLHOME/llssite.cfg";
98 fi ;
99 echo "Configuring the apache webserver..." ;
100 port=`egrep "^portnumber" $configfile | awk -F= '{print $2}'` ;
101
102 externalaccess=`egrep "^externalaccess" $configfile | awk -F= '{print $2}'` ;
103 if [ $externalaccess == "1" ] ; then
104 externalaccess="yes"
105 else
106 externalaccess="no"
107 host=`egrep "^host" $configfile | awk -F= '{print $2}'` ;
108 fi
109
110 echo -e "$port\n$externalaccess\n$host" | _configure-port-and-connection ;
111 if test -e "$GSDLHOME/apache-httpd/$GSDLOS/conf/httpd.conf" ; then
112 echo $MONITOR_SUCCESS;
113 else
114 echo $MONITOR_FAILED;
115 fi
116 echo $MONITOR_FINISHED
117}
118
119function configure-web {
120 configure-cgi
121 configure-apache $1
122}
123
124function web-status {
125 test-gsdlhome
126 $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl status
127}
128
129function web-start {
130 test-gsdlhome
131 $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl start
132 if [ $? = 0 ] ; then
133 echo $MONITOR_SUCCESS;
134 else
135 echo $MONITOR_FAILED;
136 fi
137 echo $MONITOR_FINISHED;
138}
139
140function web-restart {
141 test-gsdlhome
142 $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl restart
143 if [ $? = 0 ] ; then
144 echo $MONITOR_SUCCESS;
145 else
146 echo $MONITOR_FAILED;
147 fi
148 echo $MONITOR_FINISHED;
149}
150
151function web-graceful {
152 test-gsdlhome
153 $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl graceful
154 if [ $? = 0 ] ; then
155 echo $MONITOR_SUCCESS;
156 else
157 echo $MONITOR_FAILED;
158 fi
159 echo $MONITOR_FINISHED;
160}
161
162function web-stop-tested {
163# This version runs without testing for GSDLHOME
164# Useful to be run as a target when we know test-gsdlhome has already
165# been done. This avoids a unnecessary repetition of printing
166# out the values of GSDLHOME and GSDLOS
167 if test -e "$GSDLHOME/apache-httpd/$GSDLOS/conf/httpd.conf" ; then
168 $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl stop ;
169 fi
170}
171
172function web-stop {
173 test-gsdlhome
174 web-stop-tested
175 if [ $? = 0 ] ; then
176 echo $MONITOR_SUCCESS;
177 else
178 echo $MONITOR_FAILED;
179 fi
180 echo $MONITOR_FINISHED;
181}
182
183function usage {
184 echo ""
185 echo " Usage: $0 <command>"
186 echo " where <command> is any of the following: "
187 echo " web-start"
188 echo " web-stop"
189 echo " web-restart"
190 echo " web-status"
191 echo " web-graceful"
192 echo " configure-admin"
193 echo " configure-web [config-filename]"
194 echo " configure-apache [config-filename]"
195 echo " configure-cgi"
196 echo " test-gsdlhome"
197 echo " web-stop-tested"
198 echo ""
199}
200
201
202if [[ $# < 1 || $# > 2 ]] ; then
203 usage
204 exit 0
205fi
206
207target=$1
208configfile=$2
209
210case $target in
211 web-start)
212 web-start;;
213 web-stop)
214 web-stop;;
215 web-restart)
216 web-restart;;
217 web-status)
218 web-status;;
219 web-graceful)
220 web-graceful;;
221 configure-admin)
222 configure-admin;;
223 configure-web)
224 configure-web $configfile;;
225 configure-apache)
226 configure-apache $configfile;;
227 configure-cgi)
228 configure-cgi;;
229 test-gsdlhome)
230 test-gsdlhome;;
231 web-stop-tested)
232 web-stop-tested;;
233 *)
234 echo
235 echo "Command unrecognised: $target"
236 usage;;
237
238esac
239
240exit;
Note: See TracBrowser for help on using the repository browser.