浏览代码

✨: generate config domain

ulyc 2 年之前
父节点
当前提交
c701465693
共有 2 个文件被更改,包括 17 次插入10 次删除
  1. 15 8
      init.sh
  2. 2 2
      template/config.ini.template

+ 15 - 8
init.sh

@@ -51,7 +51,7 @@ function generate_config() {
   service_key=$(grep <genkeys "Service" | awk -F: '{gsub(/[[:blank:]]*/,"");print $2}')
   network_key=$(grep <genkeys "Network" | awk -F: '{gsub(/[[:blank:]]*/,"");print $2}')
   webhook_key=$(grep <genkeys "Webhook Private" | awk -F: '{gsub(/[[:blank:]]*/,"");print $2}')
-  sed "s/{{SERVICE_KEY}}/$service_key/" ./template/config.ini.template >config.ini
+  sed -i "s/{{SERVICE_KEY}}/$service_key/" config.ini
   sed -i "s/{{NETWORK_KEY}}/$network_key/" config.ini
   sed -i "s@{{WEBHOOK_KEY}}@$webhook_key@" config.ini
   sed -i "s@{{DOMAIN}}@$domain_name@" config.ini
@@ -66,14 +66,22 @@ function build_base_image() {
 }
 
 function generate_launch_shell() {
-  m="$meta_module $1"
-  m_count=$(echo "$m" | awk '{print NF}')
-  echo "$m" | awk '{ gsub(/\./,"");for (i=1; i<=NF; i++)  print "/usr/bin/gunicorn "$i ".app:app -b 0.0.0.0:500" i > "start.sh" }'
-  sed "s/{{PORTS}}/5001-500$m_count:5001-500$m_count/" ./template/docker-compose.yml.template >docker-compose.yml
-  echo "tail -f /dev/null" >> start.sh
+  md="$(echo "$meta_module $1" | awk '{ gsub(/\./,""); print $0 }')"
+  md_count=$(echo "$md" | awk '{print NF}')
+  cp ./template/config.ini.template config.ini
+  echo "" >"start.sh"
+  for ((i = 1; i <= "$md_count"; i++)); do
+    m=$(echo "$md" | awk -v i="$i" '{print $i }')
+    mp="500$i"
+    echo "/usr/bin/gunicorn $m .app:app -b 0.0.0.0:$mp " >>"start.sh"
+    m_domain=$domain_name:$mp
+    tp="{{"$m"_domain}}"
+    sed -i "s@$tp@$m_domain@" config.ini
+  done
+  sed "s/{{PORTS}}/5001-500$md_count:5001-500$md_count/" ./template/docker-compose.yml.template >docker-compose.yml
+  echo "tail -f /dev/null" >>start.sh
 }
 
-
 function select_version_control() {
   # Git or Mercurial or Both
   echo -e "Select your distributed version control system ${cyan}1.Git${none} or ${cyan}2.Mercurial${none} or ${cyan}3.Both${none}?"
@@ -174,7 +182,6 @@ echo
 generate_launch_shell "$modules" &
 progress $! "🤖 Generate Launch Shell"
 
-
 echo
 echo
 sed "s/{{MODULES}}/$modules/" ./template/Dockerfile.template >Dockerfile &

+ 2 - 2
template/config.ini.template

@@ -94,7 +94,7 @@ private-key={{WEBHOOK_KEY}}
 [git.sr.ht]
 #
 # URL git.sr.ht is being served at (protocol://domain)
-origin={{DOMAIN}}
+origin={{gitsrht_domain}}
 #
 # Address and port to bind the debug server to
 debug-host=0.0.0.0
@@ -169,7 +169,7 @@ internal-ipnet=127.0.0.0/8,::1/128,192.168.0.0/16,10.0.0.0/8
 #/usr/bin/buildsrht-keys=builds:builds
 
 [meta.sr.ht]
-origin={{DOMAIN}}:5000
+origin={{metasrht_domain}}
 #
 # Address and port to bind the debug server to
 debug-host=0.0.0.0