Browse Source

✨: generate start.sh

ulyc 2 years ago
parent
commit
955f8e82ba
3 changed files with 24 additions and 9 deletions
  1. 15 3
      init.sh
  2. 8 4
      start.sh
  3. 1 2
      template/docker-compose.yml.template

+ 15 - 3
init.sh

@@ -18,6 +18,7 @@ _cyan() { echo -e "${cyan}$*${none}"; }
 
 domain_name="http://localhost"
 modules=""
+meta_module="meta.sr.ht"
 git_module="git.sr.ht"
 hg_module="hg.sr.ht"
 build_module="builds.sr.h"
@@ -64,6 +65,14 @@ function build_base_image() {
   docker build -t sr.ht-base:dev ./base/ && echo
 }
 
+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
+}
+
+
 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}?"
@@ -159,14 +168,17 @@ else
   domain_name=$domain_input
 fi
 
-# TODO start.sh
-#
+echo
+echo
+generate_launch_shell "$modules" &
+progress $! "🤖 Generate Launch Shell"
+
+
 echo
 echo
 sed "s/{{MODULES}}/$modules/" ./template/Dockerfile.template >Dockerfile &
 progress $! "🐋 Generate Dockerfile"
 
-
 echo
 echo
 build_base_image &

+ 8 - 4
start.sh

@@ -1,4 +1,8 @@
-
-
-/usr/bin/gunicorn metasrht.app:app -b 0.0.0.0:5000
-/usr/bin/gunicorn gitsrht.app:app -b 0.0.0.0:5001
+/usr/bin/gunicorn metasrht.app:app -b 0.0.0.0:5001
+/usr/bin/gunicorn gitsrht.app:app -b 0.0.0.0:5002
+/usr/bin/gunicorn hgsrht.app:app -b 0.0.0.0:5003
+/usr/bin/gunicorn buildssrh.app:app -b 0.0.0.0:5004
+/usr/bin/gunicorn listssrht.app:app -b 0.0.0.0:5005
+/usr/bin/gunicorn mansrht.app:app -b 0.0.0.0:5006
+/usr/bin/gunicorn pastesrht.app:app -b 0.0.0.0:5007
+/usr/bin/gunicorn todosrht.app:app -b 0.0.0.0:5008

+ 1 - 2
docker-compose.yml → template/docker-compose.yml.template

@@ -14,8 +14,7 @@ services:
   git:
     build: ./git/
     ports:
-      - "5000:5000"
-      - "5001:5001"
+      {{PORTS}}
     volumes:
       - git-data:/var/lib/git
       - ./config.ini:/etc/sr.ht/config.ini