summaryrefslogtreecommitdiff
path: root/databases/tarantool/files/tarantool.in
blob: 12500db02a183dda4d8b44fa3ad55637a491b998 (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
#!/bin/sh
#
# $FreeBSD$

# PROVIDE: tarantool
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# tarantool_enable="YES"
# tarantool_config=""
# tarantool_data="/var/db/tarantool"
#

. /etc/rc.subr

name="tarantool"
rcvar=tarantool_enable

load_rc_config "$name"

tarantool_enable=${tarantool_enable:-"NO"}
tarantool_config=${tarantool_config:-"%%ETCDIR%%/$name.cfg"}
tarantool_data=${tarantool_data:-"/var/db/tarantool"}

command="%%PREFIX%%/bin/tarantool_box"
command_args="--config=${tarantool_config} --background"
pidfile="/var/run/$name.pid"

start_precmd="${name}_prestart"

tarantool_prestart()
{
	if ! [ -d ${tarantool_data} ]
	then
		eval mkdir -p ${tarantool_data}
	fi

	if ! [ -f "${tarantool_data}/00000000000000000001.snap" ]
	then
		if ! [ -f ${tarantool_config} ]
		then
			echo "===> Install default config file."
			eval cp "%%ETCDIR%%/tarantool.cfg.sample" ${tarantool_config}
			echo "===> Install default snapshot."
			eval cp "%%DATADIR%%/00000000000000000001.snap" ${tarantool_data}
		else
			echo "===> Init tarantool storage by ${tarantool_config}"
			eval ${command} --config=${tarantool_config} --init-storage
		fi
	fi
}

run_rc_command "$1"