From 8a97448f7f0a62b0b0f1588855688e37bc2a379b Mon Sep 17 00:00:00 2001 From: velvettear Date: Mon, 21 Feb 2022 12:04:37 +0100 Subject: [PATCH] added systemd-service and updated readme --- README.md | 24 ++++++++++++++++++++---- blinky.service | 11 +++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 blinky.service diff --git a/README.md b/README.md index ee83893..007524b 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,11 @@ control your blinkstick via http requests ## setup -- clone the project -`git clone https://git.velvettear.de/velvettear/blinky.git` +- clone the project (to '/opt/blinky') +`git clone https://git.velvettear.de/velvettear/blinky.git /opt/blinky` - enter the cloned directory -`cd blinky` +`cd /opt/blinky` - install and switch to a supported node.js version (automatically done via .nvmrc file) `nvm install` @@ -27,9 +27,25 @@ control your blinkstick via http requests - switch back to your system's default node.js version `nvm deactivate` -- run it +- execute blinky `nvm run 15 blinky.js` +## systemd + +**for security reasons it is highly recommended to not run blinky with root permissions!** + +- create a new system user +`useradd -r -s /usr/bin/nologin blinky` + +- symlink the provided systemd-service file and modify it according to your needs +`ln -s /opt/blinky/blinky.service /etc/systemd/system/blinky.service` + +- reload systemd-services +`systemctl daemon-reload` + +- enable and start blinky as a systemd-service +`systemctl enable --now blinky` + ### scripts - blinky-feed.sh diff --git a/blinky.service b/blinky.service new file mode 100644 index 0000000..10614eb --- /dev/null +++ b/blinky.service @@ -0,0 +1,11 @@ +[Unit] +Description=blinky (blinkstick controller) + +[Service] +Type=simple +User=blinky +Group=blinky +ExecStart=nvm run 15 /opt/blinky/blinky.js + +[Install] +WantedBy=multi-user.target \ No newline at end of file