aboutsummaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
Diffstat (limited to 'libexec')
-rwxr-xr-xlibexec/app-cat-conf39
-rwxr-xr-xlibexec/app-install-file9
-rwxr-xr-xlibexec/app-operate25
-rwxr-xr-xlibexec/app-operator-pid (renamed from libexec/app-method-pid)8
-rwxr-xr-xlibexec/app-run-hook2
5 files changed, 44 insertions, 39 deletions
diff --git a/libexec/app-cat-conf b/libexec/app-cat-conf
index 5b1c614..857ecaf 100755
--- a/libexec/app-cat-conf
+++ b/libexec/app-cat-conf
@@ -10,14 +10,23 @@ APPSH_HOME=$(cd $(dirname "$0")/.. && pwd)
key_expr="[a-zA-Z][_a-zA-Z0-9]*"
-file=.app/config
+files=()
name=""
+use_default_files=yes
-while getopts "f:n:" opt
+while getopts "f:Dn:" opt
do
case $opt in
f)
file=$OPTARG
+ if [[ $file == "-" ]]
+ then
+ file=/dev/stdin
+ fi
+ files+=($file)
+ ;;
+ D)
+ use_default_files=no
;;
n)
name=$OPTARG
@@ -29,6 +38,19 @@ do
esac
done
+if [[ $use_default_files == yes ]]
+then
+ if [ -r ".app/config" ]
+ then
+ files+=(".app/config")
+ fi
+
+ files+=(${APPSH_DEFAULT_CONFIG-$APPSH_HOME/lib/default-config})
+fi
+
+# TODO: find config files in the paths above $file's paths and perhaps
+# /etc/appsh/config.
+
if [ -z "$name" ]
then
filter="s,^[ ]*\($key_expr\.$key_expr\)[ ]*=[ ]*\(.*\)$,\1=\2,p"
@@ -36,17 +58,10 @@ else
filter="s,^\($name\)=\(.*\),\1=\2,p"
fi
-APPSH_DEFAULT_CONFIG=${APPSH_DEFAULT_CONFIG-$APPSH_HOME/lib/default-config}
-
-# TODO: find config files in the paths above $file's paths and perhaps /etc/appsh/config
-
-if [[ ! -r $file ]]
-then
- fatal "No such file: $file"
-fi
+debug "Using files:" "${files[@]}"
-# The awk script makes sure each key only appears once
-cat "$file" "$APPSH_DEFAULT_CONFIG" | \
+# The awk script makes sure each key only appears once. The first one wins
+cat "${files[@]}" | \
sed -n -e "$filter" | \
awk -F = ' (!($1 in a)){a[$1]; print }' | \
sort
diff --git a/libexec/app-install-file b/libexec/app-install-file
index 1e3edb8..c08a632 100755
--- a/libexec/app-install-file
+++ b/libexec/app-install-file
@@ -54,13 +54,10 @@ then
exit 1
fi
-# TODO: This should go away
-if [ -d current/bin ]
+if [ -r versions/$version/app.config ]
then
- (
- cd $name/$instance/current
- find bin -type f | xargs chmod +x
- )
+ debug "Importing config from package"
+ app-conf import versions/$version/app.config
fi
app-run-hook -v "$version" -h pre-install
diff --git a/libexec/app-operate b/libexec/app-operate
index 007948c..452f658 100755
--- a/libexec/app-operate
+++ b/libexec/app-operate
@@ -10,29 +10,16 @@ APPSH_HOME=$(cd $(dirname "$0")/.. && pwd)
assert_is_app
-method="$1"
+method="$1"; shift
+set -x
-bin=`app-conf get app.method`
-bin=${bin-$APPSH_HOME/.app/libexec/app-method-pid}
+bin=`app-conf get app.operator`
+bin=${bin:-$APPSH_HOME/libexec/app-operator-pid}
-if [ ! -x "current/$bin" ]
+if [ ! -x "$bin" ]
then
echo "Invalid executable: $bin" >&2
exit 1
fi
-case "$method" in
- start) run_app "$name" "$instance" "$bin" "start" "$@" ;;
- stop) run_app "$name" "$instance" "$bin" "stop" "$@" ;;
- status) run_app "$name" "$instance" "$bin" "status" "$@" ;;
- restart) run_app "$name" "$instance" "$bin" "restart" "$@" ;;
- run) run_app "$name" "$instance" "$bin" "run" "$@" ;;
- *)
- if [ -z "$method" ]
- then
- method_operate_usage
- else
- method_operate_usage "Unknown method $method"
- fi
- ;;
-esac
+run_app "$bin" "$@"
diff --git a/libexec/app-method-pid b/libexec/app-operator-pid
index 29f6b4f..a0ff097 100755
--- a/libexec/app-method-pid
+++ b/libexec/app-operator-pid
@@ -1,8 +1,14 @@
#!/bin/bash -e
+#!/bin/bash
+
+set -e
set -u
-. $APPSH_HOME/.app/lib/app-conf
+APPSH_HOME=$(cd $(dirname "$0")/.. && pwd)
+
+. $APPSH_HOME/lib/common
+# HEADER END
pid_file=$APPSH_APPS/.app/var/pid/$APPSH_NAME-$APPSH_INSTANCE.pid
bin=`get_conf $APPSH_APPS $APPSH_NAME $APPSH_INSTANCE app.bin`
diff --git a/libexec/app-run-hook b/libexec/app-run-hook
index ec96c58..6f1eab5 100755
--- a/libexec/app-run-hook
+++ b/libexec/app-run-hook
@@ -45,5 +45,5 @@ fi
# TODO: remove after
#chmod +x $bin
-echo "Running hook: $hook"
+debug "Running hook: $hook"
run_app -v $version hooks/$hook