1
0
forked from bip/bip
bip/systemd/bip_env.sh
Pierre-Louis Bonicoli 3f4a260a54
Add systemd unit files
Largely inspired by https://lwn.net/Articles/584175/
"They must be suitable for every distribution to use."

Packagers must define:
- ExecStart=/path/to/bip_env.sh
- Environment=BIP_DEFAULT_CONFIG='/path/to/default/bip'
using a unit file drop-in bip-config.service.d/<distrib>.conf
2018-02-19 19:56:37 +01:00

41 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
# Create /run/sysconfig/bip from default configuration file, for
# bip-config.service
# BIP_DEFAULT_CONFIG environment variable can be defined by packagers in a
# drop-in override of bip-config.service unit
if [ -n "${BIP_DEFAULT_CONFIG}" ]; then
# try some default paths
if [ -r /etc/default/bip ]; then
BIP_DEFAULT_CONFIG=/etc/default/bip
. "${BIP_DEFAULT_CONFIG}"
elif [ -r /etc/sysconfig/bip ]; then
BIP_DEFAULT_CONFIG=/etc/sysconfig/bip
. "${BIP_DEFAULT_CONFIG}"
fi
else
. "${BIP_DEFAULT_CONFIG}"
fi
ENABLED=${ENABLED:-1}
mkdir -p /run/sysconfig
{
echo ENABLED=${ENABLED}
DAEMON_HOME=${DAEMON_HOME:-/var/lib/bip}
DAEMON_CONFIG=${DAEMON_CONFIG:-/etc/bip/bip.conf}
echo "DAEMON_ARGS=${DAEMON_ARGS:--f '${DAEMON_CONFIG}' -s '${DAEMON_HOME}'}"
} > /run/sysconfig/bip
if [ ${ENABLED} = 0 ]; then
echo "INFO: BIP is explicitely disabled (ENABLED == 0) in" \
"'${BIP_DEFAULT_CONFIG}'."
else
if [ -n "${DAEMON_USER}" -o -n "${DAEMON_GROUP}" ]; then
echo "ERROR: Using systemd, DAEMON_USER and DAEMON_GROUP could not" \
"be defined using the default configuration file. A drop-in" \
"override of bip-config.service unit need to be created instead."
exit 1
fi
fi