Subversion Repositories wimsdev

Rev

Rev 8509 | Rev 11204 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8509 Rev 10121
Line 5... Line 5...
5
#
5
#
6
#	If you want to prohibit the action of this script,
6
#	If you want to prohibit the action of this script,
7
#	insert the following word to httpd.conf (in a commented line):
7
#	insert the following word to httpd.conf (in a commented line):
8
#	manually_configured_for_wims
8
#	manually_configured_for_wims
9
#
9
#
-
 
10
echo
-
 
11
echo  " ## This script adds WIMS-related definitions to Apache config. ##"
-
 
12
echo ;
10
 
13
 
11
if [ ! "$(id -ru )" = 0 ]; then
14
if [ ! "$(id -ru )" = 0 ]; then
12
 echo
15
 echo
13
 echo This script adds WIMS-related definitions to Apache config.
-
 
14
 echo It must be run as root.
16
 echo It must be run as root.
15
 echo
17
 echo
16
 echo su to root before running this script!
18
 echo su to root before running this script!
17
 echo
19
 echo
18
 echo
20
 echo
Line 22... Line 24...
22
distro=default
24
distro=default
23
[ -f /etc/debian_version ] && distro=debian
25
[ -f /etc/debian_version ] && distro=debian
24
 
26
 
25
PATH=$PATH:/usr/sbin:/sbin
27
PATH=$PATH:/usr/sbin:/sbin
26
export PATH
28
export PATH
-
 
29
 
27
# httpd or apache?
30
echo "Detecting which HTTP server to execute...";
28
httpd -v >/dev/null && httpdname=httpd
31
apache2 -v >/dev/null && httpdname=apache2
29
if [ -z "$httpdname" ]; then apache -v >/dev/null && httpdname=apache; fi
32
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
33
if [ -z "$httpdname" ]; then httpd2 -v >/dev/null && httpdname=httpd2; fi
-
 
34
if [ -z "$httpdname" ]; then httpd -v >/dev/null && httpdname=httpd; fi
32
if [ -z "$httpdname" ]; then
35
if [ -z "$httpdname" ]; then
33
 cat <<@
36
 cat <<@
34
 
37
 
35
Apache is not found on your system.
38
Apache is not found on your system.
36
WIMS requires a running web server Apache.
39
WIMS requires a running web server Apache.
37
Please first install Apache (>=1.3).
40
Please first install Apache (>=1.3).
38
 
41
 
39
@
42
@
40
 exit
43
 exit
41
fi
44
fi
42
[ -f /etc/apache2/envvars ] && . /etc/apache2/envvars
45
[ -f /etc/apache2/envvars ] && . /etc/apache2/envvars
-
 
46
 
-
 
47
echo " => HTTP server detected as $httpdname";
-
 
48
 
-
 
49
echo "Searching $httpdname conf file...";
43
conffile=`$httpdname -V | grep SERVER_CONFIG_FILE | awk -F'=' '{print $2}'  | tr -d ' "'`
50
conffile=`$httpdname -V | grep SERVER_CONFIG_FILE | awk -F'=' '{print $2}'  | tr -d ' "'`
44
confdir=`dirname $conffile`
51
confdir=`dirname $conffile`
45
if [ -z "$confdir" ]; then
52
if [ -z "$confdir" ]; then
46
 cat <<@
53
 cat <<@
47
 
54
 
Line 50... Line 57...
50
 
57
 
51
@
58
@
52
 exit
59
 exit
53
fi
60
fi
54
 
61
 
-
 
62
echo " # Linux Type: $distro";
55
case $distro in
63
if [ "$distro" = "debian" ];then
56
 debian) if [ `lsb_release -c | cut -f2` = "trusty" ];then
64
  lsb_release=`lsb_release -c | cut -f2`
57
           conffile=$confdir/conf-enabled/wims.conf
65
  echo " # Release : $lsb_release";
58
         else
66
    case $lsb_release in
-
 
67
    trusty|jessie|xenial) conffile=$confdir/conf-enabled/wims.conf;;
59
           conffile=$confdir/conf.d/wims.conf
68
    *)                    conffile=$confdir/conf.d/wims.conf;;
60
         fi
69
    esac
61
 
70
fi
62
 ;;
71
 
63
esac
72
echo " => HTTPd conf file : $conffile";
64
 
73
 
65
cd `dirname $0`/..
74
cd `dirname $0`/..
66
wimshome=`pwd`
75
wimshome=`pwd`
67
 
76
 
