aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-01-27 12:58:25 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2013-01-27 12:58:25 +0100
commit11c930f71db58201994265b71a8f76187f1dbda1 (patch)
treeb0f90a4d631b946e4cb3d3755e9da1e3198aee71
parent6076c500405b7759845496dce6d3b9e1dc619cca (diff)
downloadapp.sh-11c930f71db58201994265b71a8f76187f1dbda1.tar.gz
app.sh-11c930f71db58201994265b71a8f76187f1dbda1.tar.bz2
app.sh-11c930f71db58201994265b71a8f76187f1dbda1.tar.xz
app.sh-11c930f71db58201994265b71a8f76187f1dbda1.zip
o Adding a common header to all scripts.
o Disabling un-used tests and apps for now.
-rw-r--r--Makefile23
-rwxr-xr-xbin/X-app-instance (renamed from bin/app-instance)0
-rwxr-xr-xbin/app-conf12
-rwxr-xr-xbin/app-init10
-rwxr-xr-xbin/app-start11
-rwxr-xr-xbin/app-stop11
-rw-r--r--lib/header8
-rwxr-xr-xlibexec/app-cat-conf20
-rwxr-xr-xlibexec/app-grep-path12
-rwxr-xr-xlibexec/app-install-file12
-rwxr-xr-xlibexec/app-operate (renamed from bin/app-operate)33
-rwxr-xr-xlibexec/app-resolver-maven12
-rwxr-xr-xtest/X-app-help.bats (renamed from test/app-help.bats)0
-rwxr-xr-xtest/X-app-install.bats (renamed from test/app-install.bats)0
-rwxr-xr-xtest/X-app-list-versions.bats (renamed from test/app-list-versions.bats)0
-rwxr-xr-xtest/X-app-list.bats (renamed from test/app-list.bats)0
-rwxr-xr-xtest/X-help.bats (renamed from test/help.bats)0
-rwxr-xr-xtest/X-it-install-remove.bats (renamed from test/it-install-remove.bats)0
18 files changed, 93 insertions, 71 deletions
diff --git a/Makefile b/Makefile
index 2019e13..a3e5e42 100644
--- a/Makefile
+++ b/Makefile
@@ -1,14 +1,33 @@
all: test
-BATS=$(patsubst test/%,%,$(wildcard test/*.bats))
+BINS=$(wildcard bin/app-*) $(wildcard libexec/app-*)
+
+BATS=$(sort $(patsubst test/%,%,$(filter-out test/X-%,$(wildcard test/*.bats))))
TESTS=$(addprefix bats-,$(BATS))
bats-%:
@echo === test/$(patsubst bats-%,%,$@)
@bats test/$(patsubst bats-%,%,$@)
-test: $(TESTS)
+show-tests:
@echo BATS=$(BATS)
@echo TESTS=$(TESTS)
+ @echo $(addprefix set_header-,$(BINS))
+test: show-tests $(TESTS)
.PHONY: test
+
+define set_header
+set_header-$(1):
+ @count=`wc -l lib/header|cut -f 1 -d ' '`; \
+ cat lib/header > x; \
+ echo "# HEADER END" >> x; \
+ sed '1,/HEADER END/d' $(1) >> x; \
+ if [ `md5sum $(1)|cut -f 1 -d ' '` != `md5sum x|cut -f 1 -d ' '` ]; then echo Updated: $(1); cp x $(1); fi; \
+ rm x
+endef
+
+$(foreach f,$(BINS),$(eval $(call set_header,$(f))))
+set-headers: $(addprefix set_header-,$(BINS))
+
+.PHONY: set-headers
diff --git a/bin/app-instance b/bin/X-app-instance
index 02e3c0f..02e3c0f 100755
--- a/bin/app-instance
+++ b/bin/X-app-instance
diff --git a/bin/app-conf b/bin/app-conf
index b890d6d..3602a39 100755
--- a/bin/app-conf
+++ b/bin/app-conf
@@ -1,11 +1,9 @@
#!/bin/bash
-# HEADER START
-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
@@ -125,7 +123,7 @@ case "$command" in
exit 1
fi
- conf_delete "$1" "$2"
+ conf_delete "$1"
;;
*)
if [ -z "$command" ]
diff --git a/bin/app-init b/bin/app-init
index e758916..cca82e1 100755
--- a/bin/app-init
+++ b/bin/app-init
@@ -1,14 +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() {
echo "usage: $0 -d dir <resolver> <resolver args>"
diff --git a/bin/app-start b/bin/app-start
new file mode 100755
index 0000000..be290ce
--- /dev/null
+++ b/bin/app-start
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+set -e
+set -u
+
+APPSH_HOME=$(cd $(dirname "$0")/.. && pwd)
+
+. $APPSH_HOME/lib/common
+# HEADER END
+
+exec $APPSH_HOME/libexec/app-operate "start" "$@"
diff --git a/bin/app-stop b/bin/app-stop
new file mode 100755
index 0000000..535af9e
--- /dev/null
+++ b/bin/app-stop
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+set -e
+set -u
+
+APPSH_HOME=$(cd $(dirname "$0")/.. && pwd)
+
+. $APPSH_HOME/lib/common
+# HEADER END
+
+exec $APPSH_HOME/libexec/app-operate "stop" "$@"
diff --git a/lib/header b/lib/header
new file mode 100644
index 0000000..805e06e
--- /dev/null
+++ b/lib/header
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+set -e
+set -u
+
+APPSH_HOME=$(cd $(dirname "$0")/.. && pwd)
+
+. $APPSH_HOME/lib/common
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/bin/app-operate b/libexec/app-operate
index dc16780..8e4ecac 100755
--- a/bin/app-operate
+++ b/libexec/app-operate
@@ -1,35 +1,12 @@
#!/bin/bash
-if [[ $APPSH_HOME == "" ]]
-then
- APPSH_HOME=`dirname "$0"`
- APPSH_HOME=`cd "$APPSH_HOME/.." && pwd`
-fi
+set -e
+set -u
-operate_usage() {
- if [ -n "$1" ]
- then
- echo "Error:" "$@" >&2
- fi
-
- echo "usage: $0 [operate method] -n name -i instance" >&2
- exit 1
-}
+APPSH_HOME=$(cd $(dirname "$0")/.. && pwd)
-method_operate_usage() {
- if [ -n "$1" ]
- then
- echo "Error:" $@ >&2
- fi
-
- echo "usage: $0 operate <operate method>" >&2
- echo "" >&2
- echo "Available operate methods:" >&2
- echo " start" >&2
- echo " stop" >&2
- echo " restart" >&2
- echo " status" >&2
-}
+. $APPSH_HOME/lib/common
+# HEADER END
method_operate() {
local name="$1"; shift
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-}
diff --git a/test/app-help.bats b/test/X-app-help.bats
index 4b94f23..4b94f23 100755
--- a/test/app-help.bats
+++ b/test/X-app-help.bats
diff --git a/test/app-install.bats b/test/X-app-install.bats
index 18a84bc..18a84bc 100755
--- a/test/app-install.bats
+++ b/test/X-app-install.bats
diff --git a/test/app-list-versions.bats b/test/X-app-list-versions.bats
index de543eb..de543eb 100755
--- a/test/app-list-versions.bats
+++ b/test/X-app-list-versions.bats
diff --git a/test/app-list.bats b/test/X-app-list.bats
index 3092837..3092837 100755
--- a/test/app-list.bats
+++ b/test/X-app-list.bats
diff --git a/test/help.bats b/test/X-help.bats
index eba4eeb..eba4eeb 100755
--- a/test/help.bats
+++ b/test/X-help.bats
diff --git a/test/it-install-remove.bats b/test/X-it-install-remove.bats
index 78f4532..78f4532 100755
--- a/test/it-install-remove.bats
+++ b/test/X-it-install-remove.bats