initial commit

master
KatolaZ 7 years ago
commit fdba713eea
  1. 35
      burrow

@ -0,0 +1,35 @@
#!/bin/sh
### read from $1 and print on stdout a list of DIR selectors
### one per line, terminated by a line with ".\r\n"
## function
get_dirs(){
OLDIFS=$IFS
#IFS=$'\t\n'
## IFS="$(echo t | tr t \\t)
##"
IFS="|"
while read name sel host port; do
## echo " --- name: \"$name\""
## echo " --- sel: \"$sel\""
## echo " --- host: \"$host\""
## echo " --- port: \"$port\""
TYPE=$(echo "$name" | cut -c 1)
## echo " --- TYPE \"$TYPE\""
## echo "$TYPE, $name, $sel, $host, $port"
[ "${TYPE}" = "1" ] && {
port=$(echo $port | sed -r -e 's/\r//g')
dir_id=$(echo "${TYPE}|${sel}|${host}|${port}" | sed 's/^1||/1|\/|/g')
sid=$(echo "${dir_id}" | sha256sum | cut -d " " -f 1 )
echo "${dir_id}|${sid}"
}
done
IFS=$OLDIFS
}
FIN=${1:-"/dev/stdin"}
SRC="$2"
cat "$FIN" | sed -r -e 's/\t/|/g' | get_dirs
Loading…
Cancel
Save