#!/bin/sh

# This systemd generator creates dependency symlinks that make all Tarantool
# instances in @TARANTOOL_ENABLEDDIR@ be started/stopped/reloaded
# when tarantool.service is started/stopped/reloaded.

set -eu

wantdir="$1/tarantool.service.wants"
service="@SYSTEMD_UNIT_DIR@/tarantool@.service"

mkdir -p "$wantdir"

for file in @TARANTOOL_ENABLEDDIR@/*.lua; do
	instance=`basename $file .lua`
	[ "${instance}" = "*" ] && break  # skip empty directory
	ln -s "$service" "$wantdir/tarantool@$instance.service"
done

exit 0
