diff options
Diffstat (limited to 'libexec')
-rwxr-xr-x | libexec/app-cat-conf | 20 | ||||
-rwxr-xr-x | libexec/app-grep-path | 12 | ||||
-rwxr-xr-x | libexec/app-install-file | 12 | ||||
-rwxr-xr-x | libexec/app-operate | 50 | ||||
-rwxr-xr-x | libexec/app-resolver-maven | 12 |
5 files changed, 78 insertions, 28 deletions
diff --git a/libexec/app-cat-conf b/libexec/app-cat-conf index 78d3c36..5da435e 100755 --- a/libexec/app-cat-conf +++ b/libexec/app-cat-conf @@ -1,16 +1,17 @@ #!/bin/bash -if [[ $APPSH_HOME == "" ]] -then - APPSH_HOME=`dirname "$0"` - APPSH_HOME=`cd "$APPSH_HOME/.." && pwd` -fi - set -e +set -u + +APPSH_HOME=$(cd $(dirname "$0")/.. && pwd) + +. $APPSH_HOME/lib/common +# HEADER END key_expr="[a-zA-Z][_a-zA-Z0-9]*" file=.app/config +name="" while getopts "f:n:" opt do @@ -35,13 +36,10 @@ else filter="s,^\($name\)=\(.*\),\1=\2,p" fi -if [[ $APPSH_DEFAULT_CONFIG == "" ]] -then - APPSH_DEFAULT_CONFIG=$APPSH_HOME/lib/default-config -fi +APPSH_DEFAULT_CONFIG=${APPSH_DEFAULT_CONFIG-$APPSH_HOME/lib/default-config} # The awk script makes sure each key only appears once cat "$file" "$APPSH_DEFAULT_CONFIG" | \ - sed -n -e "$filter" $extra | \ + sed -n -e "$filter" | \ awk -F = ' (!($1 in a)){a[$1]; print }' | \ sort diff --git a/libexec/app-grep-path b/libexec/app-grep-path index f5e8287..fa6e5e5 100755 --- a/libexec/app-grep-path +++ b/libexec/app-grep-path @@ -1,13 +1,13 @@ #!/bin/bash -# A command line wrapper around get grep_path function +set -e +set -u -if [[ $APPSH_HOME == "" ]] -then - APPSH_HOME=`dirname "$0"` - APPSH_HOME=`cd "$APPSH_HOME/.." && pwd` -fi +APPSH_HOME=$(cd $(dirname "$0")/.. && pwd) . $APPSH_HOME/lib/common +# HEADER END + +# A command line wrapper around get grep_path function grep_path "$1" "$2" diff --git a/libexec/app-install-file b/libexec/app-install-file index 6c06aa7..a0d929a 100755 --- a/libexec/app-install-file +++ b/libexec/app-install-file @@ -1,10 +1,12 @@ #!/bin/bash -if [[ $APPSH_HOME == "" ]] -then - APPSH_HOME=`dirname "$0"` - APPSH_HOME=`cd "$APPSH_HOME/.." && pwd` -fi +set -e +set -u + +APPSH_HOME=$(cd $(dirname "$0")/.. && pwd) + +. $APPSH_HOME/lib/common +# HEADER END calculate_md5() { local file="$1"; shift diff --git a/libexec/app-operate b/libexec/app-operate new file mode 100755 index 0000000..8e4ecac --- /dev/null +++ b/libexec/app-operate @@ -0,0 +1,50 @@ +#!/bin/bash + +set -e +set -u + +APPSH_HOME=$(cd $(dirname "$0")/.. && pwd) + +. $APPSH_HOME/lib/common +# HEADER END + +method_operate() { + local name="$1"; shift + local instance="$1"; shift + local method="$1" + + if [ $# -gt 0 ] + then + shift + fi + + bin=`$APPSH_HOME/bin/app-cat-conf -f $apps/$name/$instance/current/etc/app.conf -g app -k method | cut -f 2 -d =` + + if [ -z "$bin" ] + then + bin=$APPSH_HOME/.app/lib/pid-method + fi + + if [ ! -x "$name/$instance/current/$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 + exit $? +} diff --git a/libexec/app-resolver-maven b/libexec/app-resolver-maven index cb137fa..a347abb 100755 --- a/libexec/app-resolver-maven +++ b/libexec/app-resolver-maven @@ -1,12 +1,12 @@ -#!/bin/bash -e +#!/bin/bash +set -e set -u -if [[ $APPSH_HOME == "" ]] -then - APPSH_HOME=`dirname "$0"` - APPSH_HOME=`cd "$APPSH_HOME/.." && pwd` -fi +APPSH_HOME=$(cd $(dirname "$0")/.. && pwd) + +. $APPSH_HOME/lib/common +# HEADER END usage() { message=${1-} |