aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Ghigonis <laurent@p1sec.com>2013-06-18 13:45:58 +0200
committerLaurent Ghigonis <laurent@p1sec.com>2013-06-18 13:45:58 +0200
commit94f6e5a63eaf17ce4a47ea5ffc054912df9f0c06 (patch)
tree8cbb0e62637193531c000b62cd569b31c50eb1cd
parentjsaccess: missed encrypted file (diff)
downloadlaurent-tools-94f6e5a63eaf17ce4a47ea5ffc054912df9f0c06.tar.xz
laurent-tools-94f6e5a63eaf17ce4a47ea5ffc054912df9f0c06.zip
jsaccess: ./ can be store
-rw-r--r--jsaccess/jsa/store/index.html1
-rwxr-xr-xjsaccess/jstore.sh29
2 files changed, 23 insertions, 7 deletions
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 !
+<!-- DO NOT EDIT THIS FILE, part of jsaccess -->
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\""
}