From c926b4b5e56b48d1bfe998b35c388b6b104ddc44 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Mon, 3 Feb 2020 19:36:06 +0100 Subject: [PATCH] deb package: adding environment file for systemctl --- scripts/build_deb.sh | 7 +++++++ scripts/config | 7 +++++++ scripts/template.service | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 scripts/config diff --git a/scripts/build_deb.sh b/scripts/build_deb.sh index 1ca0ecf..4e9fe7a 100755 --- a/scripts/build_deb.sh +++ b/scripts/build_deb.sh @@ -30,10 +30,17 @@ cat ${BASE_DIR}/${PACKAGE_TMPDIR}/DEBIAN/control # Create service file mkdir -p ${BASE_DIR}/${PACKAGE_TMPDIR}/etc/systemd/system cat ${BASE_DIR}/template.service \ + | sed "s~{{ PACKAGE_NAME }}~${PACKAGE_NAME}~" \ | sed "s~{{ DESCRIPTION }}~${PACKAGE_DESCRIPTION}~" \ | sed "s~{{ PROGRAM }}~/${PACKAGE_PREFIX}/bin/${PACKAGE_NAME}~" \ > ${BASE_DIR}/${PACKAGE_TMPDIR}/etc/systemd/system/${PACKAGE_NAME}.service +# Cerate config file +mkdir -p ${BASE_DIR}/${PACKAGE_TMPDIR}/etc/${PACKAGE_NAME} +cat ${BASE_DIR}/config \ + | sed "s~{{ PACKAGE_NAME }}~${PACKAGE_NAME}~" \ + > ${BASE_DIR}/${PACKAGE_TMPDIR}/etc/${PACKAGE_NAME}/env + # Copy program mkdir -p ${BASE_DIR}/${PACKAGE_TMPDIR}/${PACKAGE_PREFIX}/bin cp ${BASE_DIR}/../${PACKAGE_PROGRAM} ${BASE_DIR}/${PACKAGE_TMPDIR}/${PACKAGE_PREFIX}/bin/${PACKAGE_NAME} diff --git a/scripts/config b/scripts/config new file mode 100644 index 0000000..c34ce2a --- /dev/null +++ b/scripts/config @@ -0,0 +1,7 @@ +# Default settings for {{ PACKAGE_NAME }} +# +# This is sourced by the systemd unit file. + +# Command line flags to pass to {{ PACKAGE_NAME }} +# First is IP to listen to, second is port. +#OPTS="127.0.0.1 1337" diff --git a/scripts/template.service b/scripts/template.service index b06ab95..988e46e 100644 --- a/scripts/template.service +++ b/scripts/template.service @@ -3,11 +3,12 @@ Description={{ DESCRIPTION }} After=network.target [Service] +EnvironmentFile=-/etc/{{ PACKAGE_NAME }}/env Type=simple # Another Type: forking #User=nanodano #WorkingDirectory=/home/nanodano -ExecStart={{ PROGRAM }} +ExecStart={{ PROGRAM }} $OPTS Restart=on-failure # Other restart options: always, on-abort, etc