summaryrefslogtreecommitdiff
path: root/finish-ra
blob: 8836b9f24343e58bf71aae961b22c7f8a06331f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh

if [ -z "$1" ]; then
	echo "Usage: $0 <comment>" 1>&2
	exit 1
fi

comment=$1
perl -i -e '$host="'ra-$comment'"; $/=undef; $_=<>; s/^Host\s+(${host}$).*?((?=^Host)|\s*\Z)//gsm; print' ~/.ssh/config
sed -i "/ra-[0-8]\+-$comment-[0-9]\+$/d" ~/.ssh/authorized_keys
count=`ls ~/ra/ra-*-$comment-*.tar.gz 2>/dev/null | wc -l`
if [ $count -eq 0 ]; then
	echo "No files with name $comment in ~/ra." 1>&2
	ls ~/ra-*-$comment-*.tar.gz
	exit 1
fi
mv -f ~/ra/ra-*-$comment-*.tar.gz ~/ra/ra-*-$comment-*-key ~/ra/old 2>/dev/null