source: gsdl/trunk/gsicontrol.sh@ 18866

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

The configure-web and configure-apache targets now take an extra optional parameter, the configuration file, which defaults to llssite.cfg if none is provided.

  • Property svn:executable set to *
File size: 4.5 KB
Line 
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 configfile=$1 ;
72 if [ "x$configfile" = "x" ]; then
73 configfile="$GSDLHOME/llssite.cfg";
74 fi ;
75 echo "Configuring the apache webserver..." ;
76 port=`egrep "^portnumber" $configfile | awk -F= '{print $2}'` ;
77 echo $port | configure-port ;
78 if test -e "$GSDLHOME/apache-httpd/$GSDLOS/conf/httpd.conf" ; then
79 echo $MONITOR_SUCCESS;
80 else
81 echo $MONITOR_FAILED;
82 fi
83 echo $MONITOR_FINISHED
84}
85
86function configure-web {
87 configure-cgi
88 configure-apache $1
89}
90
91function web-status {
92 test-gsdlhome
93 $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl status
94}
95
96function web-start {
97 test-gsdlhome
98 $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl start
99 echo $MONITOR_SUCCESS
100 echo $MONITOR_FINISHED
101}
102
103function web-restart {
104 test-gsdlhome
105 $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl restart
106 echo $MONITOR_SUCCESS
107 echo $MONITOR_FINISHED
108}
109
110function web-graceful {
111 test-gsdlhome
112 $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl graceful
113 echo $MONITOR_SUCCESS
114 echo $MONITOR_FINISHED
115}
116
117function web-stop-tested {
118# This version runs without testing for GSDLHOME
119# Useful to be run as a target when we know test-gsdlhome has already
120# been done. This avoids a unnecessary repetition of printing
121# out the values of GSDLHOME and GSDLOS
122 if test -e "$GSDLHOME/apache-httpd/$GSDLOS/conf/httpd.conf" ; then
123 $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl stop ;
124 fi
125}
126
127function web-stop {
128 test-gsdlhome
129 web-stop-tested
130 echo $MONITOR_SUCCESS
131 echo $MONITOR_FINISHED
132}
133
134
135if [[ $# < 1 || $# > 2 ]] ; then
136 echo ""
137 echo " Usage: $0 <command>"
138 echo " where <command> is any of the following: "
139 echo " web-start"
140 echo " web-stop"
141 echo " web-restart"
142 echo " web-status"
143 echo " web-graceful"
144 echo " configure-admin"
145 echo " configure-web [config-filename]"
146 echo " configure-apache [config-filename]"
147 echo " configure-port"
148 echo " configure-cgi"
149 echo " test-gsdlhome"
150 echo " web-stop-tested"
151 echo ""
152 exit 0
153fi
154
155target=$1
156configfile=$2
157
158case $target in
159 web-start)
160 web-start;;
161 web-stop)
162 web-stop;;
163 web-restart)
164 web-restart;;
165 web-status)
166 web-status;;
167 web-graceful)
168 web-graceful;;
169 configure-admin)
170 configure-admin;;
171 configure-web)
172 configure-web $configfile;;
173 configure-port)
174 configure-port;;
175 configure-apache)
176 configure-apache $configfile;;
177 configure-cgi)
178 configure-cgi;;
179 test-gsdlhome)
180 test-gsdlhome;;
181 web-stop-tested)
182 web-stop-tested;;
183esac
184
185exit;
Note: See TracBrowser for help on using the repository browser.