Rev 823 | Rev 8375 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3 | reyssat | 1 | #! /bin/sh |
2 | # |
||
3 | # This script adds WIMS-related definitions to Apache config. |
||
4 | # It must be run as root. |
||
5 | # |
||
6 | # If you want to prohibit the action of this script, |
||
7 | # insert the following word to httpd.conf (in a commented line): |
||
8 | # manually_configured_for_wims |
||
9 | # |
||
10 | |||
824 | bpr | 11 | if [ ! "$(id -ru )" = 0 ]; then |
3 | reyssat | 12 | echo |
13 | echo This script adds WIMS-related definitions to Apache config. |
||
14 | echo It must be run as root. |
||
15 | echo |
||
16 | echo su to root before running this script! |
||
17 | echo |
||
18 | echo |
||
19 | exit |
||
20 | fi |
||
21 | |||
22 | distro=default |
||
23 | [ -f /etc/debian_version ] && distro=debian |
||
24 | |||
25 | PATH=$PATH:/usr/sbin:/sbin |
||
26 | export PATH |
||
27 | # httpd or apache? |
||
28 | httpd -v >/dev/null && httpdname=httpd |
||
29 | if [ -z "$httpdname" ]; then apache -v >/dev/null && httpdname=apache; fi |
||
30 | if [ -z "$httpdname" ]; then apache2 -v >/dev/null && httpdname=apache2; fi |
||
31 | if [ -z "$httpdname" ]; then httpd2 -v >/dev/null && httpdname=httpd2; fi |
||
32 | if [ -z "$httpdname" ]; then |
||
33 | cat <<@ |
||
34 | |||
35 | Apache is not found on your system. |
||
36 | WIMS requires a running web server Apache. |
||
37 | Please first install Apache (>=1.3). |
||
38 | |||
39 | @ |
||
40 | exit |
||
41 | fi |
||
42 | conffile=`$httpdname -V | grep SERVER_CONFIG_FILE | awk -F'=' '{print $2}' \ |
||
43 | | tr -d ' "'` |
||
44 | confdir=`dirname $conffile` |
||
45 | if [ -z "$confdir" ]; then |
||
46 | cat <<@ |
||
47 | |||
48 | Unknown web server. Version too early? |
||
49 | Please first update your web server to Apache >=1.3. |
||
50 | |||
51 | @ |
||
52 | exit |
||
53 | fi |
||
54 | |||
55 | case $distro in |
||
56 | debian) conffile=$confdir/conf.d/wims.conf |
||
57 | |||
58 | ;; |
||
59 | esac |
||
60 | |||
61 | cd `dirname $0`/.. |
||
62 | wimshome=`pwd` |
||
63 | |||
64 | if [ ! -e public_html/wims.cgi ] || [ ! -e bin/apache-config ]; then |
||
65 | echo Error: wrong directory. File wims.cgi not found. |
||
66 | echo |
||
67 | exit |
||
68 | fi |
||
69 | |||
70 | httpdroot=`$httpdname -V | grep HTTPD_ROOT | awk -F'=' '{print $2}' \ |
||
71 | | tr -d ' "'` |
||
72 | if [ ! -z "$httpdroot" ]; then cd $httpdroot; fi |
||
73 | |||
74 | tmpfile=/tmp/wims-apache.conf |
||
75 | vtest=`$httpdname -v | grep Apache` |
||
76 | if [ -z "$vtest" ]; then |
||
77 | echo |
||
78 | echo You are not running Apache web server! |
||
79 | echo |
||
80 | echo You must configure manually your web server, this script cannot be used. |
||
81 | echo |
||
82 | exit |
||
83 | fi |
||
84 | |||
85 | conftest=`grep -i manually_configured_for_wims $conffile` |
||
86 | if [ ! -z "$conftest" ]; then |
||
87 | echo Manually configured $conffile not modified. |
||
88 | exit |
||
89 | fi |
||
90 | |||
91 | # The next two definitions should NEVER be changed. |
||
92 | startl="WIMS definitions start. Do not alter this line" |
||
93 | endl="WIMS definitions end. Do not alter this line" |
||
94 | |||
95 | case $distro in |
||
96 | debian) rm -f $tmpfile |
||
97 | ;; |
||
98 | *) awk 'BEGIN {a=1}; |
||
99 | /'"$startl"'/ {a=0}; |
||
100 | a==1 {print}; |
||
101 | /'"$endl"'/ {a=1};' $conffile >$tmpfile |
||
102 | ;; |
||
103 | esac |
||
104 | |||
105 | if [ "$1" = "uninstall" ]; then |
||
106 | case $distro in |
||
107 | debian) rm -f $conffile $tmpfile |
||
108 | ;; |
||
109 | *) mv $tmpfile $conffile |
||
110 | ;; |
||
111 | esac |
||
112 | killall -HUP $httpdname |
||
113 | exit |
||
114 | fi |
||
115 | |||
116 | cat >>$tmpfile <<@ |
||
117 | ###### $startl! ###### |
||
118 | # |
||
119 | # If you manually add things concerning WIMS into this configuration file, |
||
120 | # add them BEFORE the 'WIMS definition start' line. |
||
121 | # Otherwise the addition will be erased in next update. |
||
122 | # |
||
123 | AddHandler cgi-script .cgi |
||
124 | @ |
||
125 | |||
126 | vtest=`echo $vtest | grep 'pache/1\.2'` |
||
127 | if [ ! -z "$vtest" ]; then |
||
128 | cat >>$tmpfile <<@ |
||
129 | ScriptAlias /wims/wims.cgi $wimshome/public_html/wims.cgi |
||
130 | ScriptAlias /wims/wims.html $wimshome/public_html/wims.cgi |
||
131 | ScriptAlias /wims/index.html $wimshome/public_html/wims.cgi |
||
132 | ScriptAlias /wims/wims.gif $wimshome/public_html/wims.cgi |
||
133 | ScriptAlias /wims/wims.png $wimshome/public_html/wims.cgi |
||
134 | ScriptAlias /wims/wims.jpeg $wimshome/public_html/wims.cgi |
||
135 | ScriptAlias /wims/wims.jpg $wimshome/public_html/wims.cgi |
||
136 | @ |
||
137 | else # newer versions of Apache |
||
138 | cat >>$tmpfile <<@ |
||
139 | ScriptAliasMatch ^/~wims/wims\.(.*) $wimshome/public_html/wims.cgi |
||
140 | ScriptAliasMatch ^/wims/wims\.(.*) $wimshome/public_html/wims.cgi |
||
141 | ScriptAliasMatch ^/~wims/index\.(.*) $wimshome/public_html/wims.cgi |
||
142 | ScriptAliasMatch ^/wims/index\.(.*) $wimshome/public_html/wims.cgi |
||
143 | ScriptAliasMatch ^/~wims/.._(.*).html $wimshome/public_html/wims.cgi |
||
144 | ScriptAliasMatch ^/wims/.._(.*).html $wimshome/public_html/wims.cgi |
||
145 | ScriptAliasMatch ^/~wims/getfile/(.*) $wimshome/public_html/wims.cgi |
||
146 | ScriptAliasMatch ^/wims/getfile/(.*) $wimshome/public_html/wims.cgi |
||
147 | ScriptAlias /wims/....\.cgi $wimshome/public_html/wims.cgi |
||
148 | @ |
||
149 | fi |
||
150 | cat >>$tmpfile <<@ |
||
151 | Alias /wims $wimshome/public_html |
||
152 | Alias /~wims $wimshome/public_html |
||
153 | |||
154 | <Directory $wimshome/public_html> |
||
155 | Options FollowSymLinks ExecCGI -Indexes |
||
156 | AllowOverride All |
||
157 | allow from all |
||
158 | </Directory> |
||
159 | <Directory $wimshome/public_html/modules> |
||
160 | Options FollowSymLinks |
||
161 | AllowOverride Limit |
||
162 | </Directory> |
||
163 | |||
164 | ###### $endl! ###### |
||
165 | @ |
||
166 | |||
167 | mv $tmpfile $conffile |
||
168 | |||
169 | initdir=/etc/init.d |
||
823 | bpr | 170 | [ -d $initdir ] || initdir=/etc/rc.d/init.d |
3 | reyssat | 171 | initscript=$initdir/httpd |
172 | [ -f $initscript ] || initscript=$initdir/apache |
||
173 | if [ -f $initscript ]; then |
||
174 | $initscript restart |
||
175 | else |
||
176 | echo |
||
177 | echo Now you must restart your httpd to make the new configuration |
||
178 | echo take effect. |
||
179 | echo If you don\'t know how to do so: just shut down the system then |
||
180 | echo restart it. |
||
181 | echo |
||
182 | fi |
||
183 |