summaryrefslogtreecommitdiffstats
path: root/adei/files/opt/scripts/adei-branch.sh
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2019-10-01 19:30:54 +0200
committerSuren A. Chilingaryan <csa@suren.me>2019-10-01 19:30:54 +0200
commit79c76eaef5039276bb3a8725ac8c9f05f89ef0de (patch)
tree1bde68d36ce44d75fafc6dfb41f5f6d2b555815f /adei/files/opt/scripts/adei-branch.sh
parentbc1b77dc912adfd040d432972e2d3256c9ea2065 (diff)
downloadadei-79c76eaef5039276bb3a8725ac8c9f05f89ef0de.tar.gz
adei-79c76eaef5039276bb3a8725ac8c9f05f89ef0de.tar.bz2
adei-79c76eaef5039276bb3a8725ac8c9f05f89ef0de.tar.xz
adei-79c76eaef5039276bb3a8725ac8c9f05f89ef0de.zip
Optimize Dockerfile
Diffstat (limited to 'adei/files/opt/scripts/adei-branch.sh')
-rwxr-xr-xadei/files/opt/scripts/adei-branch.sh80
1 files changed, 80 insertions, 0 deletions
diff --git a/adei/files/opt/scripts/adei-branch.sh b/adei/files/opt/scripts/adei-branch.sh
new file mode 100755
index 0000000..e56f792
--- /dev/null
+++ b/adei/files/opt/scripts/adei-branch.sh
@@ -0,0 +1,80 @@
+#! /bin/bash
+
+function branch {
+ url="$1"
+ bzr branch "$url"
+}
+
+if [ ! -d /adei/src -o ! -d /adei/tmp -o ! -d /adei/sys -o ! -d /adei/cfg ]; then
+ echo "Incorrect volume configration, we expect /adei folder with populated docker volumes"
+ exit 1
+fi
+
+LOCK_FILE=.lock
+
+#(
+# flock -x 10
+# if [ ! -f /adei/sys/adei.cron.sh ]; then
+# cp -a /opt/configs/*.cron.sh /adei/sys
+# fi
+#) 10> /adei/sys/$LOCK_FILE
+
+
+(
+ flock -x 10
+ flock -x 11
+
+
+ if [ ! -f /adei/cfg/config.actual.php ]; then
+ cp -a /opt/configs/config.*.php /adei/cfg/
+ fi
+
+ if [ ! -f /adei/src/VERSION ]; then
+ bzr branch -r $ADEI_REVISION --use-existing-dir http://darksoft.org/bzr/adei/trunk/ /adei/src
+ (
+ cd /adei/src
+ make
+
+ [ -n "$ADEI_REPOSITORY" ] && bzr config push_location=${ADEI_REPOSITORY}/adei
+
+ [ -d tmp ] && rm tmp
+ ln -s ../tmp tmp
+ chmod 0777 /adei/tmp
+
+ # Additional setups are clonned based on the environment for adei container creation
+ # but can be easily added in future. We cache all non-excluded setups. The .exclude
+ # file is removed afterwards from all
+
+ ln -s ../cfg/config.actual.php config.actual.php
+ ln -s ../cfg/config.override.php config.override.php
+ )
+ fi
+
+ (
+ cd /adei/src
+ for setup in $ADEI_ENABLED_SETUPS $ADEI_SETUP; do
+ if [[ ! -a setups/$setup ]]; then
+ if [[ ! -a /adei/cfg/$setup ]]; then
+ (
+ cd /adei/cfg/
+ if [[ "$setup" == *-logs ]]; then
+ branch "http://darksoft.org/bzr/adei/setups/$setup" &> /dev/null
+ [ $? -eq 0 ] || cp -ar /adei/src/setups/logs $setup
+ else
+ branch "http://darksoft.org/bzr/adei/setups/$setup"
+ fi
+ (
+ cd $setup
+ [ -n "$ADEI_REPOSITORY" -a -d .bzr ] && bzr config push_location=${ADEI_REPOSITORY}/adei-setups/$setup
+ )
+ )
+ fi
+ if [ -d ../cfg/$setup ]; then
+ ln -s ../../cfg/$setup setups/$setup
+ fi
+ fi
+ done
+ )
+
+ touch /adei/cfg/.ready
+) 10> /adei/cfg/$LOCK_FILE 11> /adei/src/$LOCK_FILE