syncthing: fix wrong group name in syncthing.init
authorXiang W <wxjstz@126.com>
Tue, 19 Dec 2023 13:20:13 +0000 (13:20 +0000)
committerRosen Penev <rosenp@gmail.com>
Tue, 2 Jan 2024 23:25:19 +0000 (15:25 -0800)
The group does not always have the same name as user, and when I try
to run syncthing with nobody I get an error. Since nobody belongs to
the group nogroup, I added some code to find out which group user
belongs to.

Signed-off-by: Xiang W <wxjstz@126.com>
utils/syncthing/Makefile
utils/syncthing/files/syncthing.init

index 80e6cfb20cd9a7398e6e7b2352bf5202b7a5496a..149c3b63c8061c5fd542b5f9d200fb8f0158c40f 100644 (file)
@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=syncthing
 PKG_VERSION:=1.27.1
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=syncthing-source-v$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://github.com/syncthing/syncthing/releases/download/v$(PKG_VERSION)
index 7bcb90daea5e69e95525d3e2fd24782e400f6c62..9fa1ddf4023209135d7791b0d0b83750769b24a4 100644 (file)
@@ -55,6 +55,8 @@ start_service() {
 
        config_load "syncthing"
 
+       local group=$(id -gn $user)
+
        # Some of the default values below might not match the defaults
        #   in /etc/config/syncthing: the reason is to remain backwards
        #   compatible with the older versions of this service as it
@@ -67,12 +69,12 @@ start_service() {
                [ -d "$IDX_DB" ] || mkdir -p "$IDX_DB"
 
                # A separate step to handle an upgrade use case
-               [ -d "$IDX_DB" ] && chown -R $user:$user "$IDX_DB"
+               [ -d "$IDX_DB" ] && chown -R $user:$group "$IDX_DB"
        fi
 
        [ -d "$home" ] || mkdir -p "$home"
        # A separate step to handle an upgrade use case
-       [ -d "$home" ] && chown -R $user:$user "$home"
+       [ -d "$home" ] && chown -R $user:$group "$home"
 
        # Changes to "niceness"/macprocs are not picked up by "reload_config"
        #   nor by "restart": the service has to be stopped/started