aboutsummaryrefslogtreecommitdiff
path: root/bin/app-init
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-02-01 09:28:18 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2013-02-01 09:28:18 +0100
commit97036aeae73cc2a63219c7b792ab5f18c7d98cd1 (patch)
treeb71a4e0ebde196ad7b4858f4dbaf499b7b3b7201 /bin/app-init
parent537935edab2e847196a46be68956c8ed2300a22a (diff)
downloadapp.sh-97036aeae73cc2a63219c7b792ab5f18c7d98cd1.tar.gz
app.sh-97036aeae73cc2a63219c7b792ab5f18c7d98cd1.tar.bz2
app.sh-97036aeae73cc2a63219c7b792ab5f18c7d98cd1.tar.xz
app.sh-97036aeae73cc2a63219c7b792ab5f18c7d98cd1.zip
libexec/app-resolver-maven: Better argument checking.
lib/common: Starting a way to have a common usage/help semantics.
Diffstat (limited to 'bin/app-init')
-rwxr-xr-xbin/app-init19
1 files changed, 9 insertions, 10 deletions
diff --git a/bin/app-init b/bin/app-init
index 018b210..ba97ebd 100755
--- a/bin/app-init
+++ b/bin/app-init
@@ -8,14 +8,8 @@ APPSH_HOME=$(cd $(dirname "$0")/.. && pwd)
. $APPSH_HOME/lib/common
# HEADER END
-usage() {
- echo "usage: $0 -d dir <resolver> <resolver args>"
- exit 1
-}
-
-fatal() {
- echo "$0: $@"
- exit 1
+usage_inner() {
+ echo "usage: $usage_app -d dir <resolver> <resolver args>"
}
while getopts "d:" opt
@@ -46,8 +40,6 @@ then
fatal "Already initialized: $dir" 2>&1
fi
-# TODO: install a trap handler and rm -rf "$dir"
-
resolver=`grep_path "/app-resolver-$resolver_name$" "$PATH" | head -n 1`
if [ -z "$resolver" ]
@@ -57,6 +49,11 @@ then
fi
mkdir -p -- "$dir" "$dir/.app"
+
+ok=no
+clean_dir=`cd "$dir">/dev/null; pwd`
+trap '[[ $ok == yes ]] || rm -rf "$clean_dir"' EXIT
+
cd "$dir"
app-conf set app.resolver "$resolver_name"
@@ -77,3 +74,5 @@ echo "Resolved version to $version"
"$resolver" download-version -v "$version" -f .app/latest.zip
app-install-file -v "$version" -f .app/latest.zip
+
+ok=yes