summaryrefslogtreecommitdiff
path: root/conf_convert.sh
blob: fb0c9990bbffef15e6504cb0d9e1064a1014ee2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh

# conf_convert.sh - convert rssh config files from 2.0 - 2.1.1 format to rssh
#                   version 2.2 format config files.

if [ -z "$TMPDIR" ]; then
	TMPDIR=/tmp
fi

tempdir=`mktemp -d "$TMPDIR/confconv.tempXXXXXX"`
if [ ! -d "$tempdir" ]; then
	echo "$0: unable to make temporary directory"
	exit 1
fi

if [ "$#" != "0"  ]; then

	while [ -n "$1" ]; do

		if [ ! -f "$1" ]; then
			echo "$0: $1 does not exist.  Skipping." >&2
			continue
		fi

		sed 's/^\([# ]*user *= *.*:\)\([01][01][^0-9"'\''].*\)$/\1000\2/' $1 > "$tempdir/tempconf"

		mv "$tempdir/tempconf" "$1.NEW"
		shift
	done

else
	if [ ! -f /etc/rssh.conf ]; then
		echo "/etc/rssh.conf does not exist, and no parameters given." >&2
		exit 2
	fi

	sed 's/^\([# ]*user *= *.*:\)\([01][01][^0-9"'\''].*\)$/\1000\2/' /etc/rssh.conf > "$tempdir/tempconf"
		
	mv "$tempdir/tempconf" "/etc/rssh.conf.NEW"

fi

rm -rf "$tempdir"

exit 0