From fd0fedd6955b7b7c7c95e5d38c3074e785c073c0 Mon Sep 17 00:00:00 2001 From: redxef Date: Fri, 14 Apr 2023 01:53:20 +0200 Subject: [PATCH] Init commit. --- .gitignore | 2 ++ Makefile | 7 +++++++ src/etc/udev/rules.d/99-syncthing.rules | 2 ++ src/usr/local/syncthing/start.sh | 19 +++++++++++++++++++ 4 files changed, 30 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 src/etc/udev/rules.d/99-syncthing.rules create mode 100755 src/usr/local/syncthing/start.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5e72502 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +KoboRoot.tgz +src/usr/local/syncthing/syncthing diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4c69748 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ + +SRC := $(shell find src -type f | tail -n+2) +SRC_REL := $(shell cd src && find ./ -type f) + +KoboRoot.tgz: $(SRC) + tar cvzf $@ -C src $(SRC_REL) --owner=0 --group=0 + diff --git a/src/etc/udev/rules.d/99-syncthing.rules b/src/etc/udev/rules.d/99-syncthing.rules new file mode 100644 index 0000000..800679e --- /dev/null +++ b/src/etc/udev/rules.d/99-syncthing.rules @@ -0,0 +1,2 @@ +KERNEL=="eth*", ACTION=="add", RUN+="/usr/local/syncthing/start.sh" +KERNEL=="wlan*", ACTION=="add", RUN+="/usr/local/syncthing/start.sh" diff --git a/src/usr/local/syncthing/start.sh b/src/usr/local/syncthing/start.sh new file mode 100755 index 0000000..6f97b97 --- /dev/null +++ b/src/usr/local/syncthing/start.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +if [ "$SETSID" != '1' ]; then + SETSID=1 setsid "$0" "$@" & + exit 0 +fi + +if pgrep syncthing; then + exit 0 +fi + +SYNCTHING_HOME=/mnt/onboard/.adds/syncthing + +# add 127.0.0.1 to loopback device +ip addr add 127.0.0.1/32 dev lo || true + +/usr/local/syncthing/syncthing serve --no-browser --no-restart --logflags=0 \ + --no-default-folder --home="$SYNCTHING_HOME" +exit $?