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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
#!/bin/sh
LIVE_TERMINAL=""
live_usage()
{
cat <<EOF
'live' plugin:
WARNING: To use the installer without rebooting, the current kernel and the
installer's kernel must have the same version.
-t, --text Force use of text installer
-e, --expert Use expert installation mode
EOF
}
live_prepare()
{
for arg in $@; do
case "$arg" in
-t|--text)
TEXT=true
export TEXT
;;
-e|--expert)
EXPERT=true
export EXPERT
;;
esac
done
if [ "$TEXT" != true ]; then
# Checking for x11
if [ -n "$DISPLAY" ]; then
# Checking for debconf frontend (gnome)
if dpkg -s libgnome2-perl > /dev/null 2>&1; then
export DEBIAN_FRONTEND=gnome
fi
fi
else
export DI_FRONTEND=newt
fi
# Checking for debconf frontend (LIVE_TERMINAL fallback)
if [ -z $DEBIAN_FRONTEND ]; then
LIVE_TERMINAL="x-terminal-emulator -e"
fi
# Find an debian-installer initrd, preferably the gtk one
for IMAGE in /live/image/install/gtk/initrd.gz /live/image/install/initrd.gz; do
[ -e $IMAGE ] && break
done
[ ! -e $IMAGE ] && echo "no suitable d-i initrd image found, aborting." && return 1
echo "Loading debian-installer..."
# Create the temporary directory
mkdir -p /live/installer
# Unpack the initrd
cd /live/installer
zcat $IMAGE | cpio -id > /dev/null 2>&1
$LIVE_TERMINAL /usr/share/debian-installer-launcher/debconf_kernel.sh || return 1
# Preseeding shutdown command
cat >> preseed.cfg << EOF
# Select udeb for installation to allow exiting the installer
d-i anna/choose_modules string di-utils-exit-installer
# Ask question regardless from that it's preseeded above
d-i anna/choose_modules seen false
# Skip the exit timeout
d-i di-utils-reboot/really_reboot boolean false
EOF
# Preseeding installer export mode
if [ "$EXPERT" = true ]; then
cat >> preseed.cfg << EOF
# Setting expert mode
d-i debconf/priority select low
debconf debconf/priority select low
EOF
fi
}
live_cleanup () {
# Stopping syslogd/klogd
# ->the sed horror could be improved (FIXME;)
# string: [A-Z][a-z]: [0-9] [0-9]rce [0-9]...
# we only want the [0-9]rce, but without the rce.
for PID in $(fuser -m /live/installer/var/log/syslog 2>&1 | \
sed "s,.*: ,,g;s, ,\n,g" | grep 'rce$' | \
sed -e 's/rce//g'); do
kill -9 $PID > /dev/null 2>&1 || true
done
# Unmounting filesystems
for fs in /cdrom /dev/pts /dev /proc /sys /tmp; do
umount -f /live/installer/$fs > /dev/null 2>&1 || true
done
# Remove unpacked initrd
rm -rf /live/installer
rm -f /tmp/debian-installer
}
live_run()
{
# Bindmount installer media
mkdir -p /live/installer/cdrom
mount -o bind /live/image /live/installer/cdrom
# Bindmount filesytem
for fs in /dev /dev/pts /proc /sys /tmp; do
mount -o bind $fs /live/installer/$fs
done
if [ -n "$DISPLAY" ]; then
xhost +local:
fi
# Launching debian-installer
/usr/share/debian-installer-launcher/debian-installer.sh
}
|