scripts

misc scripts and tools
git clone git://git.2f30.org/scripts
Log | Files | Refs

sids (826B)


      1 #!/bin/sh
      2 
      3 # path of the signature store
      4 sigstore=$(test -n "$SIGSTORE" && echo "$SIGSTORE" || echo /sigstore)
      5 # paths to be hashed
      6 sigpath=$(test -n "$SIGPATH" && echo "$SIGPATH" || \
      7 	echo /bin:/sbin:/usr)
      8 
      9 set -o noclobber
     10 
     11 usage() {
     12 	echo "usage: $(basename $0) [-gv]" 1>&2
     13 	exit 1
     14 }
     15 
     16 if test $1; then
     17 	option=$1
     18 else
     19 	usage
     20 fi
     21 
     22 mkdir -p "$sigstore"
     23 
     24 case $option in
     25 -g)
     26 	echo "$sigpath" | awk -F: '{for (i=1; i<=NF; i++) {print $i}}' |
     27 	while read path; do
     28 		mtree_path=mtree$(echo "$path" | sed 's/\//_/g')
     29 		mtree -c -K sha256digest -p "$path" > "$sigstore/$mtree_path"
     30 	done
     31 	chmod 600 $sigstore/*
     32 	;;
     33 -v)
     34 	echo "$sigpath" | awk -F: '{for (i=1; i<=NF; i++) {print $i}}' |
     35 	while read path; do
     36 		mtree_path=mtree$(echo "$path" | sed 's/\//_/g')
     37 		mtree -p "$path" < "$sigstore/$mtree_path"
     38 	done
     39 	;;
     40 *)
     41 	usage
     42 	;;
     43 esac