source: gsdl/trunk/gsicontrol.sh@ 18851

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

GSI-Makefile is now split into a bash script and the old Makefile where the targets just call the functions in the bash script by passing the function names as arguments.

  • Property svn:executable set to *
File size: 4.3 KB
RevLine 
[18851]1#!/bin/bash
2
3function test-gsdlhome {
4 if test -z "$GSDLHOME" ; then
5 echo "" ;
6 echo "Environment variable GSDLHOME not set." ;
7 echo " This needs to be set to run this gsicontrol command." ;
8 echo " Have you run 'source setup.bash'?" ;
9 echo "" ;
10 exit 1
11 else
12 echo "Using: " ;
13 echo " GSDLHOME = $GSDLHOME" ;
14 echo " GSDLOS = $GSDLOS" ;
15 fi
16}
17
18function configure-cgi {
19 test-gsdlhome
20 if test ! -e $GSDLHOME/cgi-bin/gsdlsite.cfg ; then
21 echo "Configuring cgi-bin/gsdlsite.cfg" ;
22 sed "s@\*\*GSDLHOME\*\*@$GSDLHOME@g" cgi-bin/gsdlsite.cfg.in > cgi-bin/gsdlsite.cfg ;
23 else
24 echo "WARNING: Nothing done for make configure-cgi." ;
25 echo " If you wish to regenerate the file " ;
26 echo " $GSDLHOME/cgi-bin/gsdlsite.cfg" ;
27 echo " from scratch, delete the existing file first." ;
28 fi
29}
30
31function configure-admin {
32 test-gsdlhome
33 echo "" ;
34 echo "Configuring admin user password:" ;
35 encrypted_password=`getpw` ;
36 if [ $? = "0" ] ; then
37 echo -e "[admin]\n<enabled>true\n<groups>administrator,colbuilder,all-collections-editor\n<password>$encrypted_password\n<username>admin" \
38 | txt2db -append "$GSDLHOME/etc/users.db" ;
39 else
40 echo "Did not set password" ;
41 fi
42 echo ""
43}
44
45function configure-port {
46 test-gsdlhome
47 echo "Enter port number to use:"
48 read port ;
49 if test ! -z $port ; then
50 echo "Port: $port" ;
51 echo "Stopping web server (if running)" ;
52 web-stop-tested ;
53 echo "Setting config file to use port $port";
54 cat "$GSDLHOME/apache-httpd/$GSDLOS/conf/httpd.conf.in" \
55 | sed "s@\*\*PORT\*\*@$port@g" \
56 | sed "s@\*\*GSDLHOME\*\*@$GSDLHOME@g" \
57 | sed "s@\*\*APACHE_HOME_OS\*\*@$GSDLHOME/apache-httpd/$GSDLOS@g" \
58 > "$GSDLHOME/apache-httpd/$GSDLOS/conf/httpd.conf" ;
59 echo "Type '$0 web-start' to start the web server running on port $port" ;
60 fi ;
61 echo "Done" ;
62}
63
64
65MONITOR_SUCCESS="MAKE SUCCESSFUL"
66MONITOR_FAILED="MAKE FAILED"
67MONITOR_FINISHED="MAKE DONE"
68
69function configure-apache {
70 test-gsdlhome
71 echo "Configuring the apache webserver..." ;
72 port=`egrep "^apache.port" $GSDLHOME/lib/java/build.properties | awk -F= '{print $2}'` ;
73 echo $port | configure-port ;
74 if test -e "$GSDLHOME/apache-httpd/$GSDLOS/conf/httpd.conf" ; then
75 echo $MONITOR_SUCCESS;
76 else
77 echo $MONITOR_FAILED;
78 fi
79 echo $MONITOR_FINISHED
80}
81
82function configure-web {
83 configure-cgi
84 configure-apache
85}
86
87function web-status {
88 test-gsdlhome
89 $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl status
90}
91
92function web-start {
93 test-gsdlhome
94 $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl start
95 echo $MONITOR_SUCCESS
96 echo $MONITOR_FINISHED
97}
98
99function web-restart {
100 test-gsdlhome
101 $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl restart
102 echo $MONITOR_SUCCESS
103 echo $MONITOR_FINISHED
104}
105
106function web-graceful {
107 test-gsdlhome
108 $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl graceful
109 echo $MONITOR_SUCCESS
110 echo $MONITOR_FINISHED
111}
112
113function web-stop-tested {
114# This version runs without testing for GSDLHOME
115# Useful to be run as a target when we know test-gsdlhome has already
116# been done. This avoids a unnecessary repetition of printing
117# out the values of GSDLHOME and GSDLOS
118 if test -e "$GSDLHOME/apache-httpd/$GSDLOS/conf/httpd.conf" ; then
119 $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl stop ;
120 fi
121}
122
123function web-stop {
124 test-gsdlhome
125 web-stop-tested
126 echo $MONITOR_SUCCESS
127 echo $MONITOR_FINISHED
128}
129
130
131if [ $# != 1 ] ; then
132 echo ""
133 echo " Usage: $0 <command>"
134 echo " where <command> is any of the following: "
135 echo " web-start"
136 echo " web-stop"
137 echo " web-restart"
138 echo " web-status"
139 echo " web-graceful"
140 echo " configure-admin"
141 echo " configure-web"
142 echo " configure-port"
143 echo " configure-apache"
144 echo " configure-cgi"
145 echo " test-gsdlhome"
146 echo " web-stop-tested"
147 echo ""
148 exit 0
149fi
150
151target=$1
152
153case $target in
154 web-start)
155 web-start;;
156 web-stop)
157 web-stop;;
158 web-restart)
159 web-restart;;
160 web-status)
161 web-status;;
162 web-graceful)
163 web-graceful;;
164 configure-admin)
165 configure-admin;;
166 configure-web)
167 configure-web;;
168 configure-port)
169 configure-port;;
170 configure-apache)
171 configure-apache;;
172 configure-cgi)
173 configure-cgi;;
174 test-gsdlhome)
175 test-gsdlhome;;
176 web-stop-tested)
177 web-stop-tested;;
178esac
179
180exit;
Note: See TracBrowser for help on using the repository browser.