diff options
author | Laurent Ghigonis <laurent@p1sec.com> | 2013-06-18 13:45:58 +0200 |
---|---|---|
committer | Laurent Ghigonis <laurent@p1sec.com> | 2013-06-18 13:45:58 +0200 |
commit | 94f6e5a63eaf17ce4a47ea5ffc054912df9f0c06 (patch) | |
tree | 8cbb0e62637193531c000b62cd569b31c50eb1cd /jsaccess/jstore.sh | |
parent | jsaccess: missed encrypted file (diff) | |
download | laurent-tools-94f6e5a63eaf17ce4a47ea5ffc054912df9f0c06.tar.xz laurent-tools-94f6e5a63eaf17ce4a47ea5ffc054912df9f0c06.zip |
jsaccess: ./ can be store
Diffstat (limited to 'jsaccess/jstore.sh')
-rwxr-xr-x | jsaccess/jstore.sh | 29 |
1 files changed, 22 insertions, 7 deletions
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 "<!-- DO NOT EDIT THIS FILE, part of jsaccess -->" >> $store/index.html echo "CREATED store \"$store\"" } |