[scripts,remaster] implement "Check disc for defects" boot option

This commit is contained in:
Fabio Erculiani 2012-09-04 00:23:54 +02:00
parent a3c8df8783
commit 4c061ea843
8 changed files with 110 additions and 15 deletions

View File

@ -3,17 +3,22 @@ default console
label console
menu label Start Sabayon __VERSION__ SpinBase
kernel /boot/sabayon
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot looptype=squashfs loop=/livecd.squashfs splash=verbose,theme:sabayon vga=791 gfxpayload=1024x768x16 gentoo=nox nox console=tty1 quiet --
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot cdroot_type=udf looptype=squashfs loop=/livecd.squashfs splash=verbose,theme:sabayon __KMS__ vga=791 gfxpayload=1024x768x16 gentoo=nox nox console=tty1 quiet --
label text-install
menu label ^Installation
kernel /boot/sabayon
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot looptype=squashfs loop=/livecd.squashfs splash=verbose,theme:sabayon vga=791 gfxpayload=1024x768x16 console=tty1 quiet installer-text gentoo=nox nox --
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot cdroot_type=udf looptype=squashfs loop=/livecd.squashfs splash=verbose,theme:sabayon __KMS__ vga=791 gfxpayload=1024x768x16 console=tty1 quiet installer-text gentoo=nox nox --
label genuine
menu label Start in Safe ^Mode
kernel /boot/sabayon
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot looptype=squashfs loop=/livecd.squashfs splash=silent,theme:sabayon vga=788 gfxpayload=800x600x16 noproprietary res=1024x768 pci=routeirq irqpoll console=tty1 quiet nokvm --
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot cdroot_type=udf looptype=squashfs loop=/livecd.squashfs splash=silent,theme:sabayon __KMS__ vga=788 gfxpayload=800x600x16 noproprietary res=1024x768 pci=routeirq irqpoll console=tty1 quiet nokvm --
label checkdisk
menu label ^Check disc for defects
kernel /boot/sabayon
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot cdroot_type=udf looptype=squashfs loop=/livecd.squashfs splash=verbose,theme:sabayon __KMS__ vga=791 console=tty1 quiet checkdisc --
label debug
menu label Deb^ug mode

View File

@ -30,6 +30,11 @@ label debug
kernel /boot/sabayon
append root=/dev/ram0 initrd=/boot/sabayon.igz init=/linuxrc cdroot cdroot_type=udf looptype=squashfs loop=/livecd.squashfs __KMS__ console=tty1 debug --
label checkdisk
menu label ^Check disc for defects
kernel /boot/sabayon
append root=/dev/ram0 initrd=/boot/sabayon.igz init=/linuxrc cdroot cdroot_type=udf looptype=squashfs loop=/livecd.squashfs splash=verbose,theme:sabayon __KMS__ vga=791 console=tty1 quiet checkdisc --
label memtest
menu label Memory ^test
kernel /boot/memtest

View File

@ -60,6 +60,11 @@ label console32
kernel /boot/sabayon32
append root=/dev/ram0 initrd=/boot/sabayon32.igz aufs init=/linuxrc cdroot cdroot_type=udf looptype=squashfs loop=/livecd32.squashfs splash=verbose,theme:sabayon __KMS__ vga=791 gfxpayload=1024x768x16 gentoo=nox nox console=tty1 quiet --
label checkdisk
menu label ^Check disc for defects
kernel /boot/sabayon64
append root=/dev/ram0 initrd=/boot/sabayon64.igz aufs init=/linuxrc cdroot cdroot_type=udf looptype=squashfs loop=/livecd64.squashfs splash=verbose,theme:sabayon __KMS__ vga=791 console=tty1 quiet checkdisc --
label memtest
menu label Memory ^test
kernel /boot/memtest

View File

@ -25,6 +25,11 @@ label console
kernel /boot/sabayon
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot cdroot_type=udf looptype=squashfs loop=/livecd.squashfs splash=verbose,theme:sabayon __KMS__ vga=791 gfxpayload=1024x768x16 gentoo=nox nox console=tty1 quiet --
label checkdisk
menu label ^Check disc for defects
kernel /boot/sabayon
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot cdroot_type=udf looptype=squashfs loop=/livecd.squashfs splash=verbose,theme:sabayon __KMS__ vga=791 console=tty1 quiet checkdisc --
label debug
menu label Deb^ug mode
kernel /boot/sabayon

View File

@ -3,17 +3,22 @@ default console
label console
menu label Start Sabayon __VERSION__ ServerBase
kernel /boot/sabayon
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot cdroot_type=udf looptype=squashfs loop=/livecd.squashfs splash=verbose,theme:sabayon vga=791 gfxpayload=1024x768x16 console=tty1 quiet --
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot cdroot_type=udf looptype=squashfs loop=/livecd.squashfs splash=verbose,theme:sabayon __KMS__ vga=791 gfxpayload=1024x768x16 console=tty1 quiet --
label text-install
menu label ^Installation
kernel /boot/sabayon
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot cdroot_type=udf looptype=squashfs loop=/livecd.squashfs splash=verbose,theme:sabayon vga=791 gfxpayload=1024x768x16 console=tty1 quiet installer-text --
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot cdroot_type=udf looptype=squashfs loop=/livecd.squashfs splash=verbose,theme:sabayon __KMS__ vga=791 gfxpayload=1024x768x16 console=tty1 quiet installer-text --
label genuine
menu label Start in Safe ^Mode
kernel /boot/sabayon
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot cdroot_type=udf looptype=squashfs loop=/livecd.squashfs splash=silent,theme:sabayon vga=788 gfxpayload=800x600x16 noproprietary res=1024x768 pci=routeirq irqpoll console=tty1 quiet nokvm --
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot cdroot_type=udf looptype=squashfs loop=/livecd.squashfs splash=silent,theme:sabayon __KMS__ vga=788 gfxpayload=800x600x16 noproprietary res=1024x768 pci=routeirq irqpoll console=tty1 quiet nokvm --
label checkdisk
menu label ^Check disc for defects
kernel /boot/sabayon
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot cdroot_type=udf looptype=squashfs loop=/livecd.squashfs splash=verbose,theme:sabayon __KMS__ vga=791 console=tty1 quiet checkdisc --
label debug
menu label Deb^ug mode