68
if [ ! -e public_html/wims.cgi ] || [ ! -e bin/apache-config ]; then
77
if [ ! -e public_html/wims.cgi ] || [ ! -e bin/apache-config ]; then
69
 echo Error: wrong directory. File wims.cgi not found.
78
 echo Error: wrong directory. File wims.cgi not found.
70
 echo
79
 echo
71
 exit
80
 exit
72
fi
81
fi
73
 
82
 
-
 
83
echo "Searching HTTPd root..."
74
httpdroot=`$httpdname -V | grep HTTPD_ROOT | awk -F'=' '{print $2}' \
84
httpdroot=`$httpdname -V | grep HTTPD_ROOT | awk -F'=' '{print $2}' \
75
 | tr -d ' "'`
85
 | tr -d ' "'`
76
if [ ! -z "$httpdroot" ]; then cd $httpdroot; fi
86
if [ ! -z "$httpdroot" ]; then cd $httpdroot; fi
-
 
87
 
-
 
88
echo " => HTTPd root found : $httpdroot"
77
 
89
 
78
tmpfile=/tmp/wims-apache.conf
90
tmpfile=/tmp/wims-apache.conf
79
vtest=`$httpdname -v | grep Apache`
91
vtest=`$httpdname -v | grep Apache`
80
if [ -z "$vtest" ]; then
92
if [ -z "$vtest" ]; then
81
 echo
93
 echo
Line 84... Line 96...
84
 echo You must configure manually your web server, this script cannot be used.
96
 echo You must configure manually your web server, this script cannot be used.
85
 echo
97
 echo
86
 exit
98
 exit
87
fi
99
fi
88
 
100
 
-
 
101
echo "Config test..."
89
conftest=`grep -i manually_configured_for_wims $conffile`
102
conftest=`grep -i manually_configured_for_wims $conffile`
90
if [ ! -z "$conftest" ]; then
103
if [ ! -z "$conftest" ]; then
91
 echo Manually configured $conffile not modified.
104
 echo Manually configured $conffile not modified.
92
 exit
105
 exit
93
fi
106
fi
Line 123... Line 136...
123
# If you manually add things concerning WIMS into this configuration file,
136
# If you manually add things concerning WIMS into this configuration file,
124
# add them BEFORE the 'WIMS definition start' line.
137
# add them BEFORE the 'WIMS definition start' line.
125
# Otherwise the addition will be erased in next update.
138
# Otherwise the addition will be erased in next update.
126
#
139
#
127
  AddHandler cgi-script .cgi
140
  AddHandler cgi-script .cgi
128
@
141
@
129
 
142
 
130
# $vtest looks like "Server version: Apache/X.Y.Z (Unix)"
143
# $vtest looks like "Server version: Apache/X.Y.Z (Unix)"
131
# $vmajor will be XY
144
# $vmajor will be XY
132
 
-
 
-
 
145
echo "Searching HTTPd major version..."
133
vmajor=`echo $vtest | grep 'pache' | perl -pe 's/.*pache\/([\d]+).([\d]+).*/$1$2/'`
146
vmajor=`echo $vtest | grep 'pache' | perl -pe 's/.*pache\/([\d]+).([\d]+).*/$1$2/'`
-
 
147
 
-
 
148
echo " => HTTPd major version found : $vmajor"
134
 
149
 
135
# Apache version == 1.2
150
# Apache version == 1.2
136
if [ "$vmajor" = "12" ]; then
151
if [ "$vmajor" = "12" ]; then
137
  cat >>$tmpfile <<@
152
  cat >>$tmpfile <<@
138
  ScriptAlias /wims/wims.cgi $wimshome/public_html/wims.cgi
153
  ScriptAlias /wims/wims.cgi $wimshome/public_html/wims.cgi
Line 182... Line 197...
182
 
197
 
183
###### $endl! ######
198
###### $endl! ######
184
@
199
@
185
 
200
 
186
mv $tmpfile $conffile
201
mv $tmpfile $conffile
-
 
202
 
-
 
203
echo  "## WIMS Configuration added to your HTTPd server conf. ##"
187
 
204
 
188
initdir=/etc/init.d
205
initdir=/etc/init.d
189
[ -d $initdir ] || initdir=/etc/rc.d/init.d
206
[ -d $initdir ] || initdir=/etc/rc.d/init.d
190
initscript=$initdir/httpd
207
initscript=$initdir/httpd
191
[ -f $initscript ] || initscript=$initdir/apache
208
[ -f $initscript ] || initscript=$initdir/apache