Browse Source

✨: generate config domain

ulyc 2 years ago
parent
commit
c701465693
2 changed files with 17 additions and 10 deletions
  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}')
   service_key=$(grep <genkeys "Service" | awk -F: '{gsub(/[[:blank:]]*/,"");print $2}')
   network_key=$(grep <genkeys "Network" | 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}')
   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/{{NETWORK_KEY}}/$network_key/" config.ini
   sed -i "s@{{WEBHOOK_KEY}}@$webhook_key@" config.ini
   sed -i "s@{{WEBHOOK_KEY}}@$webhook_key@" config.ini
   sed -i "s@{{DOMAIN}}@$domain_name@" config.ini
   sed -i "s@{{DOMAIN}}@$domain_name@" config.ini
@@ -66,14 +66,22 @@ function build_base_image() {
 }
 }
 
 
 function generate_launch_shell() {
 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() {
 function select_version_control() {
   # Git or Mercurial or Both
   # 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}?"
   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" &
 generate_launch_shell "$modules" &
 progress $! "🤖 Generate Launch Shell"
 progress $! "🤖 Generate Launch Shell"
 
 
-
 echo
 echo
 echo
 echo
 sed "s/{{MODULES}}/$modules/" ./template/Dockerfile.template >Dockerfile &
 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]
 [git.sr.ht]
 #
 #
 # URL git.sr.ht is being served at (protocol://domain)
 # URL git.sr.ht is being served at (protocol://domain)
-origin={{DOMAIN}}
+origin={{gitsrht_domain}}
 #
 #
 # Address and port to bind the debug server to
 # Address and port to bind the debug server to
 debug-host=0.0.0.0
 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
 #/usr/bin/buildsrht-keys=builds:builds
 
 
 [meta.sr.ht]
 [meta.sr.ht]
-origin={{DOMAIN}}:5000
+origin={{metasrht_domain}}
 #
 #
 # Address and port to bind the debug server to
 # Address and port to bind the debug server to
 debug-host=0.0.0.0
 debug-host=0.0.0.0