From 64d92e504ad48e2015138c8fd4aa949427c6ca64 Mon Sep 17 00:00:00 2001
From: andryyy <andre.peters@debinux.de>
Date: Mon, 12 Dec 2016 10:01:27 +0100
Subject: [PATCH] Create an order

---
 build-network.sh => 001-build-network.sh     |  0
 build-pdns.sh => 002-build-pdns.sh           |  0
 build-sql.sh => 003-build-sql.sh             |  0
 build-redis.sh => 004-build-redis.sh         |  0
 build-rspamd.sh => 005-build-rspamd.sh       |  2 ++
 build-php-fpm.sh => 006-build-php-fpm.sh     |  0
 build-nginx.sh => 007-build-nginx.sh         |  0
 build-rmilter.sh => 008-build-rmilter.sh     |  0
 build-dovecot.sh => 009-build-dovecot.sh     |  0
 build-postfix.sh => 010-build-postfix.sh     |  0
 build-memcached.sh => 011-build-memcached.sh |  0
 build-sogo.sh => 012-build-sogo.sh           |  0
 README.md                                    | 22 ++++++++++----------
 build-all.sh                                 |  6 +-----
 14 files changed, 14 insertions(+), 16 deletions(-)
 rename build-network.sh => 001-build-network.sh (100%)
 rename build-pdns.sh => 002-build-pdns.sh (100%)
 rename build-sql.sh => 003-build-sql.sh (100%)
 rename build-redis.sh => 004-build-redis.sh (100%)
 rename build-rspamd.sh => 005-build-rspamd.sh (99%)
 rename build-php-fpm.sh => 006-build-php-fpm.sh (100%)
 rename build-nginx.sh => 007-build-nginx.sh (100%)
 rename build-rmilter.sh => 008-build-rmilter.sh (100%)
 rename build-dovecot.sh => 009-build-dovecot.sh (100%)
 rename build-postfix.sh => 010-build-postfix.sh (100%)
 rename build-memcached.sh => 011-build-memcached.sh (100%)
 rename build-sogo.sh => 012-build-sogo.sh (100%)

diff --git a/build-network.sh b/001-build-network.sh
similarity index 100%
rename from build-network.sh
rename to 001-build-network.sh
diff --git a/build-pdns.sh b/002-build-pdns.sh
similarity index 100%
rename from build-pdns.sh
rename to 002-build-pdns.sh
diff --git a/build-sql.sh b/003-build-sql.sh
similarity index 100%
rename from build-sql.sh
rename to 003-build-sql.sh
diff --git a/build-redis.sh b/004-build-redis.sh
similarity index 100%
rename from build-redis.sh
rename to 004-build-redis.sh
diff --git a/build-rspamd.sh b/005-build-rspamd.sh
similarity index 99%
rename from build-rspamd.sh
rename to 005-build-rspamd.sh
index ce214f54..233a60e2 100755
--- a/build-rspamd.sh
+++ b/005-build-rspamd.sh
@@ -27,6 +27,8 @@ if [[ ! -z "$(docker images -q rspamd)" ]]; then
         docker rmi rspamd
 		build
     fi
+else
+	build
 fi
 
 docker run \
diff --git a/build-php-fpm.sh b/006-build-php-fpm.sh
similarity index 100%
rename from build-php-fpm.sh
rename to 006-build-php-fpm.sh
diff --git a/build-nginx.sh b/007-build-nginx.sh
similarity index 100%
rename from build-nginx.sh
rename to 007-build-nginx.sh
diff --git a/build-rmilter.sh b/008-build-rmilter.sh
similarity index 100%
rename from build-rmilter.sh
rename to 008-build-rmilter.sh
diff --git a/build-dovecot.sh b/009-build-dovecot.sh
similarity index 100%
rename from build-dovecot.sh
rename to 009-build-dovecot.sh
diff --git a/build-postfix.sh b/010-build-postfix.sh
similarity index 100%
rename from build-postfix.sh
rename to 010-build-postfix.sh
diff --git a/build-memcached.sh b/011-build-memcached.sh
similarity index 100%
rename from build-memcached.sh
rename to 011-build-memcached.sh
diff --git a/build-sogo.sh b/012-build-sogo.sh
similarity index 100%
rename from build-sogo.sh
rename to 012-build-sogo.sh
diff --git a/README.md b/README.md
index ef5986ff..c3fc2a13 100644
--- a/README.md
+++ b/README.md
@@ -107,7 +107,7 @@ When renewing certificates, run the last two steps (link + restart) as post-hook
 
 (Re)build a container:
 ```
-./build-$name.sh 
+./n-build-$name.sh 
 ```
 **:exclamation:** Any previous container with the same name will be stopped and removed.
 No persistent data is deleted at any time.
@@ -123,34 +123,34 @@ When a process dies, the container dies, too. Except for Postfix' container.
 
 Connect to MariaDB database:
 ```
-./build-sql.sh --client
+./n-build-sql.sh --client
 ```
 
-Init schema (will also be installed when running `./build-sql.sh` without parameters):
+Init schema (will also be installed when running `./n-build-sql.sh` without parameters):
 ```
-./build-sql.sh --init-schema
+./n-build-sql.sh --init-schema
 ```
 
 Reset mailcow admin to `admin:moohoo`:
 ```
-./build-sql.sh --reset-admin
+./n-build-sql.sh --reset-admin
 ```
 
 Dump database to file backup_${DBNAME}_${DATE}.sql:
 ```
-./build-sql.sh --dump
+./n-build-sql.sh --dump
 ```
 
 Restore database from a file:
 ```
-./build-sql.sh --restore filename
+./n-build-sql.sh --restore filename
 ```
 
 ### Redis
 
 Connect to redis database:
 ```
-./build-redis.sh --client
+./n-build-redis.sh --client
 ```
 
 ### Rspamd examples
@@ -172,7 +172,7 @@ MariaDB:
 docker stop mariadb-mailcow
 docker rm mariadb-mailcow
 rm -rf data/db/mysql/*
-./build-sql.sh
+./n-build-sql.sh
 ```
 
 Redis:
@@ -181,9 +181,9 @@ Redis:
 docker stop redis-mailcow
 docker rm redus-mailcow
 rm -rf data/db/redis/*
-./build-redis.sh
+./n-build-redis.sh
 
 ## It is almost always enough to just flush all keys:
-./build-redis client
+./n-build-redis client
 # FLUSHALL [ENTER]
 ```
diff --git a/build-all.sh b/build-all.sh
index c09c645e..184d3448 100755
--- a/build-all.sh
+++ b/build-all.sh
@@ -2,13 +2,9 @@
 
 /bin/bash port-check.sh
 [[ $? != 0 ]] && exit 1
-/bin/bash build-network.sh
-/bin/bash build-pdns.sh
 
-[[ $? != 0 ]] && exit 1
-for buildx in $(ls build-*.sh | grep -vE "all|network|pdns"); do
+for build in $(ls *build*.sh | grep -v all); do
     echo "Starting build file ${buildx} ..."
 	/bin/bash ${buildx}
 done
-
 /bin/bash fix-permissions.sh