source: gsdl/trunk/gsicontrol.sh@ 19140

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

The .db file extensions on key, users, history and argdb have been changed to.gdb, this file needed to be updated to refer to the .gdb files now.

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