Line 0
Link Here
|
|
|
1 |
#!/bin/sh |
2 |
|
3 |
# $FreeBSD$ |
4 |
# |
5 |
# PROVIDE: cockroach |
6 |
# REQUIRE: LOGIN |
7 |
# KEYWORD: shutdown |
8 |
# |
9 |
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf |
10 |
# to enable this service: |
11 |
# |
12 |
# cockroach_enable (bool): Set to NO by default. |
13 |
# Set it to YES to enable cockroach. |
14 |
# cockroach_user (user): Set user to run cockroach. |
15 |
# Default is "cockroach". |
16 |
# cockroach_group (group): Set group to run cockroach. |
17 |
# Default is "cockroach". |
18 |
# cockroach_dir (dir): Set dir to run cockroach in. |
19 |
# Default is "path=/var/db/cockroach". |
20 |
# cockroach_flags (string): Set additional flags with which to run cockroach. |
21 |
# Default is "--insecure --host=localhost". |
22 |
|
23 |
. /etc/rc.subr |
24 |
|
25 |
name=cockroach |
26 |
rcvar=cockroach_enable |
27 |
|
28 |
load_rc_config $name |
29 |
|
30 |
: ${cockroach_enable:="NO"} |
31 |
: ${cockroach_user:="cockroach"} |
32 |
: ${cockroach_group:="cockroach"} |
33 |
: ${cockroach_dir:="/var/db/cockroachdb"} |
34 |
: ${cockroach_store:="--store=path=${cockroach_dir}"} |
35 |
: ${cockroach_flags:="--insecure --host=localhost"} |
36 |
|
37 |
start_precmd=cockroach_startprecmd |
38 |
start_cmd=${name}_start |
39 |
stop_cmd=${name}_stop |
40 |
|
41 |
pidfile=/var/run/cockroach.pid |
42 |
command="%%PREFIX%%/bin/cockroach" |
43 |
|
44 |
cockroach_startprecmd() |
45 |
{ |
46 |
if [ ! -e ${pidfile} ]; then |
47 |
install -o ${cockroach_user} -g ${cockroach_group} /dev/null ${pidfile}; |
48 |
fi |
49 |
|
50 |
if [ ! -d ${cockroach_dir} ]; then |
51 |
install -d -o ${cockroach_user} -g ${cockroach_group} ${cockroach_dir} |
52 |
fi |
53 |
} |
54 |
|
55 |
cockroach_start() { |
56 |
/usr/sbin/daemon -u ${cockroach_user} \ |
57 |
-p $pidfile ${command} \ |
58 |
start \ |
59 |
${cockroach_store} \ |
60 |
${cockroach_flags} |
61 |
} |
62 |
|
63 |
cockroach_stop() { |
64 |
[ -f $pidfile ] \ |
65 |
&& ${command} quit --insecure \ |
66 |
|| echo ${name} not running? \(check ${pidfile}\) |
67 |
} |
68 |
|
69 |
run_rc_command "$1" |