forked from cccs-web/soc-maps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.sh
executable file
·95 lines (78 loc) · 2.93 KB
/
functions.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
#!/bin/bash
# Configurable options (though we recommend not changing these)
POSTGIS_PORT=6001
POSTGIS_CONTAINER_NAME=cccs-postgis-public
QGIS_SERVER_PORT=6003
QGIS_SERVER_CONTAINER_NAME=cccs-qgis-server-public
# -------------------------
function restart_postgis_server {
echo "Starting docker postgis container for public data"
echo "-------------------------------------------------"
# too dodgy? - docker container needs read access to these files
chmod -R a+rX ${DATA_PATH}
docker kill ${POSTGIS_CONTAINER_NAME}
docker rm ${POSTGIS_CONTAINER_NAME}
docker run \
--restart="always" \
--name="${POSTGIS_CONTAINER_NAME}" \
--hostname="${POSTGIS_CONTAINER_NAME}" \
-p ${POSTGIS_PORT}:5432 \
-d -t \
kartoza/postgis
#-e USERNAME=${USER} \
#-e PASS=${PASSWORD}\
# Todo: prevent multiple entries in pgpass
echo "localhost:${POSTGIS_PORT}:*:${USER}:${PASSWORD}" >> ~/.pgpass
sleep 90
}
function restart_qgis_server {
echo "Running QGIS server"
echo "-------------------"
WEB_DIR=`pwd`/web
chmod -R a+rX ${WEB_DIR}
docker kill ${QGIS_SERVER_CONTAINER_NAME}
docker rm ${QGIS_SERVER_CONTAINER_NAME}
docker run \
--restart="always" \
--name="${QGIS_SERVER_CONTAINER_NAME}" \
--hostname="${QGIS_SERVER_CONTAINER_NAME}" \
--link ${POSTGIS_CONTAINER_NAME}:${POSTGIS_CONTAINER_NAME} \
-d -t \
-v ${WEB_DIR}:/web \
-p ${QGIS_SERVER_PORT}:80 \
kartoza/qgis-server
echo "You can now consume WMS services at this url"
echo "http://localhost:${QGIS_SERVER_PORT}/cgi-bin/qgis_mapserv.fcgi?map=/web/cccs_public.qgs"
}
function install_dependencies {
echo "Checking for docker installation"
echo "---------------------------------"
if dpkg -l | grep "docker.io" > /dev/null
then
echo "You have the ubuntu docker package, please install the upstream"
echo "official docker packages rather."
echo "After removing docker.io package from ubuntu simply rerun this "
echo "script and it will be installed:"
exit
fi
if dpkg -l | grep "lxc-docker" > /dev/null
then
echo "Upstream docker installation found, great!"
else
echo "You need to have docker installed before you run this script."
echo "We will install docker from the upstream repo for you, please"
echo "enter your sudo password when prompted."
curl -sSL https://get.docker.io/ubuntu/ | sudo sh
fi
echo "Checking for gdal installation"
echo "------------------------------"
if dpkg -l | grep "gdal-bin" > /dev/null
then
echo "GDAL found, great!"
else
echo "You need to have gdal installed before you run this script."
echo "We will install gdal-bin from the ubuntu repos for you, please"
echo "enter your sudo password when prompted."
sudo apt-get install gdal-bin
fi
}