#!/bin/bash
#
# Wrapper function to make sure the user wishes to continue before
# rebooting the system

. /usr/libexec/ovirt-functions

rc=0
while true; do
    printf "\n\n Local Installation and Reboot\n\n"

    printf "\nThis option will exit the menu, and require a reboot. \n\
Please ensure that you have configured the local storage \n\
and networking correctly on the previous menu before \n\
continuing."
    printf "\n\n"
    bootparams="${OVIRT_BOOTPARAMS}"
    printf "Current kernel boot parameters are:\n"
    printf "${bootparams}\n"
    printf "\n"
    read -p "Please enter kernel boot arguments (hit return to use the above): "
    if [[ -n "$REPLY" ]]; then
        bootparams="${REPLY}"
    else
        bootparams="${OVIRT_BOOTPARAMS}"
    fi
    if ask_yes_or_no "Do you wish to continue ([Y]es/[N]o)?"; then
        mount_live \
            && /usr/libexec/ovirt-config-boot /live "${bootparams}"
        rc=$?
        break
    else
        printf "\nExiting back to the menu\n"
        rc=99
        break
    fi
done
exit $rc
