From 94f6e5a63eaf17ce4a47ea5ffc054912df9f0c06 Mon Sep 17 00:00:00 2001 From: Laurent Ghigonis Date: Tue, 18 Jun 2013 13:45:58 +0200 Subject: jsaccess: ./ can be store --- jsaccess/jsa/store/index.html | 1 + jsaccess/jstore.sh | 29 ++++++++++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) (limited to 'jsaccess') diff --git a/jsaccess/jsa/store/index.html b/jsaccess/jsa/store/index.html index d47b0f4..9146c8e 100644 --- a/jsaccess/jsa/store/index.html +++ b/jsaccess/jsa/store/index.html @@ -1 +1,2 @@ The monster has emptied me ! + diff --git a/jsaccess/jstore.sh b/jsaccess/jstore.sh index ea19ea0..bd88109 100755 --- a/jsaccess/jstore.sh +++ b/jsaccess/jstore.sh @@ -64,16 +64,30 @@ confirm_exit() { fi } +__store_test() { + dir=$1 + [ ! -d $dir ] && return 1 + [ ! -f $dir/index.html ] && return 1 + [ X"`grep -c "The monster has emptied me" $dir/index.html 2>/dev/null`" != X"1" ] && return 1 + return 0 +} + _store_get() { - store="" - [[ -d ./jsa/store/ ]] && store="`readlink -f ./jsa/store/`" # priority 3 - [[ -d ./store/ ]] && store="`readlink -f ./store/`" # priority 2 - [[ X"$1" != X"" ]] && store=$1 # priority 1 + store=$1 + local_tries="./ ./store/ ./jsa/store/" + if [ X"$store" = X"" ]; then + for s in $local_tries; do + __store_test $s && store=$s && break + done + else + __store_test $store + [ $? -ne 0 ] && echo "ERROR: specified store is invalid !" && \ + clean_exit 1 + fi [[ -z $store ]] && echo "ERROR: store not found !" && \ echo "Not specified as argument and local stores" \ - "./store/ or ./jsa/store/ not found" && clean_exit 1 - [[ ! -d $store ]] && echo "ERROR: specified store does not exist !" && \ - echo "Cannot access $store" && clean_exit 1 + "$local_tries not found" && clean_exit 1 + store=`readlink -f $store` echo "Using store \"$store\"" } @@ -197,6 +211,7 @@ action_init() { store=$1 mkdir $store ||clean_exit 1 echo "The monster has emptied me !" > $store/index.html + echo "" >> $store/index.html echo "CREATED store \"$store\"" } -- cgit v1.2.3-59-g8ed1b