Lines 2-8
Link Here
|
2 |
# $FreeBSD$ |
2 |
# $FreeBSD$ |
3 |
|
3 |
|
4 |
# PROVIDE: litecoind |
4 |
# PROVIDE: litecoind |
5 |
# REQUIRE: DAEMON cleanvar |
5 |
# REQUIRE: LOGIN cleanvar |
6 |
# KEYWORD: shutdown |
6 |
# KEYWORD: shutdown |
7 |
|
7 |
|
8 |
# |
8 |
# |
Lines 10-62
Link Here
|
10 |
# litecoind_enable (bool): Set to "NO" by default. |
10 |
# litecoind_enable (bool): Set to "NO" by default. |
11 |
# Set it to "YES" to enable litecoind |
11 |
# Set it to "YES" to enable litecoind |
12 |
# litecoind_user (str) Set to "litecoin" by default. |
12 |
# litecoind_user (str) Set to "litecoin" by default. |
13 |
# Set it to preferred user |
|
|
14 |
# litecoind_group (str) Set to "litecoin" by default. |
13 |
# litecoind_group (str) Set to "litecoin" by default. |
15 |
# Set it to preferred group |
14 |
# litecoind_conf (str) Set to "%%PREFIX%%/etc/litecoind.conf" by default. |
16 |
# litecoind_data_dir (str) Set to "/var/lib/litecoin" by default. |
15 |
# litecoind_data_dir (str) Set to "/var/db/litecoin" by default. |
17 |
# Set it to preferred data dir |
16 |
# litecoindlimits_enable (bool) Set to "NO" by default. |
18 |
# litecoind_config_file (str) Set to "%%PREFIX%%/etc/litecoind.conf" by default. |
17 |
# Set it to "YES" to enable litecoindlimits |
19 |
# Set it to preferred config file |
18 |
# litecoindlimits_args Set to "-e -U ${litecoind_user}" by default |
20 |
# litecoind_log_file (str) Set to "/var/log/litecoind.log" by default. |
|
|
21 |
# Set it to preferred log file |
22 |
|
19 |
|
|
|
20 |
|
23 |
. /etc/rc.subr |
21 |
. /etc/rc.subr |
24 |
|
22 |
|
25 |
name=litecoind |
23 |
name="litecoind" |
26 |
desc="Litecoin Daemon" |
|
|
27 |
rcvar=litecoind_enable |
24 |
rcvar=litecoind_enable |
28 |
|
25 |
|
|
|
26 |
start_precmd="litecoind_precmd" |
27 |
start_cmd="litecoind_start" |
28 |
restart_precmd="litecoind_checkconfig" |
29 |
reload_precmd="litecoind_checkconfig" |
30 |
configtest_cmd="litecoind_checkconfig" |
31 |
status_cmd="litecoind_status" |
32 |
stop_cmd="litecoind_stop" |
33 |
stop_postcmd="litecoind_wait" |
34 |
command="%%PREFIX%%/bin/litecoind" |
35 |
daemon_command="/usr/sbin/daemon" |
36 |
#pidfile="/var/run/${name}.pid" |
37 |
extra_commands="configtest" |
38 |
|
39 |
|
40 |
: ${litecoind_enable:="NO"} |
41 |
: ${litecoindlimits_enable:="NO"} |
42 |
|
29 |
load_rc_config ${name} |
43 |
load_rc_config ${name} |
30 |
|
44 |
|
31 |
: ${litecoind_enable:=NO} |
45 |
: ${litecoind_user:="litecoin"} |
32 |
: ${litecoind_user:=litecoin} |
46 |
: ${litecoind_group:="litecoin"} |
33 |
: ${litecoind_group:=litecoin} |
47 |
: ${litecoind_data_dir:="/var/db/litecoin"} |
34 |
: ${litecoind_data_dir:=/var/db/litecoin} |
48 |
: ${litecoind_config_file:="%%PREFIX%%/etc/litecoin.conf"} |
35 |
: ${litecoind_config_file:=%%PREFIX%%/etc/litecoin.conf} |
49 |
: ${litecoindlimits_args:="-e -U ${litecoind_user}"} |
36 |
: ${litecoind_log_file:=/var/log/litecoind.log} |
|
|
37 |
|
50 |
|
|
|
51 |
# set up dependant variables |
52 |
procname="${command}" |
53 |
pidfile="${litecoind_data_dir}/litecoind.pid" |
38 |
required_files="${litecoind_config_file}" |
54 |
required_files="${litecoind_config_file}" |
39 |
litecoind_chdir="${litecoind_data_dir}" |
|
|
40 |
litecoind_env="HOME=${litecoind_data_dir}" |
41 |
pidfile="/var/run/${name}.pid" |
42 |
command="%%PREFIX%%/bin/litecoind" |
43 |
command_args="-daemon -pid=${pidfile} -conf=${litecoind_config_file} -datadir=${litecoind_data_dir} > ${litecoind_log_file} 2>&1" |
44 |
|
55 |
|
45 |
start_precmd=litecoind_startprecmd |
|
|
46 |
|
56 |
|
47 |
litecoind_startprecmd() |
57 |
litecoind_checkconfig() |
48 |
{ |
58 |
{ |
49 |
if [ ! -e ${pidfile} ]; then |
59 |
echo "Performing sanity check on litecoind configuration:" |
50 |
install -o ${litecoind_user} -g ${litecoind_group} /dev/null ${pidfile}; |
60 |
if [ ! -d "${litecoind_data_dir}" ] |
51 |
fi |
61 |
then |
|
|
62 |
echo "Missing data directory: ${litecoind_data_dir}" |
63 |
exit 1 |
64 |
fi |
65 |
chown -R "${litecoind_user}:${litecoind_group}" "${litecoind_data_dir}" |
52 |
|
66 |
|
53 |
if [ ! -e ${litecoind_log_file} ]; then |
67 |
if [ ! -f "${litecoind_config_file}" ] |
54 |
install -o ${litecoind_user} -g ${litecoind_group} /dev/null ${litecoind_log_file}; |
68 |
then |
55 |
fi |
69 |
echo "Missing configuration file: ${litecoind_config_file}" |
|
|
70 |
exit 1 |
71 |
fi |
72 |
if [ ! -x "${command}" ] |
73 |
then |
74 |
echo "Missing executable: ${command}" |
75 |
exit 1 |
76 |
fi |
77 |
return 0 |
78 |
} |
56 |
|
79 |
|
57 |
if [ ! -d ${litecoind_data_dir} ]; then |
80 |
litecoind_cleanup() |
58 |
install -d -o ${litecoind_user} -g ${litecoind_group} ${litecoind_data_dir} |
81 |
{ |
59 |
fi |
82 |
rm -f "${pidfile}" |
60 |
} |
83 |
} |
61 |
|
84 |
|
|
|
85 |
litecoind_precmd() |
86 |
{ |
87 |
litecoind_checkconfig |
88 |
|
89 |
pid=$(check_pidfile "${pidfile}" "${procname}") |
90 |
if [ -z "${pid}" ] |
91 |
then |
92 |
echo "Litecoind is not running" |
93 |
rm -f "${pidfile}" |
94 |
fi |
95 |
|
96 |
if checkyesno litecoindlimits_enable |
97 |
then |
98 |
eval $(/usr/bin/limits ${litecoindlimits_args}) 2>/dev/null |
99 |
else |
100 |
return 0 |
101 |
fi |
102 |
} |
103 |
|
104 |
litecoind_status() |
105 |
{ |
106 |
local pid |
107 |
pid=$(check_pidfile "${pidfile}" "${procname}") |
108 |
if [ -z "${pid}" ] |
109 |
then |
110 |
echo "Litecoind is not running" |
111 |
return 1 |
112 |
else |
113 |
echo "Litecoind running, pid: ${pid}" |
114 |
fi |
115 |
} |
116 |
|
117 |
litecoind_start() |
118 |
{ |
119 |
echo "Starting litecoind:" |
120 |
cd "${litecoind_data_dir}" || return 1 |
121 |
${daemon_command} -u "${litecoind_user}" -p "${pidfile}" -f \ |
122 |
${command} \ |
123 |
-conf="${litecoind_config_file}" \ |
124 |
-datadir="${litecoind_data_dir}" |
125 |
} |
126 |
|
127 |
litecoind_stop() |
128 |
{ |
129 |
echo "Stopping litecoind:" |
130 |
pid=$(check_pidfile "${pidfile}" "${procname}") |
131 |
if [ -z "${pid}" ] |
132 |
then |
133 |
echo "Litecoind is not running" |
134 |
return 1 |
135 |
else |
136 |
kill ${pid} |
137 |
fi |
138 |
} |
139 |
|
140 |
litecoind_wait() |
141 |
{ |
142 |
local n=60 |
143 |
echo "Waiting for litecoind shutdown:" |
144 |
while : |
145 |
do |
146 |
printf '.' |
147 |
pid=$(check_pidfile "${pidfile}" "${procname}") |
148 |
if [ -z "${pid}" ] |
149 |
then |
150 |
printf '\n' |
151 |
break |
152 |
fi |
153 |
sleep 1 |
154 |
n=$((${n} - 1)) |
155 |
if [ ${n} -eq 0 -a -f "${pidfile}" ] |
156 |
then |
157 |
printf "\nForce shutdown" |
158 |
kill -9 $(cat "${pidfile}") |
159 |
for n in 1 2 3 |
160 |
do |
161 |
printf '.' |
162 |
sleep 1 |
163 |
done |
164 |
printf '\n' |
165 |
break |
166 |
fi |
167 |
done |
168 |
rm -f "${pidfile}" |
169 |
echo "Shutdown complete" |
170 |
} |
171 |
|
62 |
run_rc_command "$1" |
172 |
run_rc_command "$1" |