From 4c51b610def9ed50962ddc054dfdcdc06f57f149 Mon Sep 17 00:00:00 2001 From: Vlad Glagolev Date: Tue, 6 Sep 2022 00:01:59 +0000 Subject: syncthing-bin: add init framework --- bin-net/syncthing-bin/BUILD | 2 +- bin-net/syncthing-bin/DEPENDS | 2 ++ bin-net/syncthing-bin/DETAILS | 1 + bin-net/syncthing-bin/FINAL | 5 +++++ bin-net/syncthing-bin/HISTORY | 4 ++++ bin-net/syncthing-bin/INSTALL | 8 ++++++- bin-net/syncthing-bin/init.d/syncthing | 33 +++++++++++++++++++++++++++++ bin-net/syncthing-bin/init.d/syncthing.conf | 3 +++ 8 files changed, 56 insertions(+), 2 deletions(-) create mode 100755 bin-net/syncthing-bin/DEPENDS create mode 100755 bin-net/syncthing-bin/init.d/syncthing create mode 100644 bin-net/syncthing-bin/init.d/syncthing.conf diff --git a/bin-net/syncthing-bin/BUILD b/bin-net/syncthing-bin/BUILD index 27ba77d..2932a63 100755 --- a/bin-net/syncthing-bin/BUILD +++ b/bin-net/syncthing-bin/BUILD @@ -1 +1 @@ -true +create_account syncthing /var/lib/syncthing diff --git a/bin-net/syncthing-bin/DEPENDS b/bin-net/syncthing-bin/DEPENDS new file mode 100755 index 0000000..355760d --- /dev/null +++ b/bin-net/syncthing-bin/DEPENDS @@ -0,0 +1,2 @@ +# for syslog logging +depends util-linux diff --git a/bin-net/syncthing-bin/DETAILS b/bin-net/syncthing-bin/DETAILS index 8fe682e..cdb3813 100755 --- a/bin-net/syncthing-bin/DETAILS +++ b/bin-net/syncthing-bin/DETAILS @@ -1,6 +1,7 @@ SPELL=syncthing-bin SPELLX=${SPELL/-bin/} VERSION=1.20.4 + PATCHLEVEL=1 if [[ "${SMGL_COMPAT_ARCHS[1]}" == "x86_64" || "${SMGL_COMPAT_ARCHS[1]}" == "em64t" ]]; then ARCH=amd64 SOURCE_HASH=sha256:ce577b08236c14ce4e3f2f589791b2521086bdd2ce952800847f0acd1b753dbe:UPSTREAM_HASH diff --git a/bin-net/syncthing-bin/FINAL b/bin-net/syncthing-bin/FINAL index 4b6a086..a05a270 100755 --- a/bin-net/syncthing-bin/FINAL +++ b/bin-net/syncthing-bin/FINAL @@ -1,3 +1,8 @@ +# binaries require /lib64 +if [ ! -d "${INSTALL_ROOT}/lib64" ]; then + ln -vsf "${TRACK_ROOT}/lib" "${INSTALL_ROOT}/lib64" +fi && + message "${MESSAGE_COLOR}You also want to consider the following:\n" message "# Increase maximum receive socket buffer size to 2MiB for QUIC connections" message "# see https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size" diff --git a/bin-net/syncthing-bin/HISTORY b/bin-net/syncthing-bin/HISTORY index f458ab2..25022be 100644 --- a/bin-net/syncthing-bin/HISTORY +++ b/bin-net/syncthing-bin/HISTORY @@ -1,2 +1,6 @@ +2022-09-05 Vlad Glagolev + * DETAILS: PATCHLEVEL=1 + * BUILD, INSTALL, init.d: added init framework + 2022-09-04 Vlad Glagolev * DETAILS, BUILD, INSTALL, FINAL: created spell, version 1.20.4 diff --git a/bin-net/syncthing-bin/INSTALL b/bin-net/syncthing-bin/INSTALL index 8c97ae8..e9a1c81 100755 --- a/bin-net/syncthing-bin/INSTALL +++ b/bin-net/syncthing-bin/INSTALL @@ -1 +1,7 @@ -install -vm 755 syncthing "${INSTALL_ROOT}/usr/bin/syncthing" +install -vm 755 syncthing "${INSTALL_ROOT}/usr/bin/syncthing" && + +local home_dir="${INSTALL_ROOT}/var/lib/${SPELLX}" && + +if [ ! -d "${home_dir}" ]; then + install -vm 750 -o syncthing -g syncthing -d "${home_dir}" +fi diff --git a/bin-net/syncthing-bin/init.d/syncthing b/bin-net/syncthing-bin/init.d/syncthing new file mode 100755 index 0000000..81f7d26 --- /dev/null +++ b/bin-net/syncthing-bin/init.d/syncthing @@ -0,0 +1,33 @@ +#!/bin/bash + +. /etc/sysconfig/syncthing + +PROGRAM=/usr/bin/syncthing +ARGS="--no-browser --no-default-folder --no-restart --logflags=0 --home=/var/lib/syncthing $SYNCTHING_ARGS" +RUNLEVEL=3 +NEEDS="+network" + +start() { + echo "Starting $NAME..." + + TIMEOUT=3 + + su syncthing -s /bin/sh -c "set -o pipefail; $PROGRAM $ARGS 2>&1 | logger -ip daemon.info -t syncthing" & + ppid=$! + + sleep $TIMEOUT && pgrep -P $ppid > /dev/null || wait $ppid + + evaluate_retval +} + +stop() { + echo "Stopping $NAME..." + + killproc "syncthing serve" +} + +reload() { + _restart +} + +. /etc/init.d/smgl_init diff --git a/bin-net/syncthing-bin/init.d/syncthing.conf b/bin-net/syncthing-bin/init.d/syncthing.conf new file mode 100644 index 0000000..ee08705 --- /dev/null +++ b/bin-net/syncthing-bin/init.d/syncthing.conf @@ -0,0 +1,3 @@ +# For the arguments and description see ``syncthing serve --help'' + +SYNCTHING_ARGS="" -- cgit v1.2.3