-
-
Notifications
You must be signed in to change notification settings - Fork 360
/
start.sh
executable file
·191 lines (154 loc) · 7.15 KB
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/bin/sh
set -e
apt-get update -y
export BUILD_NAME=PHP_7.3_WITH_PROJ7
#export PYTHON_VERSION=3.6
export PYTHON_VERSION=system
LANG=en_US.UTF-8
export LANG
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
sudo locales tzdata software-properties-common python3-dev python3-pip python3-setuptools git curl \
apt-transport-https ca-certificates gnupg software-properties-common wget \
php-dev phpunit && \
echo "$LANG UTF-8" > /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=$LANG
USER=root
export USER
# Install pyenv
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
export PATH="/root/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
ln -s /usr/bin/python3 /usr/bin/python
ln -s /usr/bin/pip3 /usr/bin/pip
export CRYPTOGRAPHY_DONT_BUILD_RUST=1 # to avoid issue when building Cryptography python module
pip install --upgrade pip
# Install recent cmake
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
cd "$WORK_DIR"
ci/travis/before_install.sh
ci/travis/script.sh
# Validate openapi document
pip install jsonschema
wget https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.0/schema.json -O openapi_schema.json
echo "Run jsonschema -i msautotest/api/expected/ogcapi_api.json openapi_schema.json"
jsonschema -i msautotest/api/expected/ogcapi_api.json openapi_schema.json
#####################################
# Test MapServer as CGI and FastCGI #
#####################################
make cmakebuild_nocoverage MFLAGS="-j${nproc}"
ln -s mapserv /tmp/install-mapserver/bin/mapserv.cgi
ln -s mapserv /tmp/install-mapserver/bin/mapserv.fcgi
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends apache2 libapache2-mod-fcgid
a2enmod fcgid cgid
a2disconf serve-cgi-bin
a2dissite 000-default
echo "ServerName www.example.com" > /etc/apache2/conf-available/servername.conf
a2enconf servername
cat <<EOF >/etc/apache2/sites-available/001-mapserver.conf
<VirtualHost *:80>
ErrorLog \${APACHE_LOG_DIR}/mapserv-error.log
CustomLog \${APACHE_LOG_DIR}/mapserv-access.log combined
SetEnv MAPSERVER_CONFIG_FILE ${WORK_DIR}/msautotest/etc/mapserv.conf
FcgidInitialEnv MAPSERVER_CONFIG_FILE ${WORK_DIR}/msautotest/etc/mapserv.conf
ScriptAlias /cgi-bin/ "/tmp/install-mapserver/bin/"
<Directory "/tmp/install-mapserver/bin">
AddHandler fcgid-script .fcgi
AddHandler cgi-script .cgi
AllowOverride All
Options +ExecCGI -MultiViews +FollowSymLinks
Order Allow,Deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
EOF
a2ensite 001-mapserver
service apache2 restart
# Prepare mapfile and related resources
cat msautotest/wxs/wfs_simple.map | sed "s/\.\/data\/epsg2/\/tmp\/data\/epsg2/" | sed "s/SHAPEPATH \.\/data/SHAPEPATH \/tmp\/data/" | sed "s/ etc/ \/tmp\/etc/" > /tmp/wfs_simple.map
cp -r $WORK_DIR/msautotest/wxs/data /tmp
cp -r $WORK_DIR/msautotest/wxs/etc /tmp
echo "Running CGI query"
curl -s "http://localhost/cgi-bin/mapserv.cgi?MAP=/tmp/wfs_simple.map&SERVICE=WFS&REQUEST=GetCapabilities" > /tmp/res.xml
cat /tmp/res.xml | grep wfs:WFS_Capabilities >/dev/null || (cat /tmp/res.xml && /bin/false)
echo "Demonstrate that mapserv reject -conf passed through QUERY_STRING env variable"
curl -s "http://localhost/cgi-bin/mapserv.cgi?-conf+bar" > /tmp/res.txt
cat /tmp/res.txt | grep "conf switch cannot be used" >/dev/null || (cat /tmp/res.txt && /bin/false)
echo "Running FastCGI query"
curl -s "http://localhost/cgi-bin/mapserv.fcgi?MAP=/tmp/wfs_simple.map&SERVICE=WFS&REQUEST=GetCapabilities" > /tmp/res.xml
cat /tmp/res.xml | grep wfs:WFS_Capabilities >/dev/null || (cat /tmp/res.xml && /bin/false)
echo "Running FastCGI query again"
curl -s "http://localhost/cgi-bin/mapserv.fcgi?MAP=/tmp/wfs_simple.map&SERVICE=WFS&REQUEST=GetCapabilities" > /tmp/res.xml
cat /tmp/res.xml | grep wfs:WFS_Capabilities >/dev/null || (cat /tmp/res.xml && /bin/false)
cd msautotest/wxs
export PATH=/tmp/install-mapserver/bin:$PATH
# Demonstrate that mapserv will error out if cannot find config file
mapserv 2>&1 | grep "msLoadConfig(): Unable to access file" >/dev/null && echo yes
mapserv QUERY_STRING="MAP=wfs_simple.map&REQUEST=GetCapabilities" 2>&1 | grep "msLoadConfig(): Unable to access file" >/dev/null && echo yes
echo "Check that MS_MAP_NO_PATH works"
cat <<EOF >/tmp/mapserver.conf
CONFIG
ENV
"MS_MAP_NO_PATH" "1"
END
MAPS
"MYMAPFILE" "wfs_simple.map"
END
END
EOF
# Also demonstrate that mapserv can find config file in ${CMAKE_INSTALL_FULL_SYSCONFDIR}/etc/mapserver.conf by default
ln -s /tmp/mapserver.conf /tmp/install-mapserver/etc
mapserv QUERY_STRING="MAP=MYMAPFILE&SERVICE=WFS&REQUEST=GetCapabilities" > /tmp/res.txt
rm /tmp/install-mapserver/etc/mapserver.conf
cat /tmp/res.txt | grep wfs:WFS_Capabilities >/dev/null || (cat /tmp/res.txt && /bin/false)
echo "Check that -conf switch parameter works in a non-CGI context"
mapserv QUERY_STRING="MAP=MYMAPFILE&SERVICE=WFS&REQUEST=GetCapabilities" -conf /tmp/mapserver.conf > /tmp/res.txt
cat /tmp/res.txt | grep wfs:WFS_Capabilities >/dev/null || (cat /tmp/res.txt && /bin/false)
echo "Check that MS_MAP_NO_PATH works (rejecting a value not defined in the MAPS section)"
MAPSERVER_CONFIG_FILE=/tmp/mapserver.conf mapserv QUERY_STRING="MAP=FOO&SERVICE=WFS&REQUEST=GetCapabilities" > /tmp/res.txt
cat /tmp/res.txt | grep "Web application error" >/dev/null || (cat /tmp/res.txt && /bin/false)
echo "Check that MS_MAP_PATTERN works (accepting valid MAP)"
cat <<EOF >/tmp/mapserver.conf
CONFIG
ENV
"MS_MAP_PATTERN" "^wfs_simple\.map$"
END
END
EOF
MAPSERVER_CONFIG_FILE=/tmp/mapserver.conf mapserv QUERY_STRING="MAP=wfs_simple.map&SERVICE=WFS&REQUEST=GetCapabilities" > /tmp/res.txt
cat /tmp/res.txt | grep wfs:WFS_Capabilities >/dev/null || (cat /tmp/res.txt && /bin/false)
echo "Check that MS_MAP_PATTERN works (rejecting invalid MAP)"
cat <<EOF >/tmp/mapserver.conf
CONFIG
ENV
"MS_MAP_PATTERN" "mypatternmapserv"
END
END
EOF
MAPSERVER_CONFIG_FILE=/tmp/mapserver.conf mapserv QUERY_STRING="MAP=wfs_simple.map&SERVICE=WFS&REQUEST=GetCapabilities" > /tmp/res.txt
cat /tmp/res.txt | grep "Web application error" >/dev/null || (cat /tmp/res.txt && /bin/false)
echo "Check that MS_MAPFILE works alone"
cat <<EOF >/tmp/mapserver.conf
CONFIG
ENV
"MS_MAPFILE" "wfs_simple.map"
END
END
EOF
MAPSERVER_CONFIG_FILE=/tmp/mapserver.conf mapserv QUERY_STRING="SERVICE=WFS&REQUEST=GetCapabilities" > /tmp/res.txt
cat /tmp/res.txt | grep wfs:WFS_Capabilities >/dev/null || (cat /tmp/res.txt && /bin/false)
echo "Check that a MAP query parameter isn't accepted when MS_MAPFILE and MS_MAP_NO_PATH are specified"
cat <<EOF >/tmp/mapserver.conf
CONFIG
ENV
"MS_MAPFILE" "wfs_simple.map"
"MS_MAP_NO_PATH" "1"
END
END
EOF
MAPSERVER_CONFIG_FILE=/tmp/mapserver.conf mapserv QUERY_STRING="MAP=wfs_simple.map&SERVICE=WFS&REQUEST=GetCapabilities" > /tmp/res.txt
cat /tmp/res.txt | grep "Web application error" >/dev/null || (cat /tmp/res.txt && /bin/false)
echo "Done !"