Page MenuHomeDevCentral

D20.id308.diff
No OneTemporary

D20.id308.diff

diff --git a/paas/docker/systemd-unit/files/containers.conf b/paas/docker/systemd-unit/files/containers.conf
new file mode 100644
--- /dev/null
+++ b/paas/docker/systemd-unit/files/containers.conf
@@ -0,0 +1,8 @@
+acquisitariat
+aphlict
+devcentral
+wolfphab
+pad
+cachet
+ci
+white-rabbit
diff --git a/paas/docker/systemd-unit/files/docker-containers.service b/paas/docker/systemd-unit/files/docker-containers.service
new file mode 100644
--- /dev/null
+++ b/paas/docker/systemd-unit/files/docker-containers.service
@@ -0,0 +1,5 @@
+[Service]
+Type=simple
+RemainAfterExit=yes
+ExecStart=docker_start
+ExecStop=docker_stop
diff --git a/paas/docker/systemd-unit/files/docker_start b/paas/docker/systemd-unit/files/docker_start
new file mode 100644
--- /dev/null
+++ b/paas/docker/systemd-unit/files/docker_start
@@ -0,0 +1,3 @@
+#!/bin/sh
+get-containers-list | xargs docker start
+
diff --git a/paas/docker/systemd-unit/files/docker_stop b/paas/docker/systemd-unit/files/docker_stop
new file mode 100644
--- /dev/null
+++ b/paas/docker/systemd-unit/files/docker_stop
@@ -0,0 +1,3 @@
+#!/bin/sh
+get-containers --reverse | xargs docker stop
+
diff --git a/paas/docker/systemd-unit/files/get-containers-list b/paas/docker/systemd-unit/files/get-containers-list
new file mode 100755
--- /dev/null
+++ b/paas/docker/systemd-unit/files/get-containers-list
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+## Read /etc/containers.conf and recover docker’s names into an array.
+## get-containers-list [--reverse]
+
+file='/etc/containers.conf'
+
+if [[ ! -f "$file" ]]; then
+
+ echo "$file : does not exists "
+ exit 1
+elif [[ ! -r "$file" ]]; then
+
+ echo "$file : can not read "
+fi
+
+#Get names in an array
+# 21:42 <geirha> since bash 4, you can use mapfile instead of that while read loop. mapfile -t array < "$file"
+
+mapfile -t array < "$file"
+
+#Test argument to know in wich order return names
+if [[ $1 == "--reverse" ]]; then
+ for ((i="${#array[*]}"; i > 0; i--)) ; do
+
+ echo "${array[i]}"
+ done
+
+elif [[ -z "$1" ]] ; then
+ for ((i=0; i < "${#array[*]}"; i++)) ; do
+
+ echo "${array[i]}"
+ done
+
+else
+ echo "$1 is not a valid argument"
+fi
+
+

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 20, 05:46 (20 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2307329
Default Alt Text
D20.id308.diff (2 KB)

Event Timeline