Skip to content

Commit

Permalink
Updated init script for FreeBSD and fix paths after install
Browse files Browse the repository at this point in the history
  • Loading branch information
zloidemon committed Jul 7, 2015
1 parent 4d67cbe commit 6fc7bb3
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 33 deletions.
29 changes: 28 additions & 1 deletion FreeBSD/databases/tarantool/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,30 @@ USE_GCC= 4.9+
USE_LDCONFIG= yes
USE_RC_SUBR= ${PORTNAME}
SUB_FILES= pkg-message

TT_DATADIR?= /var/db/tarantool
TT_RUNDIR?= /var/run/tarantool
TT_LOGDIR?= /var/log/tarantool

CMAKE_ARGS= -DCMAKE_INSTALL_MANDIR=man \
-DCMAKE_INSTALL_SYSCONFDIR=${ETCDIR} \
-DCMAKE_LOCALSTATE_DIR=${DATADIR}
-DCMAKE_LOCALSTATE_DIR=${DATADIR} \
-DTARANTOOL_DATADIR="${TT_DATADIR}"

USERS= tarantool
GROUPS= tarantool

SUB_LIST+= PORTNAME=${PORTNAME} \
TT_USER=${USERS} \
TT_DATADIR=${TT_DATADIR} \
TT_LOGDIR=${TT_LOGDIR} \
TT_RUNDIR=${TT_RUNDIR}

PLIST_SUB+= TT_USER=${USERS} \
TT_GROUP=${GROUPS} \
TT_LOGDIR=${TT_LOGDIR} \
TT_DATADIR=${TT_DATADIR} \
TT_RUNDIR=${TT_RUNDIR}

OPTIONS_DEFINE= DEBUG
DEBUG_DESC= Enable debug
Expand All @@ -40,4 +61,10 @@ CMAKE_ARGS+= -DENABLE_BACKTRACE=OFF
BROKEN= Does not build on FreeBSD < 9.0
.endif

post-install:
${MKDIR} ${STAGEDIR}${TT_LOGDIR} \
${STAGEDIR}${TT_DATADIR} \
${STAGEDIR}${TT_RUNDIR} \
${STAGEDIR}${ETCDIR}/instances.enabled

.include <bsd.port.mk>
7 changes: 2 additions & 5 deletions FreeBSD/databases/tarantool/files/pkg-message.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
#
# * Enable tarantool on startup:
# tarantool_enable="YES"
# * Change config (Default %%ETCDIR%%/default/tarantool):
# tarantool_config="%%ETCDIR%%/default/tarantool"
# * Path to storage, depended by option work_dir at:
# %%ETCDIR%%/default/tarantool
# tarantool_data="/var/db/tarantool"
# * Path to storage instances:
# tarantool_instances="%%ETCDIR%%/instances.enabled"
#
#
#########################################################
56 changes: 29 additions & 27 deletions FreeBSD/databases/tarantool/files/tarantool.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
# KEYWORD: shutdown
#
# tarantool_enable="YES"
# tarantool_config=""
# tarantool_data="/var/db/tarantool"
# tarantool_instances=""
#

. /etc/rc.subr
Expand All @@ -19,35 +18,38 @@ 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"}
tarantool_instances=${tarantool_instances:-"%%ETCDIR%%/instances.enabled"}

command="%%PREFIX%%/bin/tarantool_box"
command_args="--config=${tarantool_config} --background"
pidfile="/var/run/$name.pid"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
restart_cmd="${name}_restart"

start_precmd="${name}_prestart"
INSTANCES=$(find ${tarantool_instances} -type f -name '*.lua')
TDAEMON=%%PREFIX%%/bin/tarantool
TCTL=%%PREFIX%%/bin/tarantoolctl

tarantool_prestart()
tarantool_start()
{
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
echo "tarantool: Starting instances"
for inst in ${INSTANCES}
do
${TDAEMON} ${TCTL} start $(basename ${inst} .lua)
done
}

tarantool_stop()
{
echo "tarantool: Stopping instances"
for inst in ${INSTANCES}
do
${TDAEMON} ${TCTL} stop $(basename ${inst} .lua)
done
}

tarantool_restart()
{
tarantool_stop
tarantool_start
}

run_rc_command "$1"
4 changes: 4 additions & 0 deletions FreeBSD/databases/tarantool/pkg-plist
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ man/man1/tarantool.1.gz
man/man1/tarantoolctl.1.gz
%%PORTDOCS%%%%DOCSDIR%%/LICENSE
%%PORTDOCS%%%%DOCSDIR%%/README.md
@dir %%ETCDIR%%/instances.enabled
@dir(%%TT_USER%%,%%TT_GROUP%%,) %%TT_DATADIR%%
@dir(%%TT_USER%%,%%TT_GROUP%%,) %%TT_LOGDIR%%
@dir(%%TT_USER%%,%%TT_GROUP%%,) %%TT_RUNDIR%%

0 comments on commit 6fc7bb3

Please sign in to comment.