stubby: ensure appdata directory is present on service start

Signed-off-by: Norman Dankert <norman.dankert@outlook.com>
This commit is contained in:
Norman Dankert
2024-11-22 22:21:18 +01:00
committed by Hannu Nyman
parent 9f507623e1
commit 55a6cd43c6
2 changed files with 12 additions and 2 deletions

View 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)

View File

@@ -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 ""