From 16e63a5c745d881b5b7fbac63a477e5b7e6844a6 Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Mon, 1 Jun 2026 14:45:27 +0800 Subject: [PATCH] fix --- install_iot.sh | 60 +++++++++++++++++++++++++++++++++++++++++++++- install_service.md | 37 ++++++++++++++++++++++++---- 2 files changed, 91 insertions(+), 6 deletions(-) diff --git a/install_iot.sh b/install_iot.sh index 25e8d30..01b0594 100755 --- a/install_iot.sh +++ b/install_iot.sh @@ -24,7 +24,9 @@ SERVICE_GROUP="${SERVICE_GROUP:-$(id -gn "$SERVICE_USER")}" # IOT_ENV is rendered into the systemd service file as Environment= lines, # using the [prod] section from iot/env.file. Directory creation is driven by # those service env values. IOT_DIR_ENV_KEYS lists env keys whose values are -# directories that must be created if they do not exist. +# directories that must be created if they do not exist. IOT_PARENT_DIR_ENV_KEYS +# lists env keys whose values are file paths; their parent directories must be +# created if they do not exist. # # Use {install_dir}, {work_dir} and {service_name} in commands and directories. # service_user and service_group are optional. @@ -43,6 +45,7 @@ IOT_ENV=( "ENDPOINT_ROOT_DIR=/var/lib/endpoint/database/" "ENDPOINT_LOG_PATH=/var/lib/endpoint/endpoint_log" "IOT_MNESIA_DIR=/var/lib/iot/mnesia/" + "IOT_CTRL_SOCKET_PATH=/var/lib/iot/ctl.sock" ) IOT_DIR_ENV_KEYS=( @@ -51,6 +54,10 @@ IOT_DIR_ENV_KEYS=( "IOT_MNESIA_DIR" ) +IOT_PARENT_DIR_ENV_KEYS=( + "IOT_CTRL_SOCKET_PATH" +) + TEMP_FILES=() INSTALLED_SERVICES=() @@ -75,6 +82,7 @@ Array config inside script: INSTALL_IOT IOT_ENV IOT_DIR_ENV_KEYS + IOT_PARENT_DIR_ENV_KEYS Package format: INSTALL_=( @@ -348,6 +356,29 @@ service_dir_env_keys() { done } +service_parent_dir_env_keys() { + local service_name="$1" + local parent_dir_keys_array_name="" + local parent_dir_keys_count + local index + local env_key + + case "$service_name" in + iot) + parent_dir_keys_array_name="IOT_PARENT_DIR_ENV_KEYS" + ;; + *) + return 0 + ;; + esac + + eval "parent_dir_keys_count=\${#${parent_dir_keys_array_name}[@]}" + for ((index=0; index