aboutsummaryrefslogtreecommitdiff
path: root/net/stone/files/stone.sh.in
blob: 1f93e4392551ea99a730d61d7080229deb990e76 (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
#!/bin/sh

# PROVIDE: stone
# REQUIRE: DAEMON
# BEFORE: LOGIN
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf to enable stone:
# stone_enable (bool):		Set it to "YES" to enable stone.
#				Default: NO

# Add at least one of the followings to /etc/rc.conf to give rules to stone:
# stone_flags (str):		See stone(1).
#				Default: "" (-D will be added automatically)
# stone_conffile (str):		Stone config file
#				Default: ""
#

. %%RC_SUBR%%

name="stone"
rcvar=`set_rcvar`

command="%%PREFIX%%/bin/stone"
start_precmd="stone_precmd"
restart_precmd="stone_precmd"

stone_enable=${stone_enable:-"NO"}

load_rc_config $name

stone_precmd()
{
    if [ -z "${stone_flags}" -a -z "${stone_conffile}" ]; then
        warn "set at least stone_flags or stone_conffile."
	return 1
    fi

    # doesn't use required_files because stone accepts only one conffile
    if [ -n "${stone_conffile}" ]; then
        if [ ! -r "${stone_conffile}" ]; then
            warn "${stone_conffile} is not readable."
            if [ -n "$stone_conffile" -a -n "$rc_force" ]; then
		warn "start without ${stone_conffile} anyway."
	    else
	        return 1
	    fi
        else
            rc_flags="-C ${stone_conffile} ${rc_flags}"
	fi
    fi

    # make sure daemonize option will be given
    rc_flags="-D ${rc_flags}"
}

run_rc_command "$1"