Remove UPNP support & do some cleanup.
[novacoin.git] / contrib / initscripts / bsd / novacoin
1 #!/bin/sh
2
3 # PROVIDE: novacoin
4 # REQUIRE: LOGIN
5 # KEYWORD: shutdown
6
7 #
8 # Add the following lines to /etc/rc.conf.local or /etc/rc.conf
9 # to enable this service:
10 #
11 # novacoin_enable (bool): Set to NO by default. Set this variable to YES if you want to enable novacoin service.
12 # novacoin_config (path): Set to /usr/local/etc/novacoin.conf by default.
13 # novacoin_user:  The user account novacoin daemon runs as. It uses 'root' user by default.
14 # novacoin_group: The group account novacoin daemon runs as. It uses 'wheel' group by default.
15 # novacoin_datadir (str): Default to "/var/db/novacoin". Base data directory.
16
17 . /etc/rc.subr
18
19 name=novacoin
20 rcvar=novacoin_enable
21
22 : ${novacoin_enable:=NO}
23 : ${novacoin_config=/usr/local/etc/novacoin.conf}
24 : ${novacoin_datadir=/var/db/novacoin}
25 : ${novacoin_user="root"}
26 : ${novacoin_group="wheel"}
27
28 required_files=${novacoin_config}
29 command=/usr/local/bin/novacoind
30 novacoin_chdir=${novacoin_datadir}
31 pidfile="${novacoin_datadir}/novacoind.pid"
32 stop_cmd=novacoin_stop
33 command_args="-conf=${novacoin_config} -datadir=${novacoin_datadir} -daemon -pid=${pidfile}"
34 start_precmd="${name}_prestart"
35
36 novacoin_create_datadir()
37 {
38         echo "Creating data directory"
39         eval mkdir -p ${novacoin_datadir}
40         [ $? -eq 0 ] && chown -R ${novacoin_user}:${novacoin_group} ${novacoin_datadir}
41 }
42
43 novacoin_prestart()
44 {
45         if [ ! -d "${novacoin_datadir}/." ]; then
46                 novacoin_create_datadir || return 1
47         fi
48 }
49
50 novacoin_requirepidfile()
51 {
52         if [ ! "0`check_pidfile ${pidfile} ${command}`" -gt 1 ]; then
53                 echo "${name} not running? (check $pidfile)."
54                 exit 1
55         fi
56 }
57
58 novacoin_stop()
59 {
60     novacoin_requirepidfile
61
62         echo "Stopping ${name}."
63         eval ${command} -conf=${novacoin_config} -datadir=${novacoin_datadir} stop
64         wait_for_pids ${rc_pid}
65 }
66
67 load_rc_config $name
68 run_rc_command "$1"