aboutsummaryrefslogtreecommitdiff
path: root/.app/lib/app-common
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-01-10 13:34:04 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2013-01-10 13:34:04 +0100
commit5cf3abf29e3451ce2a86cfa400e36cbb53552354 (patch)
treebc0c96d1ab343aaab275dc5152388277a1233664 /.app/lib/app-common
parent3cd32904c6b16b3992c0cdaa9997405c8c86c56d (diff)
downloadapp.sh-5cf3abf29e3451ce2a86cfa400e36cbb53552354.tar.gz
app.sh-5cf3abf29e3451ce2a86cfa400e36cbb53552354.tar.bz2
app.sh-5cf3abf29e3451ce2a86cfa400e36cbb53552354.tar.xz
app.sh-5cf3abf29e3451ce2a86cfa400e36cbb53552354.zip
o Making run_control more generic and renamed to run_app.
Diffstat (limited to '.app/lib/app-common')
-rw-r--r--.app/lib/app-common56
1 files changed, 54 insertions, 2 deletions
diff --git a/.app/lib/app-common b/.app/lib/app-common
index 0d33c84..3856430 100644
--- a/.app/lib/app-common
+++ b/.app/lib/app-common
@@ -16,7 +16,14 @@ assert_is_instance() {
$usage "Missing required option -i."
fi
- if [ ! -d $name/$instance ]
+ # Use $APPSH_APPS as prefix if it's set
+ local x=""
+ if [ ! -z "$APPSH_APPS" ]
+ then
+ x="$APPSH_APPS/"
+ fi
+
+ if [ ! -d $x$name/$instance ]
then
echo "No such instance: $name/$instance." >&2
exit 1
@@ -24,7 +31,7 @@ assert_is_instance() {
if [ "$check_link" != "no" ]
then
- if [ ! -e $name/$instance/current ]
+ if [ ! -e $x$name/$instance/current ]
then
echo "Missing 'current' link." >&2
exit 1
@@ -103,3 +110,48 @@ find_versions() {
ls -1d *
)
}
+
+# TODO: set ulimit
+# TODO: set umask
+# TODO: change group newgrp/sg
+run_app() {
+ local name=$1; shift
+ local instance=$1; shift
+ local bin=$1; shift
+ local method=$1; shift
+
+ assert_is_instance operate_usage "$name" "$instance"
+
+ local x=""
+ if [ ! -z "$APPSH_APPS" ]
+ then
+ x="$APPSH_APPS/"
+ fi
+
+ (
+ cd $x$name/$instance
+ APPSH_INSTANCE_HOME=`pwd`
+ cd current
+
+ e="`get_conf_in_group $apps $name $instance env`"
+
+ # Set a default PATH which can be overridden by the application's settings
+ set +e
+ env -i \
+ PATH=/bin:/usr/bin \
+ $e \
+ PWD=$PWD \
+ APPSH_METHOD=$method \
+ APPSH_APPS=$apps \
+ APPSH_HOME=$APPSH_HOME \
+ APPSH_NAME=$name \
+ APPSH_INSTANCE=$instance \
+ APPSH_INSTANCE_HOME=$APPSH_INSTANCE_HOME \
+ $bin "$@"
+ local ret=$?
+ set +x
+ set -e
+
+ exit $ret
+ )
+}