[18851] | 1 | #!/bin/bash
|
---|
| 2 |
|
---|
| 3 | function 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 |
|
---|
| 18 | function 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 |
|
---|
| 31 | function 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 |
|
---|
| 45 | function 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 |
|
---|
| 65 | MONITOR_SUCCESS="MAKE SUCCESSFUL"
|
---|
| 66 | MONITOR_FAILED="MAKE FAILED"
|
---|
| 67 | MONITOR_FINISHED="MAKE DONE"
|
---|
| 68 |
|
---|
| 69 | function configure-apache {
|
---|
| 70 | test-gsdlhome
|
---|
[18866] | 71 | configfile=$1 ;
|
---|
| 72 | if [ "x$configfile" = "x" ]; then
|
---|
| 73 | configfile="$GSDLHOME/llssite.cfg";
|
---|
| 74 | fi ;
|
---|
[18851] | 75 | echo "Configuring the apache webserver..." ;
|
---|
[18866] | 76 | port=`egrep "^portnumber" $configfile | awk -F= '{print $2}'` ;
|
---|
[18851] | 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 |
|
---|
| 86 | function configure-web {
|
---|
| 87 | configure-cgi
|
---|
[18866] | 88 | configure-apache $1
|
---|
[18851] | 89 | }
|
---|
| 90 |
|
---|
| 91 | function web-status {
|
---|
| 92 | test-gsdlhome
|
---|
| 93 | $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl status
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | function web-start {
|
---|
| 97 | test-gsdlhome
|
---|
| 98 | $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl start
|
---|
| 99 | echo $MONITOR_SUCCESS
|
---|
| 100 | echo $MONITOR_FINISHED
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | function web-restart {
|
---|
| 104 | test-gsdlhome
|
---|
| 105 | $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl restart
|
---|
| 106 | echo $MONITOR_SUCCESS
|
---|
| 107 | echo $MONITOR_FINISHED
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | function web-graceful {
|
---|
| 111 | test-gsdlhome
|
---|
| 112 | $GSDLHOME/apache-httpd/$GSDLOS/bin/apachectl graceful
|
---|
| 113 | echo $MONITOR_SUCCESS
|
---|
| 114 | echo $MONITOR_FINISHED
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | function 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 |
|
---|
| 127 | function web-stop {
|
---|
| 128 | test-gsdlhome
|
---|
| 129 | web-stop-tested
|
---|
| 130 | echo $MONITOR_SUCCESS
|
---|
| 131 | echo $MONITOR_FINISHED
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 |
|
---|
[18866] | 135 | if [[ $# < 1 || $# > 2 ]] ; then
|
---|
[18851] | 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"
|
---|
[18866] | 145 | echo " configure-web [config-filename]"
|
---|
| 146 | echo " configure-apache [config-filename]"
|
---|
[18851] | 147 | echo " configure-port"
|
---|
| 148 | echo " configure-cgi"
|
---|
| 149 | echo " test-gsdlhome"
|
---|
| 150 | echo " web-stop-tested"
|
---|
| 151 | echo ""
|
---|
| 152 | exit 0
|
---|
| 153 | fi
|
---|
| 154 |
|
---|
| 155 | target=$1
|
---|
[18866] | 156 | configfile=$2
|
---|
[18851] | 157 |
|
---|
| 158 | case $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)
|
---|
[18866] | 172 | configure-web $configfile;;
|
---|
[18851] | 173 | configure-port)
|
---|
| 174 | configure-port;;
|
---|
| 175 | configure-apache)
|
---|
[18866] | 176 | configure-apache $configfile;;
|
---|
[18851] | 177 | configure-cgi)
|
---|
| 178 | configure-cgi;;
|
---|
| 179 | test-gsdlhome)
|
---|
| 180 | test-gsdlhome;;
|
---|
| 181 | web-stop-tested)
|
---|
| 182 | web-stop-tested;;
|
---|
| 183 | esac
|
---|
| 184 |
|
---|
| 185 | exit; |
---|