summaryrefslogtreecommitdiffstats
path: root/move/tree/mdk_behind_totem
blob: 82c065bf4099dda2953fc6c7fa5d2ebfd63aebb7 (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
#!/bin/bash

ok=1

while [ -n "$1" ]; do
    case "$1" in
	--boot-loop)
	    boot_loop="$2"
            shift
	    shift
	;;
	--main-loop)
	    main_loop="$2"
            shift
	    shift
	;;
	--totem-pid)
            totem_pid="$2"
            shift
	    shift
	;;
	*)
            ok=''
	    shift
    esac
done

if [ -z "$totem_pid" -o -z "$ok" ]; then
    printf "Usage: mdk_behind_totem [--boot-loop <loop>] [--main-loop <loop>] --totem-pid <pid>\n"
    exit 1
fi

exec &> /tmp/mdk_behind_totem.log

trap 'umount_cd' USR1

umount_cd() {
    echo umount_cd
    busy-files | grep /image/
    busy-files | grep /image_boot/

    umount /image_boot
    losetup -d /dev/$boot_loop

    ln -sf /image_always/lib /
    umount /image
    /image_always/sbin/losetup -d /dev/$main_loop
}

mount_cd() {
    echo mount_cd
    /image_always/sbin/losetup -r -e gz /dev/$main_loop /cdrom/live_tree.clp 
    /image_always/bin/mount /dev/$main_loop /image

    losetup -r -e gz /dev/$boot_loop /cdrom/live_tree_boot.clp 
    mount /dev/$boot_loop /image_boot

    ln -sf /image/lib /

    mdk_move_loop to_cdrom always always_i18n totem
}

while [ -e "/proc/$totem_pid" ]; do
    echo "waiting..."
    /image_totem/bin/sleep 1
done

mount_cd