From 4fd639f02efb7699af55db457bd0f739ccc540fd Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Sun, 30 Oct 2016 16:10:31 +0100 Subject: [PATCH] [TASK] Migrate to systemctl service. --- .gitignore | 4 ++++ Makefile | 4 ---- ftpbot.service.example | 13 +++++++++++++ install.sh | 19 +++++++++++++++++++ 4 files changed, 36 insertions(+), 4 deletions(-) delete mode 100644 Makefile create mode 100644 ftpbot.service.example create mode 100755 install.sh diff --git a/.gitignore b/.gitignore index 8c6f22a..884349f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +venv/ + settings.ini *.pyc *.cache + +ftpbot.service diff --git a/Makefile b/Makefile deleted file mode 100644 index ae3ddb7..0000000 --- a/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -run: - python fdskun.py -install: - pip install -r requirements.txt diff --git a/ftpbot.service.example b/ftpbot.service.example new file mode 100644 index 0000000..e6bc72e --- /dev/null +++ b/ftpbot.service.example @@ -0,0 +1,13 @@ +[Unit] +Description=File system monitoring irc bot +After=network.target + +[Service] +Type=simple +User=%USER% +Group=%GROUP% +ExecStart=%PWD%/venv/bin/python %PWD%/ftpbot.py + +[Install] +WantedBy=multi-user.target + diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..0073899 --- /dev/null +++ b/install.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# TODO: Make sure this is executed from within its original directory! + +virtualenv ./venv +. ./venv/bin/activate +pip install -r requirements.txt + +# Prepare a systemd service unit file with current pwd and user data +USER=`id -un` +GROUP=`id -gn` +PWD=`pwd` + +cp ftpbot.service.example ftpbot.service +sed -i "s#%USER%#$USER#g" ftpbot.service +sed -i "s#%GROUP%#$GROUP#g" ftpbot.service +sed -i "s#%PWD%#$PWD#g" ftpbot.service + +echo "Put ftpbot.servive within /etc/systemd/system and use systemctl to configure the service."