-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-osrm-config.sh
executable file
·69 lines (50 loc) · 1.46 KB
/
build-osrm-config.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
#!/bin/bash
die () {
echo "$@"
exit 1
}
if [ "$#" -ne 2 ]
then
die "Usage: build-osrm-config profile.lua port"
fi
if [ ! -d /opt/Project-OSRM ]
then
cd /opt || die cant cd to /opt
git clone https://github.com/DennisOSRM/Project-OSRM.git
git checkout -b v0.3.5 v0.3.5
fi
filename=${1##*/}
soloname=${filename%.*}
dirname="/opt/${soloname}"
echo "killing server instance running...."
kill -9 $(cat /opt/${soloname}/osrm-routed.pid)
while kill -0 $(cat /opt/${soloname}/osrm-routed.pid); do
echo "killing server instance waiting to shutdown...."
sleep 0.5
done
echo create dir $dirname
mkdir -pv $dirname || die cant create directory $dirname
cd $dirname || die cant cd to $dirname
builddir=$dirname/build
cp -a /opt/Project-OSRM/* $dirname/ || die
mkdir -pv $builddir || die
cd $builddir
cp -av /opt/Project-OSRM/profiles $builddir/ || die
cp -av /opt/maps/ref-map.osm.bz2 $builddir/map.osm.bz2 || die
cp -av $1 $builddir/profile.lua || die
$builddir/osrm-extract map.osm.bz2
$builddir/osrm-prepare map.osrm
cat <<EOF > server.ini || die
Threads = 7
IP = 0.0.0.0
Port = $2
hsgrData=${builddir}/map.osrm.hsgr
nodesData=${builddir}/map.osrm.nodes
edgesData=${builddir}/map.osrm.edges
ramIndex=${builddir}/map.osrm.ramIndex
fileIndex=${builddir}/map.osrm.fileIndex
namesData=${builddir}/map.osrm.names
timestamp=${builddir}/map.osrm.timestamp
EOF
nohup 2>&1 $builddir/osrm-routed & echo $! > /opt/${soloname}/osrm-routed.pid | logger -t osrm-indus
exit 0