| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
LIVE_TERMINAL="" |
| 4 |
|
| 5 |
live_usage() |
| 6 |
{ |
| 7 |
cat <<EOF |
| 8 |
'live' plugin: |
| 9 |
|
| 10 |
WARNING: To use the installer without rebooting, the current kernel and the |
| 11 |
installer's kernel must have the same version. |
| 12 |
|
| 13 |
-t, --text Force use of text installer |
| 14 |
-e, --expert Use expert installation mode |
| 15 |
EOF |
| 16 |
} |
| 17 |
|
| 18 |
live_prepare() |
| 19 |
{ |
| 20 |
for arg in $@; do |
| 21 |
case "$arg" in |
| 22 |
-t|--text) |
| 23 |
TEXT=true |
| 24 |
export TEXT |
| 25 |
;; |
| 26 |
|
| 27 |
-e|--expert) |
| 28 |
EXPERT=true |
| 29 |
export EXPERT |
| 30 |
;; |
| 31 |
esac |
| 32 |
done |
| 33 |
|
| 34 |
if [ -z "$DISPLAY" ]; then |
| 35 |
TEXT=true |
| 36 |
export TEXT |
| 37 |
fi |
| 38 |
|
| 39 |
if [ "$TEXT" != true ]; then |
| 40 |
# Checking for x11 |
| 41 |
if [ -n "$DISPLAY" ]; then |
| 42 |
# Checking for debconf frontend (gnome) |
| 43 |
if dpkg -s libgtk3-perl > /dev/null 2>&1; then |
| 44 |
DEBIAN_FRONTEND=gnome |
| 45 |
export DEBIAN_FRONTEND |
| 46 |
fi |
| 47 |
fi |
| 48 |
else |
| 49 |
DI_FRONTEND=newt |
| 50 |
export DI_FRONTEND |
| 51 |
[ "$TEXT" = true ] && export DEBIAN_FRONTEND=text |
| 52 |
fi |
| 53 |
|
| 54 |
# Checking for debconf frontend (LIVE_TERMINAL fallback) |
| 55 |
if [ -z $DEBIAN_FRONTEND ]; then |
| 56 |
LIVE_TERMINAL="x-terminal-emulator -e" |
| 57 |
fi |
| 58 |
|
| 59 |
# Find an debian-installer initrd, preferably the gtk one |
| 60 |
for IMAGE in /run/live/medium/install/gtk/initrd.gz /run/live/medium/install/initrd.gz; do |
| 61 |
[ -e $IMAGE ] && break |
| 62 |
done |
| 63 |
|
| 64 |
[ ! -e $IMAGE ] && echo "no suitable d-i initrd image found, aborting." && return 1 |
| 65 |
|
| 66 |
echo "Loading debian-installer..." |
| 67 |
|
| 68 |
# Create the temporary directory and mount a tmpfs on it to ease cleanup |
| 69 |
mkdir -p /run/live/installer |
| 70 |
mount -t tmpfs none /run/live/installer |
| 71 |
|
| 72 |
# Unpack the initrd |
| 73 |
cd /run/live/installer |
| 74 |
zcat $IMAGE | cpio -id > /dev/null 2>&1 |
| 75 |
|
| 76 |
$LIVE_TERMINAL /usr/share/debian-installer-launcher/debconf_kernel.sh || return 1 |
| 77 |
|
| 78 |
# Preseeding shutdown command |
| 79 |
cat >> preseed.cfg << EOF |
| 80 |
# Select udeb for installation to allow exiting the installer |
| 81 |
d-i anna/choose_modules string di-utils-exit-installer apt-cdrom-udeb |
| 82 |
# Ask question regardless from that it's preseeded above |
| 83 |
d-i anna/choose_modules seen false |
| 84 |
# Skip the exit timeout |
| 85 |
d-i di-utils-reboot/really_reboot boolean false |
| 86 |
EOF |
| 87 |
|
| 88 |
# Preseeding installer expert mode |
| 89 |
if [ "$EXPERT" = true ]; then |
| 90 |
cat >> preseed.cfg << EOF |
| 91 |
# Setting expert mode |
| 92 |
d-i debconf/priority select low |
| 93 |
debconf debconf/priority select low |
| 94 |
EOF |
| 95 |
fi |
| 96 |
} |
| 97 |
|
| 98 |
live_cleanup () { |
| 99 |
# Stopping syslogd/klogd |
| 100 |
# These processes are assumed to be the only users of busybox within the chroot |
| 101 |
# which is a bit of a grubby way to identify them, but holds true for now. |
| 102 |
fuser -k /run/live/installer/bin/busybox > /dev/null 2>&1 || true |
| 103 |
|
| 104 |
# Remove unpacked initrd |
| 105 |
cd |
| 106 |
umount -l /run/live/installer |
| 107 |
rm -f /tmp/debian-installer |
| 108 |
} |
| 109 |
|
| 110 |
live_run() |
| 111 |
{ |
| 112 |
# Bindmount installer media |
| 113 |
mkdir -p /run/live/installer/cdrom |
| 114 |
mount -o bind /run/live/medium /run/live/installer/cdrom |
| 115 |
|
| 116 |
# Bindmount filesytem |
| 117 |
for fs in /dev /dev/pts /proc /sys /tmp; do |
| 118 |
mount -o bind $fs /run/live/installer/$fs |
| 119 |
done |
| 120 |
|
| 121 |
if [ -n "$DISPLAY" ]; then |
| 122 |
xhost +local: |
| 123 |
fi |
| 124 |
|
| 125 |
# Launching debian-installer |
| 126 |
/usr/share/debian-installer-launcher/debian-installer.sh |
| 127 |
} |