Browse Source

removed hostname

admin 1 year ago
parent
commit
85b8cb63b6
5 changed files with 27 additions and 45 deletions
  1. 0 4
      .env.template
  2. 1 1
      .gitignore
  3. 3 7
      README.md
  4. 2 0
      services.conf.template
  5. 21 33
      startup.sh

+ 0 - 4
.env.template

@@ -1,4 +0,0 @@
-docker.example.com="
-  /opt/docker/reverse-proxy
-  /opt/docker/ejabberd
-"

+ 1 - 1
.gitignore

@@ -1 +1 @@
-.env
+services.conf

+ 3 - 7
README.md

@@ -1,9 +1,6 @@
 # Docker startup helper scripts 
 
-`startup.sh` brings containers up/down or pulls images with `docker compose`.
-The script looks for an environment variable named as per the hostname of the machine
-containing a list with absolute paths to `docker-compose.yml` files.
-Those variables can be defined in `.env`. 
+`startup.sh` runs `docker compose` for a list of services to bring containers up/down or pulls images.  The services must be defined as  absolute paths to `docker-compose.yml` files in `/opt/docker/startup/services.conf`.
 
 `container-startup.service` is a one-shot systemd service which runs `startup.sh up` after boot.
 Stop and restart are explicitly not part of the service as those actions are
@@ -11,9 +8,8 @@ Stop and restart are explicitly not part of the service as those actions are
 
 To install the service run:
 ```
-cp .env.template .env
-# add a variable named as per the hostname of the machine
-# with the list of your docker-compose.yml files
+cp services.conf services.conf.template
+# add absolute paths to your docker-compose.yml files
 vi .env
 cp container-startup.service /etc/systemd/system/
 systemctl enable container-startup.service

+ 2 - 0
services.conf.template

@@ -0,0 +1,2 @@
+/opt/docker/reverse-proxy
+/opt/docker/transfer-sh

+ 21 - 33
startup.sh

@@ -1,25 +1,16 @@
 #!/bin/bash
 
-if [ -f /opt/docker/startup/.env ]
+if [ -f /opt/docker/startup/services.conf ]
 then
-  echo "OK: .env file found"
-  source /opt/docker/startup/.env
+  echo "OK: services.conf file found"
+  services=$(cat /opt/docker/startup/services.conf)
 else
- echo '.env is missing, please consult README.md' && exit 1
+ echo 'services.conf file is missing, please consult README.md'
+ exit 1
 fi
 
-# test if a variable with the hostname of the machine,
-# as defined in $HOSTNAME, exists
-if [ ! -z "${!HOSTNAME}" ]
-then
-  echo "OK: Container list found in \$$HOSTNAME"
-else
-  echo "NOK: No container list found for $HOSTNAME" && exit 1
-fi
-
-
 up() {
-for service in ${!HOSTNAME}
+for service in $services
   do
     cd $service
     docker compose up -d --remove-orphans
@@ -42,23 +33,20 @@ for service in $services
   done
 }
 
-
-
 case "$1" in
-        up)
-            up 
-            ;;
-         
-        down)
-            down 
-            ;;
-         
-        pull)
-            pull 
-            ;;
-         
-        *)
-            echo $"Usage: $0 {up|down|pull}"
-            exit 1
+  up)
+      up 
+      ;;
+   
+  down)
+      down 
+      ;;
+   
+  pull)
+      pull 
+      ;;
+   
+  *)
+      echo $"Usage: $0 {up|down|pull}"
+      exit 1
 esac
-