~ubuntu-branches/ubuntu/oneiric/migration-assistant/oneiric

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
#!/bin/sh

set -e
. /usr/share/debconf/confmodule
. /usr/share/migration-assistant/ma-script-utils

IFS='
'

if [ -z "$1" ]; then
    mapath="/usr/bin"
else
    mapath="$1"
fi

error () {
    logger -t migration-assistant "error: $@"
}

log () {
    logger -t migration-assistant "info: $@"
}

db_get migration-assistant/partitions
selection=`echo "$RET" | sed -e 's/, /\n/g'`
for choice in $selection; # Microsoft Windows XP Professional (/dev/hda1)
do
    location=`expr "$choice" : '.*(\(.*\))'` # /dev/hda1
    for line in `os-prober`;
    do
	loc=$(expr match "$line" '\(.*\):.*:.*:.*')
	if [ $location = $loc ]
	then
	    set_os_type $line
	    path=${loc#*/*/}
	    mount_os "$ostype" "$loc"
	    db_get migration-assistant/$path/users
	    user_selection=`echo "$RET" | sed -e 's/, /\n/g'`
	    for usr in $user_selection;
	    do
		db_get migration-assistant/$path/$usr/user
		new_user=$RET

		if [ $(grep -c ^$new_user: $ROOT/etc/passwd) -eq 0 ]; then
		    log "creating user $new_user"

		    db_get migration-assistant/new-user/$new_user/password
		    pass=$RET
		    db_get migration-assistant/new-user/$new_user/fullname
		    fn=$RET

		    add_user $new_user $fn $pass
		fi
		
		db_get migration-assistant/$path/$usr/items
		log "importing: $RET"
		item_selection=`echo "$RET" | sed -e 's/, /\n/g'`
		for itm in $item_selection;
		do
		    itm=$(echo $itm | sed -e 's/ //g' | tr [A-Z] [a-z])
		    log-output -t migration-assistant $mapath/ma-import \
		    --target="$itm" \
		    --ostype="$ostype" \
		    --fromuser="$usr" \
		    --frompath="$mountpoint" \
		    --touser="$new_user" \
		    --topath="$ROOT" \
		    || error "importing $itm failed."
		done
	    done

	    unmount_os
	fi
    done
done