Commit 4553c87f authored by Niels Möller's avatar Niels Möller
Browse files

New shell script.

Rev: src/lsh-upgrade:1.1
parent b2e3194b
#! /bin/sh
# A script for upgrading files under .lsh for lsh-2.0
werror () {
echo "$1" >&2
}
die () {
werror "$1"
exit 1
}
if [ $# -ne 0 ] ; then
werror "Updates older lsh files to work with lsh-2.0"
werror ""
werror "Usage: lsh-upgrade"
exit 1
fi
: ${SEXP_CONV:=sexp-conv}
cd "$HOME/.lsh" || die "No .lsh directory, so nothing to do."
if [ -s host-acls ] ; then
werror "~/.lsh/host-acls already exists, so I won't touch that."
else
if [ -s known_hosts ] ; then
werror "Converting known_hosts to host-acls"
# These are the changes we must make:
#
# * The subject of an acl must be enclosed in a subject-expression
#
# * Numbers are signed, so the most significant bit of all our
# numbers must be 0. So we add a leading zero octet to numbers
# that need it.
"$SEXP_CONV" -s hex <known_hosts \
| sed -e 's,(entry ,(entry (subject ,' \
-e 's,(tag ,)(tag ,' \
-e 's,(\(.\) #\([89a-fA-F]\),(\1 #00\2,' \
| "$SEXP_CONV" >host-acls
fi
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment