summaryrefslogtreecommitdiffstats
path: root/urunlevel/my_linux/Trinux/savehome
blob: 837c63940ea1a7b66f0aebf2a75a7544766e7c21 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/sh

# savehome  - saves home directory to

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



if [ -f /etc/tux/config/home ]
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

[ -d /usr/local/tmp ] || mkdir -p /usr/local/tmp 

cd /
tar cf - home | gzip -f > /usr/local/tmp/$home.tgz
echo "Saving home directory to $USER@$HOST via $PROTO"

cd /usr/local/tmp

if [ "$PROTO" = "ssh" ]
then
	scp $home.tgz $USER@$HOST:~
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 -T $home.tgz ftp://$HOST

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

		ftp $HOST

	fi
fi

if [ "$PROTO" = "fixed" ]
then
	if mount -t $PROTO $HOST /mnt
	then
		[ "$USER" ] && cd /mnt/$USER
		cp /usr/local/tmp/$home.tgz .
		cd /
		umount /mnt
	fi
fi

if [ "$PROTO" = "floppy" ]
then 
	if mount -t vfat /dev/fd0 /mnt
	then
		cp /usr/local/tmp/$home.tgz /mnt
		cd /
		umount /mnt
	else
		echo "Unable to mount floppy"
	fi
fi