Line 0
Link Here
|
|
|
1 |
#!/bin/sh |
2 |
|
3 |
# PROVIDE: osrm |
4 |
# REQUIRE: LOGIN cleanvar |
5 |
# KEYWORD: shutdown |
6 |
# |
7 |
# |
8 |
# osrm_enable (bool): Set to NO by default. |
9 |
# Set it to YES to enable osrm-backend. |
10 |
# osrm_flags (flags): Empty by default |
11 |
# Adjust it to your needs. |
12 |
# osrm_file (path): The path to the osrm-file you intend |
13 |
# to use with osrm. |
14 |
# osrm_shared_memory (bool): Set to NO by default. |
15 |
# When enabled it will ignore osrm_file |
16 |
# and assume osrm-datastore has set up |
17 |
# the data in shared memory. |
18 |
# osrm will fail to start if this is |
19 |
# enbled and osrm-datastore hasnt set |
20 |
# up the shared memory. |
21 |
|
22 |
. /etc/rc.subr |
23 |
|
24 |
name="osrm" |
25 |
rcvar=${name}_enable |
26 |
load_rc_config $name |
27 |
|
28 |
: ${osrm_enable:="NO"} |
29 |
: ${osrm_user:="osrm"} |
30 |
: ${osrm_group:="osrm"} |
31 |
: ${osrm_flags:=""} |
32 |
: ${osrm_shared_memory:="NO"} |
33 |
: ${osrm_file:=""} |
34 |
|
35 |
|
36 |
|
37 |
|
38 |
pidfile="/var/run/osrm.pid" |
39 |
procname="/usr/local/bin/osrm-routed" |
40 |
command=/usr/sbin/daemon |
41 |
start_precmd="osrm_precmd" |
42 |
|
43 |
osrm_precmd() |
44 |
{ |
45 |
if checkyesno osrm_shared_memory; then |
46 |
command_args="-f -c -p ${pidfile} ${procname} --shared-memory=yes ${osrm_flags}" |
47 |
else |
48 |
|
49 |
if [ -f "$osrm_file" ]; then |
50 |
chown ${osrm_user}:${osrm_group} ${osrm_file} |
51 |
command_args="-f -c -p ${pidfile} ${procname} ${osrm_flags} ${osrm_file}" |
52 |
else |
53 |
err 1 "Osrm file not found or osrm_file variable empty." |
54 |
fi |
55 |
fi |
56 |
install -o $osrm_user -m 644 /dev/null ${pidfile} |
57 |
} |
58 |
|
59 |
|
60 |
run_rc_command "$1" |