stubby: ensure appdata directory is present on service start master
authorNorman Dankert <norman.dankert@outlook.com>
Fri, 22 Nov 2024 21:21:18 +0000 (22:21 +0100)
committerHannu Nyman <hannu.nyman@iki.fi>
Sat, 30 Nov 2024 20:34:48 +0000 (22:34 +0200)
Signed-off-by: Norman Dankert <norman.dankert@outlook.com>
net/stubby/Makefile
net/stubby/files/stubby.init

index d86630b844a2ad83fbd83facbb452cd3f5655c1d..d7a0c77e89d13a85aec62f1b8ac9ce7a4b7f427c 100644 (file)
@@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=stubby
 PKG_VERSION:=0.4.3
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL:=https://github.com/getdnsapi/$(PKG_NAME)
index 57429050020284f5caffa6d5005cd4351dbec0e6..d30fcf0b0372787124e421db9795a8a25159d504 100755 (executable)
@@ -11,6 +11,7 @@ stubby_config_dir="/var/etc/stubby"
 stubby_config="$stubby_config_dir/stubby.yml"
 stubby_pid_file="/var/run/stubby.pid"
 stubby_manual_config="/etc/stubby/stubby.yml"
+stubby_default_appdata_dir="/var/lib/stubby"
 
 boot()
 {
@@ -49,7 +50,7 @@ generate_config()
     config_get round_robin "global" round_robin_upstreams "1"
     echo "round_robin_upstreams: $round_robin"
 
-    config_get appdata_dir "global" appdata_dir "/var/lib/stubby"
+    config_get appdata_dir "global" appdata_dir "$stubby_default_appdata_dir"
     echo "appdata_dir: \"$appdata_dir\""
 
     config_get trust_anchors_backoff_time "global" trust_anchors_backoff_time "2500"
@@ -211,6 +212,7 @@ start_service() {
     local manual
     local log_level
     local command_line_arguments
+    local appdata_dir
 
     mkdir -p "$stubby_config_dir"
 
@@ -228,6 +230,14 @@ start_service() {
     chown stubby:stubby "$stubby_config"
     chmod 0400 "$stubby_config"
 
+    config_get appdata_dir "global" appdata_dir "$stubby_default_appdata_dir"
+    if [ -n "$appdata_dir" ]; then
+        if mkdir -p "$appdata_dir"; then
+            chown stubby:stubby "$appdata_dir"
+            chmod 0700 "$appdata_dir"
+        fi
+    fi
+
     config_get command_line_arguments "global" command_line_arguments ""
 
     config_get log_level "global" log_level ""