This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 4a6a9ed406f fix: docker replace conf sh (#14518)
4a6a9ed406f is described below

commit 4a6a9ed406f0e737330006bf513c527f1a0aa84a
Author: CritasWang <[email protected]>
AuthorDate: Mon Dec 23 11:24:24 2024 +0800

    fix: docker replace conf sh (#14518)
---
 .../main/DockerCompose/replace-conf-from-env.sh    | 33 ++++++++++++----------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/docker/src/main/DockerCompose/replace-conf-from-env.sh 
b/docker/src/main/DockerCompose/replace-conf-from-env.sh
index 887faf1bdcd..dc3d6cf2cf1 100755
--- a/docker/src/main/DockerCompose/replace-conf-from-env.sh
+++ b/docker/src/main/DockerCompose/replace-conf-from-env.sh
@@ -21,33 +21,36 @@
 conf_path=${IOTDB_HOME}/conf
 target_files="iotdb-system.properties"
 
-function process_single(){
-       local key_value="$1"
-       local filename=$2
-       local key=$(echo $key_value|cut -d = -f1)
-       local line=$(grep -ni "${key}=" ${filename})
-       #echo "line=$line"
-       if [[ -n "${line}" ]]; then
+function process_single() {
+  local key_value="$1"
+  local filename=$2
+  local key=$(echo $key_value | cut -d = -f1)
+  local line=$(grep -ni "${key}=" ${filename})
+  #echo "line=$line"
+  if [[ -n "${line}" ]]; then
     echo "update $key $filename"
-    local line_no=$(echo $line|cut -d : -f1)
-               local content=$(echo $line|cut -d : -f2)
-               if [[ "${content:0:1}" != "#" ]]; then
+    local line_no=$(echo $line | cut -d : -f1)
+    local content=$(echo $line | cut -d : -f2)
+    if [[ "${content:0:1}" != "#" ]]; then
       sed -i "${line_no}d" ${filename}
     fi
     sed -i "${line_no} i${key_value}" ${filename}
-       fi
+  else
+    echo "append $key to $filename"
+
+    echo "${key_value}" >>"${filename}"
+  fi
 }
 
-function replace_configs(){
+function replace_configs() {
   for v in $(env); do
     if [[ "${v}" =~ "=" && "${v}" =~ "_" && ! "${v}" =~ "JAVA_" ]]; then
-#      echo "###### $v ####"
+      #      echo "###### $v ####"
       for f in ${target_files}; do
-          process_single $v ${conf_path}/$f
+        process_single $v ${conf_path}/$f
       done
     fi
   done
 }
 
 replace_configs
-

Reply via email to