summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-10-17 21:03:43 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2012-10-17 21:05:52 +0200
commitfbc6c0b93a88ac10730dd6f4492750cd32e2b44a (patch)
tree06da50f5115f1f20b34dad817b98cd1bc4c677ea
parent265b1d8b25945898e11801242dbff7639e1a4a60 (diff)
downloadapp.sh-fbc6c0b93a88ac10730dd6f4492750cd32e2b44a.tar.gz
app.sh-fbc6c0b93a88ac10730dd6f4492750cd32e2b44a.tar.bz2
app.sh-fbc6c0b93a88ac10730dd6f4492750cd32e2b44a.tar.xz
app.sh-fbc6c0b93a88ac10730dd6f4492750cd32e2b44a.zip
o Adding environment variables to postinstall:
- APPSH_BASEDIR - APPSH_HOME - APPSH_INSTANCE - APPSH_NAME - APPSH_VERSION
-rw-r--r--.app/lib/app-instance5
-rwxr-xr-xtest/app-install.bats7
-rw-r--r--test/data/app-a/root/etc/prod/foo.conf1
-rw-r--r--test/data/app-a/scripts/postinstall8
-rw-r--r--test/data/install-test-env/scripts/postinstall2
-rwxr-xr-xtest/it-install-remove.bats4
-rw-r--r--test/utils.bash2
7 files changed, 26 insertions, 3 deletions
diff --git a/.app/lib/app-instance b/.app/lib/app-instance
index 2012a74..5c452d2 100644
--- a/.app/lib/app-instance
+++ b/.app/lib/app-instance
@@ -210,6 +210,11 @@ method_install() {
set +e
env -i \
PATH=/bin:/usr/bin \
+ APPSH_BASEDIR=$BASEDIR \
+ APPSH_HOME=$APPSH_HOME \
+ APPSH_NAME=$name \
+ APPSH_INSTANCE=$instance \
+ APPSH_VERSION=$resolved_version \
scripts/postinstall
set -e
ret=`echo $?`
diff --git a/test/app-install.bats b/test/app-install.bats
index 59880bd..7b80547 100755
--- a/test/app-install.bats
+++ b/test/app-install.bats
@@ -35,11 +35,16 @@ Changing current symlink" ]
[ "$output" = "Creating instance 'prod' for 'install-test-env'
Unpacking...
Running postinstall...
+APPSH_BASEDIR=$APPSH_BASEDIR
+APPSH_HOME=$APPSH_HOME
+APPSH_INSTANCE=prod
+APPSH_NAME=install-test-env
+APPSH_VERSION=1.0
PATH=/bin:/usr/bin
PWD=$WORK/install-test-env/prod/versions/1.0
SHLVL=1
_=/usr/bin/env
Postinstall completed successfully
Changing current symlink" ]
- [ ${#lines[*]} == 9 ]
+ [ ${#lines[*]} == 14 ]
}
diff --git a/test/data/app-a/root/etc/prod/foo.conf b/test/data/app-a/root/etc/prod/foo.conf
new file mode 100644
index 0000000..ce01362
--- /dev/null
+++ b/test/data/app-a/root/etc/prod/foo.conf
@@ -0,0 +1 @@
+hello
diff --git a/test/data/app-a/scripts/postinstall b/test/data/app-a/scripts/postinstall
index cd16289..a77f86f 100644
--- a/test/data/app-a/scripts/postinstall
+++ b/test/data/app-a/scripts/postinstall
@@ -1,3 +1,11 @@
#!/bin/bash
echo "Hello World!"
+
+if [ -d root/etc/$APPSH_INSTANCE ]
+then
+ find root/etc/$APPSH_INSTANCE -type f -maxdepth 1 | while read file
+ do
+ cp $file root/
+ done
+fi
diff --git a/test/data/install-test-env/scripts/postinstall b/test/data/install-test-env/scripts/postinstall
index ad40c95..2a68f6a 100644
--- a/test/data/install-test-env/scripts/postinstall
+++ b/test/data/install-test-env/scripts/postinstall
@@ -1,3 +1,3 @@
#!/bin/bash
-env
+env | sort
diff --git a/test/it-install-remove.bats b/test/it-install-remove.bats
index 736bf56..bba16d2 100755
--- a/test/it-install-remove.bats
+++ b/test/it-install-remove.bats
@@ -13,7 +13,7 @@ load utils
app instance install \
-r file \
-u $BATS_TEST_DIRNAME/data/app-a.zip \
- -n $name -i $instance
+ -n $name -i $instance; echo_lines
[ $status -eq 0 ]
can_not_read ".app/var/pid/$name-$instance.pid"
@@ -35,8 +35,10 @@ load utils
can_read "$name/$instance/$name.log"
can_read "$name/$instance/$name.env"
+ can_read "$name/$instance/current/foo.conf"
[ "`cat $name/$instance/$name.env`" = "TEST_PROPERTY=awesome" ]
+ [ "`cat $name/$instance/current/foo.conf`" = "hello" ]
# app instance install \
# -r file \
diff --git a/test/utils.bash b/test/utils.bash
index 653aae4..6a6967f 100644
--- a/test/utils.bash
+++ b/test/utils.bash
@@ -14,6 +14,8 @@ echo_lines() {
APPSH=$(pwd)/app
setup() {
+ APPSH_BASEDIR=$BATS_TMPDIR/app.sh
+ APPSH_HOME=$(cd $BATS_TEST_DIRNAME/../..; echo `pwd`/app.sh)
rm -rf $BATS_TMPDIR/app.sh
mkdir $BATS_TMPDIR/app.sh
cd $BATS_TMPDIR/app.sh