From 750844f49e199cb2bdae6644f64723f852ac7178 Mon Sep 17 00:00:00 2001 From: velvettear Date: Thu, 24 Feb 2022 23:25:20 +0100 Subject: [PATCH] updated systemd-service and readme --- README.md | 26 +++++++++++++++++++++++--- blinky.service | 7 ++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 312ebc6..1eb1adb 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,11 @@ control your blinkstick via http requests **the node-hid module is a bit picky about node.js's version - use node.js 8.x or 15.x** -## setup +## setup (as root) + +- install nvm + +- to load nvm restart your terminal or `source ~/.nvm/nvm.sh` - clone the project (to '/opt/blinky') `git clone https://git.velvettear.de/velvettear/blinky.git /opt/blinky` @@ -30,14 +34,26 @@ control your blinkstick via http requests - execute blinky `nvm run 15 blinky.js` +- if you get this error message on linux: +`Error: cannot open device with path /dev/hidraw0` +run: +`echo "KERNEL==\"hidraw*\", SUBSYSTEM==\"hidraw\", ATTRS{idVendor}==\"20a0\", ATTRS{idProduct}==\"41e5\", MODE=\"0666\"" | sudo tee /etc/udev/rules.d/85-blinkstick-hid.rules` +and reboot your system + + + ## 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` +`useradd -U -r -s /usr/bin/nologin node` -- symlink the provided systemd-service file and modify it according to your needs +- make your install of nvm available to the new user +`cp -R ~/.nvm /opt/nvm` +`chown -R node /opt/nvm` + +- symlink the provided systemd-service file `ln -s /opt/blinky/blinky.service /etc/systemd/system/blinky.service` - reload systemd-services @@ -46,6 +62,10 @@ control your blinkstick via http requests - enable and start blinky as a systemd-service `systemctl enable --now blinky` +- if you don't use nvm otherwise remove it and remove it from your shell-profile +`rm -rf ~/.nvm` +`vim ~/.zshrc` + ### scripts - blinky-feed.sh diff --git a/blinky.service b/blinky.service index 10614eb..3f27e74 100644 --- a/blinky.service +++ b/blinky.service @@ -3,9 +3,10 @@ Description=blinky (blinkstick controller) [Service] Type=simple -User=blinky -Group=blinky -ExecStart=nvm run 15 /opt/blinky/blinky.js +User=node +Group=node +WorkingDirectory=/opt/blinky +ExecStart=/opt/nvm/nvm-exec node blinky.js [Install] WantedBy=multi-user.target \ No newline at end of file