aboutsummaryrefslogtreecommitdiff
path: root/www/osrm-backend/files/osrm.in
blob: 93cead6dc50f88b26b1760ea47d68ccc895b1d94 (plain) (blame)
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
#!/bin/sh

# $FreeBSD$

# PROVIDE: osrm
# REQUIRE: LOGIN cleanvar
# KEYWORD: shutdown
#
#
# osrm_enable (bool):		Set to NO by default.
#				Set it to YES to enable osrm-backend.
# osrm_flags (flags):		Empty by default
#				Adjust it to your needs.
# osrm_file (path):		The path to the osrm-file you intend
#				to use with osrm.
# osrm_shared_memory (bool):	Set to NO by default.
#				When enabled it will ignore osrm_file
#				and assume osrm-datastore has set up
#				the data in shared memory.
#				osrm will fail to start if this is
#				enbled and osrm-datastore hasnt set
#                               up the shared memory.

. /etc/rc.subr

name="osrm"
rcvar=${name}_enable
load_rc_config $name

: ${osrm_enable:="NO"}
: ${osrm_user:="osrm"}
: ${osrm_group:="osrm"}
: ${osrm_flags:=""}
: ${osrm_shared_memory:="NO"}
: ${osrm_file:=""}




pidfile="/var/run/osrm.pid"
procname="/usr/local/bin/osrm-routed"
command=/usr/sbin/daemon
start_precmd="osrm_precmd"

osrm_precmd()
{
    if checkyesno osrm_shared_memory; then
        command_args="-f -c -p ${pidfile} ${procname} --shared-memory=yes ${osrm_flags}"
    else
	    
        if [ -f "$osrm_file" ]; then
            chown ${osrm_user}:${osrm_group} ${osrm_file}
            command_args="-f -c -p ${pidfile} ${procname} ${osrm_flags} ${osrm_file}"
        else
	    err 1 "Osrm file not found or osrm_file variable empty."    
        fi
    fi
    install -o $osrm_user -m 644 /dev/null ${pidfile}
}


run_rc_command "$1"