View File

@ -27,11 +27,17 @@ label genuine
menu label Safe ^Mode
kernel /boot/sabayon
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot cdroot_type=udf looptype=squashfs loop=/livecd.squashfs splash=silent,theme:sabayon __KMS__ vga=788 gfxpayload=800x600x16 noproprietary res=1024x768 pci=routeirq irqpoll console=tty1 quiet nokvm --
label console
menu label ^Console mode
kernel /boot/sabayon
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot cdroot_type=udf looptype=squashfs loop=/livecd.squashfs splash=verbose,theme:sabayon __KMS__ vga=791 gfxpayload=1024x768x16 gentoo=nox nox console=tty1 quiet --
label checkdisk
menu label ^Check disc for defects
kernel /boot/sabayon
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot cdroot_type=udf looptype=squashfs loop=/livecd.squashfs splash=verbose,theme:sabayon __KMS__ vga=791 console=tty1 quiet checkdisc --
label debug
menu label Deb^ug mode
kernel /boot/sabayon

39
scripts/cdupdate.sh Executable file
View File

@ -0,0 +1,39 @@
#!/bin/sh
CDROOT=/mnt/cdrom
CHECK_DISC=$(cat /proc/cmdline | grep checkdisc)
if [ -n "${CHECK_DISC}" ]; then
echo "Checking Live System Image for defects..."
cd "${CDROOT}" || exit 1
all_fine=1
for shafile in $(find "${CDROOT}" -name "*.sha256"); do
target_file="${shafile/.sha256}"
echo -en "Checking ${target_file} ... "
target_sha=$(sha256sum "${target_file}" 2> /dev/null | cut -d" " -f 1)
shafile_sha=$(cat "${shafile}" | cut -d" " -f 1)
if [ "${target_sha}" != "${shafile_sha}" ]; then
echo
echo "target = ${target_sha}"
echo "expect = ${shafile_sha}"
echo
echo "ATTENTION ATTENTION ATTENTION"
echo "This Live System won't properly work"
echo "Your DVD, USB stick or ISO image is damaged"
echo "ATTENTION ATTENTION ATTENTION"
all_fine=0
break
else
echo "OK"
fi
done
echo
if [ "${all_fine}" = "1" ]; then
echo "All fine baby, the Live System is healthy"
else
echo "Ouch... I am very sorry!"
fi
echo "Press Enter key (yeah, that one) to reboot"
read
reboot -f
fi

View File

@ -2,14 +2,39 @@
LIVECD_SQUASHFS="${CDROOT_DIR}/livecd.squashfs"
# Path to molecules.git dir
SABAYON_MOLECULE_HOME="${SABAYON_MOLECULE_HOME:-/sabayon}"
export SABAYON_MOLECULE_HOME
echo
echo "Generating sha256sums..."
echo
# create sha256 file for livecd.squashfs
if [ -f "${LIVECD_SQUASHFS}" ]; then
echo
echo "Generating SHA256 of ${LIVECD_SQUASHFS}..."
echo
(
squash_dir=$(dirname "${LIVECD_SQUASHFS}")
squash_name=$(basename "${LIVECD_SQUASHFS}")
cd "${squash_dir}" && \
sha256sum "${squash_name}" > "${squash_name}.sha256"
)
echo "Doing ${LIVECD_SQUASHFS}..."
squash_dir=$(dirname "${LIVECD_SQUASHFS}")
squash_name=$(basename "${LIVECD_SQUASHFS}")
pushd "${squash_dir}" > /dev/null && \
sha256sum "${squash_name}" > "${squash_name}.sha256" && \
popd > /dev/null
fi
# files inside /boot now
if [ -d "${CDROOT_DIR}/boot" ]; then
for bootfile in "${CDROOT_DIR}"/boot/* ; do
if [ -f "${bootfile}" ]; then
echo "Doing ${bootfile}..."
boot_dir=$(dirname "${bootfile}")
boot_name=$(basename "${bootfile}")
pushd "${boot_dir}" > /dev/null && \
sha256sum "${boot_name}" > "${boot_name}.sha256" && \
popd > /dev/null
fi
done
fi
# move cdupdate.sh in place
cp "${SABAYON_MOLECULE_HOME}/scripts/cdupdate.sh" "${CDROOT_DIR}/cdupdate.sh" && \
chmod +x "${CDROOT_DIR}/cdupdate.sh" && \
chown root:root "${CDROOT_DIR}/cdupdate.sh"