Move check for block device to mount_persistence_media().
[debian-live-boot.git] / components / 0030-verify-checksums
blobdd1c8f89a5227055e4fe9904fb3161632ea967af
1 #!/bin/sh
3 #set -e
5 Verify_checksums ()
7 for _PARAMETER in ${LIVE_BOOT_CMDLINE}
8 do
9 case "${_PARAMETER}" in
10 live-boot.verify-checksums=*|verify-checksums=*)
11 LIVE_VERIFY_CHECKSUMS="true"
12 LIVE_VERIFY_CHECKSUMS_DIGESTS="${_PARAMETER#*verify-checksums=}"
15 live-boot.verify-checksums|verify-checksums)
16 LIVE_VERIFY_CHECKSUMS="true"
18 esac
19 done
21 case "${LIVE_VERIFY_CHECKSUMS}" in
22 true)
26 return 0
28 esac
30 _MOUNTPOINT="${1}"
32 LIVE_VERIFY_CHECKSUMS_DIGESTS="${LIVE_VERIFY_CHECKSUMS_DIGESTS:-sha512 sha384 sha256 sha224 sha1 md5}"
33 _TTY="/dev/tty8"
35 log_begin_msg "Verifying checksums"
37 cd "${_MOUNTPOINT}"
39 for _DIGEST in $(echo ${LIVE_VERIFY_CHECKSUMS_DIGESTS} | sed -e 's|,| |g')
41 _CHECKSUMS="$(echo ${_DIGEST} | tr [a-z] [A-Z])SUMS ${_DIGEST}sum.txt"
43 for _CHECKSUM in ${_CHECKSUMS}
45 if [ -e "${_CHECKSUM}" ]
46 then
47 echo "Found ${_CHECKSUM}..." > "${_TTY}"
49 if [ -e "/bin/${_DIGEST}sum" ]
50 then
51 echo "Checking ${_CHECKSUM}..." > "${_TTY}"
53 # Verify checksums
54 /bin/${_DIGEST}sum -c "${_CHECKSUM}" < "${_TTY}" > "${_TTY}"
55 _RETURN="${?}"
57 # Stop after first verification
58 break
59 else
60 echo "Not found /bin/${_DIGEST}sum..." > "${_TTY}"
63 done
64 done
66 log_end_msg
68 case "${_RETURN}" in
70 log_success_msg "Verification successfull, rebooting in 10 seconds."
71 sleep 10
73 # Unmount live-media
74 cd /
75 umount -f "${_MOUNTPOINT}" > /dev/null 2>&1
76 sync
78 # Attempt to remount all mounted filesystems read-only
79 echo u > /proc/sysrq-trigger
81 # Immediately reboot the system without syncing or unmounting filesystems
82 echo b > /proc/sysrq-trigger
86 panic "Verification failed, $(basename ${_TTY}) for more information."
88 esac