agama/live/root/usr/bin/checkmedia-service
Ladislav Slezák 39a9a79022
feat(live): Implement the media check functionality (#1958)
## Problem

- Selecting the "Mediacheck" boot option does nothing, it just starts
Agama as usually

## Solution

- Implement a systemd service which runs the `mediacheck` tool when the
`mediacheck=1` boot option is used

## Details

- After finishing the check Agama starts as usually
- When the check fails then the system is halted to prevent from using a
broken medium. (Of course, user can always reboot the system manually
and use it anyway, but we should clearly indicate that it is a bad
idea.)

## Testing

- Tested manually

## Screenshots


![agama-mediacheck](https://github.com/user-attachments/assets/9966d275-6bb5-4006-b4ad-74eef9f95e8a)
2025-02-07 09:40:10 +01:00

28 lines
901 B
Bash
Executable file

#! /bin/sh
# Note: the LIVE_MEDIUM_LABEL placeholder is replaced by the real label in config.sh script
# get the partition where the live ISO is mounted, the real name is set by the
# config.sh script which gets the live partition label name from KIWI
disk=$(blkid -L "@@LIVE_MEDIUM_LABEL@@")
if [ -z "$disk" ]; then
echo -e "\e[31mPartition \"@@LIVE_MEDIUM_LABEL@@\" not found, skipping media check\e[0m"
read -n1 -s -p "Press any key to continue... "
echo
exit 0
fi
echo "Checking data integrity of device $disk (@@LIVE_MEDIUM_LABEL@@)..."
if checkmedia -v "$disk"; then
echo -e "\e[32mMedium check succeeded\e[0m"
read -n1 -s -p "Press any key to continue... "
echo
else
echo -e "\e[31mERROR: Medium check failed!\e[0m"
echo "The installation medium is broken, it should not be used for installation."
read -n1 -s -p "Press any key to halt the system... "
echo
halt
fi