Browse Source

allow terms and selection to be specified on the command line...

This allows you to run:
sh snapaid.sh find amd64 vmdk CURRENT xz 1

and it will automatically d/l the latest vm image that is vmdk, xz
compressed for the amd64 architecture.
main
John-Mark Gurney 4 years ago
parent
commit
2855d77e30
Signed by: jmg GPG Key ID: 205F0B33DD006ADA
1 changed files with 14 additions and 6 deletions
  1. +14
    -6
      snapaid.sh

+ 14
- 6
snapaid.sh View File

@@ -313,6 +313,7 @@ if [ x"$1" = x"verify" ]; then
verifyfile "$vermid" "$i" verifyfile "$vermid" "$i"
done done
elif [ x"$1" = x"find" ]; then elif [ x"$1" = x"find" ]; then
shift
fetch "$currenturl" fetch "$currenturl"


tmpdir=$(mktemp -d -t snapaid) tmpdir=$(mktemp -d -t snapaid)
@@ -320,11 +321,12 @@ elif [ x"$1" = x"find" ]; then
trap "rm -r $tmpdir" 0 trap "rm -r $tmpdir" 0


( cd "$tmpdir"; ( cd "$tmpdir";
xzcat "$STOREDIR"/snapshot.idx.xz | sort -r -k 5 > selection;
xzcat "$STOREDIR"/snapshot.idx.xz | sort -r -k 5 -k 2 > selection;
while :; do while :; do
# display current list
cnt=$(wc -l < selection) cnt=$(wc -l < selection)
awk '
if [ x"$1" = x"" ]; then
# display current list
awk '
BEGIN { BEGIN {
# xzcat snapshot.complete.idx.xz | ./maxcol.awk # xzcat snapshot.complete.idx.xz | ./maxcol.awk
# xzcat snapshot.complete.idx.xz | awk "{ print $3}" | sort -u # xzcat snapshot.complete.idx.xz | awk "{ print $3}" | sort -u
@@ -347,9 +349,15 @@ BEGIN {


cnt += 1 cnt += 1
} }
' selection
' selection
fi


read -p 'Select image #, enter search term, reset, or quit: ' sel
if [ x"$1" != x"" ]; then
sel="$1"
shift
else
read -p 'Select image #, enter search term, reset, or quit: ' sel
fi
if [ x"$sel" = x"reset" ]; then if [ x"$sel" = x"reset" ]; then
xzcat "$STOREDIR"/snapshot.idx.xz | sort -r -k 5 > selection; xzcat "$STOREDIR"/snapshot.idx.xz | sort -r -k 5 > selection;
continue continue
@@ -491,7 +499,7 @@ else
fi fi
echo "Usage:" echo "Usage:"
echo " $0 verify file ..." echo " $0 verify file ..."
echo " $0 find"
echo " $0 find [ termselection ... ]"
echo "" echo ""
echo "The verify option will attempt to verify each file specified." echo "The verify option will attempt to verify each file specified."
echo "" echo ""


Loading…
Cancel
Save