[scripts,remaster] implement "Check disc for defects" boot option
This commit is contained in:
39
scripts/cdupdate.sh
Executable file
39
scripts/cdupdate.sh
Executable 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
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user