(i) localization, warnings,(s) add SPOKES_UP
This initiall version of SPOKES_UP has only the most minimal of guards to avoid unneeded operations.
This commit is contained in:
parent
add3204f83
commit
88837a27c2
1 changed files with 70 additions and 10 deletions
80
ghostwheel.fn.sh
Executable file → Normal file
80
ghostwheel.fn.sh
Executable file → Normal file
|
|
@ -544,7 +544,7 @@ function c4.i.val {
|
|||
local src=$( c4.fa_src $@ )
|
||||
if test -z "$src" -o ! -r "$src" ; then
|
||||
# || test 0 == "$(file "$src" | grep text >2 2>&1; echo $?)"
|
||||
echo "WARN" "C4R${C4_RUN}${C4_TR}_VAL: missing SRC" >&2 # LOG
|
||||
echo "WARN" "C4R${C4_RUN}${C4_TR}_VAL: BAD SRC ($src)" >&2 # LOG
|
||||
return 1;
|
||||
fi
|
||||
head -1 $src
|
||||
|
|
@ -555,7 +555,7 @@ function c4.i.val {
|
|||
function c4.i.vals {
|
||||
local src=$( c4.fa_src $@ )
|
||||
if test -z "$src" -o ! -r "$src" ; then
|
||||
echo "WARN" "C4R${C4_RUN}${C4_TR}_VAL: missing SRC" >&2 # LOG
|
||||
echo "WARN" "C4R${C4_RUN}${C4_TR}_VAL: BAD SRC ($src)" >&2 # LOG
|
||||
return 1;
|
||||
fi
|
||||
cat $src
|
||||
|
|
@ -630,6 +630,7 @@ function c4.i.set {
|
|||
|
||||
## return identity source of [[ <context1> [...]] query
|
||||
## where QUERY (and CONTEXT1, etc, if provided) are words
|
||||
C4_I_ID=.
|
||||
function c4.i.of {
|
||||
local context="$C4_IS";
|
||||
local query=$1; shift;
|
||||
|
|
@ -661,7 +662,7 @@ function c4.i.of {
|
|||
fi
|
||||
|
||||
# return valid seeming identity file
|
||||
printf '%s/.%s' "$context" "$query"
|
||||
printf '%s/%s%s' "$context" "$C4_I_ID" "$query"
|
||||
}
|
||||
|
||||
# return true when given an existant identity
|
||||
|
|
@ -703,15 +704,56 @@ function c4.h.array {
|
|||
|
||||
C4_TR='S'; ### SPOKES
|
||||
|
||||
C4_S_IS="${C4_S_IS-spoke}"
|
||||
C4_S_IS_SI=spoke
|
||||
## return true when given an existant spoke
|
||||
function c4.s.is {
|
||||
( C4_ROOT=$C4_SPOKES;
|
||||
C4_IS=$C4_SPOKES;
|
||||
c4.i.has $@ $C4_S_IS )
|
||||
local C4_ROOT=$C4_SPOKES;
|
||||
local C4_IS=$C4_SPOKES;
|
||||
|
||||
c4.i.of $@ $C4_S_IS_SI # 2>/dev/null
|
||||
}
|
||||
|
||||
C4_S_SSHFS_CMD="ssh"
|
||||
C4_S_READY_Q=
|
||||
C4_S_READY_OK=OK
|
||||
C4_S_READY_NOTOK=
|
||||
function c4.s.ready {
|
||||
local quiet=$C4_S_READY_Q;
|
||||
case $1 in
|
||||
-q) quiet=1; shift ;;
|
||||
esac
|
||||
|
||||
local f=$( c4.s.is $@ );
|
||||
|
||||
test -n "$f" -a -r "$f"
|
||||
local rv=$?
|
||||
|
||||
if test -z "$quiet" ; then
|
||||
if test 0 -eq "$rv" ; then
|
||||
echo $C4_S_READY_OK
|
||||
else
|
||||
echo $C4_S_READY_NOTOK
|
||||
fi
|
||||
fi
|
||||
|
||||
return $rv
|
||||
}
|
||||
|
||||
C4_S_IS=spokes
|
||||
function c4.s.spokes {
|
||||
local C4_IS=$C4_SS;
|
||||
local C4_I_ID=
|
||||
|
||||
local src=$( c4.i.of $C4_S_IS $@ )
|
||||
if test -n "$src" -a -r "$src" ; then
|
||||
c4.i.vals $src;
|
||||
fi
|
||||
}
|
||||
|
||||
function c4.i.spokes {
|
||||
c4.i.vals $( c4.i.of $C4_S_IS )
|
||||
}
|
||||
|
||||
C4_S_SSHFS_CMD="echo sshfs"
|
||||
C4_S_SSHFS_OPT="-o allow_other"
|
||||
function c4.s.sshfs {
|
||||
if test -z "$1"; then
|
||||
|
|
@ -720,11 +762,11 @@ function c4.s.sshfs {
|
|||
fi
|
||||
if test -z "$2"; then
|
||||
echo "WARN" "C4R${C4_RUN}S_SSHFS: missing TO (FROM \"$1\")" >&2 # LOG
|
||||
return 1;
|
||||
return 2;
|
||||
fi
|
||||
if test ! -d "$2"; then
|
||||
echo "WARN" "C4R${C4_RUN}S_SSHFS: missing or non-directory TO \"$2\" (FROM \"$1\")" >&2 # LOG
|
||||
return 1;
|
||||
return 3;
|
||||
fi
|
||||
$C4_S_SSHFS_CMD $C4_S_SSHFS_OPT $@
|
||||
}
|
||||
|
|
@ -837,6 +879,24 @@ _c4_cmd_debug="$(c4.s.first "$_C4_CMD_DEBUG" "$C4_DEBUG")"
|
|||
# fi
|
||||
# }
|
||||
|
||||
C4_TR=w # wheels-up!
|
||||
|
||||
## brute force all the things
|
||||
function c4.SPOKES_UP {
|
||||
local s;
|
||||
local i;
|
||||
local rv=0;
|
||||
for i in $( c4.i.spokes ) ; do
|
||||
for s in $( c4.s.spokes $i ); do
|
||||
c4.s.ready -q $s $i || c4.s.sshfs $s:/$i $C4_SPOKES/$s/$i;
|
||||
rv=$((rv+$?))
|
||||
done ;
|
||||
done
|
||||
return $rv
|
||||
}
|
||||
|
||||
|
||||
|
||||
####
|
||||
#### END
|
||||
####
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue