-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathProvisiofile
More file actions
122 lines (104 loc) · 4.2 KB
/
Provisiofile
File metadata and controls
122 lines (104 loc) · 4.2 KB
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
#task declare_list_of_map_files_to_download always
# Modify this list depending on what you want to import
declare -a MAP_URLS=(
"http://download.geofabrik.de/europe/ireland-and-northern-ireland-180125.osm.pbf"
"http://download.geofabrik.de/europe/great-britain-180125.osm.pbf"
)
#end
#task install_docker once
provisio install yum yum-utils
provisio install yum device-mapper-persistent-data
provisio install yum lvm2
provisio download https://download.docker.com/linux/centos/docker-ce.repo
yum-config-manager --add-repo /tmp/docker-ce.repo
provisio install rpm-key docker-ce https://download.docker.com/linux/centos/gpg
provisio install yum docker-ce
systemctl enable docker
systemctl start docker
#end
#task install_docker_compose once
provisio install yum curl
provisio download https://github.com/docker/compose/releases/download/1.19.0-rc1/docker-compose-`uname -s`-`uname -m`
mv /tmp/docker-compose-`uname -s`-`uname -m` /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
#end
#task pull_docker_images once
provisio install docker chatelao/docker-postgres-osm
provisio install docker smartroadsense/osm-tiles
provisio install docker openfirmware/osm2pgsql:0.87.2
provisio install docker bwindsor/osm-pbf-merger:v1.0
#end
#task download_map_data always
mkdir -p /tmp/map-data
## now loop through the above array, downloading the files and moving them to /tmp/map-data
MAP_FILE_LIST=""
for i in "${MAP_URLS[@]}"
do
provisio download "$i"
MAP_FILE_NAME=$(basename "$i")
mv "/tmp/$MAP_FILE_NAME" /tmp/map-data
MAP_FILE_LIST="$MAP_FILE_LIST $MAP_FILE_NAME"
done
#end
#task clone_this_repo once
# This will clone into /tmp/osm-server
provisio pull --no-up bwindsor/osm-server
#end
#task pull_this_repo_latest_changes always if UPDATING_REPO
provisio pull -f --no-up bwindsor/osm-server
#end
# ----- END OF TASKS REQUIRING AN INTERNET CONNECTION ----- #
#task setup_code_path always
CODE_REPO_PATH=/tmp/osm-server
#end
#task open_port_80 once
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
#end
#task merge_map_data always unless NO_MAP_IMPORT
# Merge the list of files downloaded earlier
docker run -it --rm -v /tmp/map-data:/data bwindsor/osm-pbf-merger:v1.0 $MAP_FILE_LIST -o merged.osm.pbf
#end
#task create_tileserver_user once
useradd -M -G docker tileserver
# Assign code ownership to tileserver
chown -R tileserver:tileserver "$CODE_REPO_PATH"
#end
#task install_tile_systemd_service once
pushd "$CODE_REPO_PATH"
cp service/tile-server.service /etc/systemd/system/tile-server.service
chmod 664 /etc/systemd/system/tile-server.service
popd
# Get systemd to reload the latest configurations
systemctl daemon-reload
# Make the tile server run at start up
systemctl enable tile-server.service
#end
#task start_tile_server always
# Restart (or start) the service twice, because if the configuration has changed it doesn't always work the first time
systemctl restart tile-server.service
sleep 15s
systemctl restart tile-server.service
#end
#task import_map_data always unless NO_MAP_IMPORT
export IMPORT_FROM=/tmp/map-data
export IMPORT_FILE=merged.osm.pbf
pushd "$CODE_REPO_PATH"
docker-compose -f docker-compose-importer.yml run --rm data-importer
popd
sleep 1s
#end
#task restart_tile_server always
systemctl restart tile-server.service
#end
#task clear_cached_tiles always unless NO_MAP_IMPORT
TILE_CONTAINER_ID=$(docker ps | grep tile-server | awk '{print $1;}')
docker exec -it $TILE_CONTAINER_ID rm -rf /var/lib/mod_tile/default
#end
#task prerender_tiles always
# Note this task does nothing if prerendering has already been done, it doesn't matter that we are rerunning it
TILE_CONTAINER_ID=$(docker ps | grep tile-server | awk '{print $1;}')
# Uncomment the following line and change the arguments to render the areas you require.
# For multiple areas, just copy and paste the line so it runs for each area
# docker exec -it $TILE_CONTAINER_ID render_list_geo -z 0 -Z 15 -x -8 -X 1.8 -y 49.8 -Y 60.9
#end