#!/bin/bash

set -x

# Because system may reboot at the end of task,
# we have to mount recovery patition on /cdrom
# if it is not mounted.

if ! mount | grep -q cdrom; then
    boot_dev="$(grub-probe -t device /)"
    root_dev="${boot_dev::-1}"
    recovery_dev="${root_dev}$( [ -d /sys/firmware/efi ] && echo 2 || echo 1)"
    mount -r "${recovery_dev}" /cdrom
fi
