Import net/stone version 2.3e
[dports.git] / net / stone / files / stone.in
1 #!/bin/sh
2
3 # $FreeBSD: ports/net/stone/files/stone.in,v 1.2 2012/11/17 06:00:22 svnexp Exp $
4 #
5 # PROVIDE: stone
6 # REQUIRE: DAEMON
7 # BEFORE: LOGIN
8 # KEYWORD: shutdown
9 #
10 # Add the following line to /etc/rc.conf to enable stone:
11 # stone_enable (bool):          Set it to "YES" to enable stone.
12 #                               Default: NO
13 # Add at least one of the followings to /etc/rc.conf to give rules to stone:
14 # stone_flags (str):            See stone(1).
15 #                               Default: "" (-D will be added automatically)
16 # stone_conffile (str):         Stone config file
17 #                               Default: ""
18
19 . /etc/rc.subr
20
21 name="stone"
22 rcvar=stone_enable
23
24 command="%%PREFIX%%/bin/stone"
25 start_precmd="stone_precmd"
26 restart_precmd="stone_precmd"
27
28 stone_enable=${stone_enable:-"NO"}
29
30 load_rc_config $name
31
32 stone_precmd()
33 {
34     if [ -z "${stone_flags}" -a -z "${stone_conffile}" ]; then
35         warn "set at least stone_flags or stone_conffile."
36         return 1
37     fi
38
39     # doesn't use required_files because stone accepts only one conffile
40     if [ -n "${stone_conffile}" ]; then
41         if [ ! -r "${stone_conffile}" ]; then
42             warn "${stone_conffile} is not readable."
43             if [ -n "$stone_conffile" -a -n "$rc_force" ]; then
44                 warn "start without ${stone_conffile} anyway."
45             else
46                 return 1
47             fi
48         else
49             rc_flags="-C ${stone_conffile} ${rc_flags}"
50         fi
51     fi
52
53     # make sure daemonize option will be given
54     rc_flags="-D ${rc_flags}"
55 }
56
57 run_rc_command "$1"