summaryrefslogtreecommitdiffstats
path: root/urunlevel/my_linux/Trinux/gethome
blob: c47c2382b8b079b5155f9a39f8d8be59785d8d10 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh

if [ "$1" ]
then
	home=$1
else
	home="home"
fi

homeline=`cat /etc/tux/config/home`

if [ "$homeline" ]
then
	PROTO=`cut -d':' -f1 /etc/tux/config/home`
	HOST=`cut -d':' -f2 /etc/tux/config/home`
	USER=`cut -d':' -f3 /etc/tux/config/home`
else
	echo -n "ftp or ssh: "
	read PROTO
	echo -n "Host: "
	read HOST
	echo -n "User: "
	read USER
	echo $PROTO:$HOST:$USER > /etc/tux/config/home
fi


echo "Retrieving home directory from $USER@$HOST via $PROTO"

if [ $PROTO = "ssh" ]
then
	scp $USER@$HOST:~/$home.tgz / 
fi

if [ $PROTO = "ftp" ]
then
	echo "Using FTP to transfor $home.tgz -- your passwords are sniffable"

	if [ -x /usr/bin/curl ]
	then
		curl -u $USER ftp://$HOST/$home.tgz > /$home.tgz

	else
		echo "Curl is not installed.  You will have to login with your" 
                echo "username and upload $home.tgz manually"

		ftp $HOST

	fi
fi

cd /
echo
echo "Uncompressing archive..."
gunzip -c $home.tgz | tar xvf -
rm /$home.tgz 2> /dev/null