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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
|
#!/bin/sh
# set -e
Live ()
{
if [ -x /scripts/local-top/cryptroot ]
then
/scripts/local-top/cryptroot
fi
exec 6>&1
exec 7>&2
exec > boot.log
exec 2>&1
tail -f boot.log >&7 &
tailpid="${!}"
LIVE_BOOT_CMDLINE="${LIVE_BOOT_CMDLINE:-$(cat /proc/cmdline)}"
Cmdline_old
Debug
Read_only
Select_eth_device
if [ -e /conf/param.conf ]
then
. /conf/param.conf
fi
# Needed here too because some things (*cough* udev *cough*)
# changes the timeout
if [ -n "${NETBOOT}" ] || [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ]
then
if do_netmount
then
livefs_root="${mountpoint?}"
else
panic "Unable to find a live file system on the network"
fi
else
if [ -n "${ISCSI_PORTAL}" ]
then
do_iscsi && livefs_root="${mountpoint}"
elif [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
then
# Do a local boot from hd
livefs_root=${ROOT}
else
Setup_Memdisk
# If the live media location is given via command line and access to it
# involves LVM volumes, the corresponding volumes need to be activated.
IFS=','
for dev in $(echo "$LIVE_MEDIA")
do
case "$dev" in
/dev/mapper/*)
eval $(dmsetup splitname --nameprefixes --noheadings --rows "${dev#/dev/mapper/}")
if [ "$DM_VG_NAME" ] && [ "$DM_LV_NAME" ]
then
lvm lvchange -aay -y --sysinit --ignoreskippedcluster "$DM_VG_NAME/$DM_LV_NAME"
fi
;;
/dev/*/*)
# Could be /dev/VG/LV; use lvs to check
if lvm lvs -- "$dev" >/dev/null 2>&1
then
lvm lvchange -aay -y --sysinit --ignoreskippedcluster "$dev"
fi
;;
esac
done
unset IFS
# Scan local devices for the image
i=0
while [ "$i" -lt 60 ]
do
livefs_root=$(find_livefs ${i})
if [ -n "${livefs_root}" ]
then
break
fi
sleep 1
i=$((i + 1))
done
fi
fi
if [ -z "${livefs_root}" ]
then
panic "Unable to find a medium containing a live file system"
fi
Verify_checksums "${livefs_root}"
if [ "${TORAM}" ]
then
live_dest="ram"
elif [ "${TODISK}" ]
then
live_dest="${TODISK}"
fi
if [ "${live_dest}" ]
then
log_begin_msg "Copying live media to ${live_dest}"
copy_live_to "${livefs_root}" "${live_dest}"
log_end_msg
fi
# if we do not unmount the ISO we can't run "fsck /dev/ice" later on
# because the mountpoint is left behind in /proc/mounts, so let's get
# rid of it when running from RAM
if [ -n "$FROMISO" ] && [ "${TORAM}" ]
then
losetup -d /dev/loop0
if is_mountpoint /run/live/fromiso
then
umount /run/live/fromiso
rmdir --ignore-fail-on-non-empty /run/live/fromiso \
>/dev/null 2>&1 || true
fi
fi
if [ -n "${MODULETORAMFILE}" ] || [ -n "${PLAIN_ROOT}" ]
then
setup_unionfs "${livefs_root}" "${rootmnt?}"
else
mac="$(get_mac)"
mac="$(echo "${mac}" | sed 's/-//g')"
mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}"
fi
if [ -n "${ROOT_PID}" ]
then
echo "${ROOT_PID}" > "${rootmnt}"/lib/live/root.pid
fi
log_end_msg
# aufs2 in kernel versions around 2.6.33 has a regression:
# directories can't be accessed when read for the first the time,
# causing a failure for example when accessing /var/lib/fai
# when booting FAI, this simple workaround solves it
ls /root/* >/dev/null 2>&1
# if we do not unmount the ISO we can't run "fsck /dev/ice" later on
# because the mountpoint is left behind in /proc/mounts, so let's get
# rid of it when running from RAM
if [ -n "$FINDISO" ] && [ "${TORAM}" ]
then
losetup -d /dev/loop0
if is_mountpoint /run/live/findiso
then
umount /run/live/findiso
rmdir --ignore-fail-on-non-empty /run/live/findiso \
>/dev/null 2>&1 || true
fi
fi
if [ -f /etc/hostname ] && ! grep -E -q -v '^[[:space:]]*(#|$)' "${rootmnt}/etc/hostname"
then
log_begin_msg "Copying /etc/hostname to ${rootmnt}/etc/hostname"
cp -v /etc/hostname "${rootmnt}/etc/hostname"
log_end_msg
fi
if [ -f /etc/hosts ] && ! grep -E -q -v '^[[:space:]]*(#|$|(127.0.0.1|::1|ff02::[12])[[:space:]])' "${rootmnt}/etc/hosts"
then
log_begin_msg "Copying /etc/hosts to ${rootmnt}/etc/hosts"
cp -v /etc/hosts "${rootmnt}/etc/hosts"
log_end_msg
fi
if [ -L /root/etc/resolv.conf ] ; then
# assume we have resolvconf
DNSFILE="${rootmnt}/etc/resolvconf/resolv.conf.d/base"
else
DNSFILE="${rootmnt}/etc/resolv.conf"
fi
if [ -f /etc/resolv.conf ] && ! grep -E -q -v '^[[:space:]]*(#|$)' "${DNSFILE}"
then
log_begin_msg "Copying /etc/resolv.conf to ${DNSFILE}"
cp -v /etc/resolv.conf "${DNSFILE}"
log_end_msg
fi
if ! [ -d "/lib/live/boot" ]
then
panic "A wrong rootfs was mounted."
fi
Fstab
Netbase
Swap
exec 1>&6 6>&-
exec 2>&7 7>&-
kill ${tailpid}
[ -w "${rootmnt}/var/log/" ] && mkdir -p "${rootmnt}/var/log/live" && ( \
cp boot.log "${rootmnt}/var/log/live" 2>/dev/null; \
cp fsck.log "${rootmnt}/var/log/live" 2>/dev/null )
}
|