From 11856792221c7faa2f423bc106d1f4b1482bcdb8 Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Wed, 1 Aug 2018 10:27:54 +0100 Subject: new url_to_id and added dry-run in burrow --- burrow | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'burrow') diff --git a/burrow b/burrow index 2665d21..8138ca5 100755 --- a/burrow +++ b/burrow @@ -7,6 +7,19 @@ ### ### where SHA256 is the SHA256SUM of "1|SELECTOR|HOST|PORT" ### +### *** DRY RUN *** +### +### If run as burrow?* (i.e., "burrow" followed by at least one +### character), burrow will run in DRY MODE, i.e., it will just check +### if the id provided as input exists, and then exit. +### +###------------------------------------------------ +### +### (C) Vincenzo 'KatolaZ' Nicosia +### +### Use, modify, redistribute under the terms of the GNU General +### Public License version 3 or, at your option, any other version. +### ## function get_dirs(){ src_id="$1" @@ -56,7 +69,7 @@ retrieve_selector(){ check_selector_present(){ sel_id="$1" sel_dir="$(echo ${sel_id} | cut -c -2)" - [ -d "${sel_dir}" -a -f "${sel_dir}/${sel_id}" ] && exit + [ -d "${sel_dir}" -a -f "${sel_dir}/${sel_id}" ] && echo "${SRC}" >>present && exit ## { ## if at least one of the neighbours of sel_id is missing, cat the entire list of ## neighbours to be re-visited and exit @@ -69,6 +82,8 @@ check_selector_present(){ [ ! -d "${sel_dir}" ] && mkdir -p "${sel_dir}" } +[ $# -lt 1 ] && echo "Usage: $0 " && exit 1 + SRC="$1" @@ -78,5 +93,9 @@ check_selector_present "${src_id}" echo "selector ${src_id} not found" >> logfile.txt -retrieve_selector "$SRC" | sed -r -e 's/\t/|/g' | get_dirs "${src_id}" +MYNAME=$(basename $0) + +if [ -z "${MYNAME##burrow}" ]; then + retrieve_selector "$SRC" | sed -r -e 's/\t/|/g' | get_dirs "${src_id}" +fi -- cgit v1.2.3