Darryl L. Pierce
2009-Mar-03 22:39 UTC
[Ovirt-devel] [PATCH node] Disable o-c-storage on systems booted from local storage.
Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- scripts/ovirt-config-boot | 3 +++ scripts/ovirt-config-boot-wrapper | 2 +- scripts/ovirt-config-storage | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletions(-) diff --git a/scripts/ovirt-config-boot b/scripts/ovirt-config-boot index 40b3a6b..3ee0665 100755 --- a/scripts/ovirt-config-boot +++ b/scripts/ovirt-config-boot @@ -155,6 +155,9 @@ EOF # mark new Root ready to go, reboot() in ovirt-function switches it to active lvrename HostVG RootNew RootUpdate + # remove the o-c-storage script symlink so it won't show in the firstboot menu + rm -f /etc/ovirt-config-setup.d/98_* + rm -rf $tmpdir log "done." } diff --git a/scripts/ovirt-config-boot-wrapper b/scripts/ovirt-config-boot-wrapper index 4ac742a..5264bed 100755 --- a/scripts/ovirt-config-boot-wrapper +++ b/scripts/ovirt-config-boot-wrapper @@ -15,7 +15,7 @@ Please ensure that you have configured the local storage \n\ and networking correctly on the previous menu before \n\ continuing." printf "\n\n" - read -p "Do you wish to continue? (Y|N)? " + read -p "Do you wish to continue (Y/n)? " r=$(echo $REPLY|tr '[[:lower:]]' '[[:upper:]]') if [ "$r" == "Y" ]; then mount_live \ diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage index c9225f7..c2ab88e 100755 --- a/scripts/ovirt-config-storage +++ b/scripts/ovirt-config-storage @@ -15,6 +15,12 @@ die() { warn "$*"; exit 1; } trap '__st=$?; stop_log; exit $__st' 0 trap 'exit $?' 1 2 13 15 +# check that we're not booted from local storage; if so then exit with an error +grep \/dev\/HostVG\/Root /proc/cmdline > /dev/null +if [ 0 -eq $? ]; then + die "You cannot configure storage on a running system. Please boot from CD/USB to configure local storage." +fi + default_overcommit=0.5 default_boot_size=50 -- 1.6.0.6
Alan Pevec
2009-Mar-03 23:27 UTC
[Ovirt-devel] [PATCH node] Disable o-c-storage on systems booted from local storage.
> + ? ?# remove the o-c-storage script symlink so it won't show in the firstboot menu > + ? ?rm -f /etc/ovirt-config-setup.d/98_* > +But this won't be persisted, change will be only done in the running writeable dm-snapshot. You need dynamic check in o-c-setup, to skip disk partitioning option if booted from HostVG. Also 98_* is '98_Local install and reboot', should be '00_Disk Partitioning'
Darryl L. Pierce
2009-Mar-04 15:57 UTC
[Ovirt-devel] [PATCH node] Disable o-c-storage on systems booted from local storage.
NOTE: This patch is reworked to remove the Partitioning option from the o-c-setup menu if booted from disk, as well as disabling o-c-storage directly. Removes the o-c-storage item from the o-c-setup menu if booted from local storage. Also, if the admin runs o-c-storage directly the script will exit with an error. Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- scripts/ovirt-config-boot-wrapper | 2 +- scripts/ovirt-config-setup | 21 ++++++++++++++++++--- scripts/ovirt-config-storage | 5 +++++ scripts/ovirt-functions | 12 ++++++++++++ 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/scripts/ovirt-config-boot-wrapper b/scripts/ovirt-config-boot-wrapper index 4ac742a..5264bed 100755 --- a/scripts/ovirt-config-boot-wrapper +++ b/scripts/ovirt-config-boot-wrapper @@ -15,7 +15,7 @@ Please ensure that you have configured the local storage \n\ and networking correctly on the previous menu before \n\ continuing." printf "\n\n" - read -p "Do you wish to continue? (Y|N)? " + read -p "Do you wish to continue (Y/n)? " r=$(echo $REPLY|tr '[[:lower:]]' '[[:upper:]]') if [ "$r" == "Y" ]; then mount_live \ diff --git a/scripts/ovirt-config-setup b/scripts/ovirt-config-setup index 8db8ffd..ccbb27e 100755 --- a/scripts/ovirt-config-setup +++ b/scripts/ovirt-config-setup @@ -13,11 +13,26 @@ CONTINUE="Continue Stateless Boot" declare -a OPTIONS +can_include_item() { + if is_booted_from_local_disk; then + if [[ $1 =~ Partitioning ]]; then + return 0 + else + return 1 + fi + else + return 1 + fi +} + for cfg in $CONFIG_DIR/*; do label=$(basename "$cfg") - # Assume label is actually XX_Some Text. So strip of the first 3 characters - label=${label:3} - OPTIONS[${#OPTIONS[*]}]="$label" + can_include_item "$label" + if [ 1 -eq $? ]; then + # Assume label is actually XX_Some Text. So strip of the first 3 characters + label=${label:3} + OPTIONS[${#OPTIONS[*]}]="$label" + fi done OPTIONS[${#OPTIONS[*]}]="$DEBUG_SHELL" OPTIONS[${#OPTIONS[*]}]="$CONTINUE" diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage index c9225f7..d8c93e0 100755 --- a/scripts/ovirt-config-storage +++ b/scripts/ovirt-config-storage @@ -15,6 +15,11 @@ die() { warn "$*"; exit 1; } trap '__st=$?; stop_log; exit $__st' 0 trap 'exit $?' 1 2 13 15 +# check that we're not booted from local storage; if so then exit with an error +if is_booted_from_local_disk; then + die "You cannot configure storage on a running system. Please boot from CD/USB to configure local storage." +fi + default_overcommit=0.5 default_boot_size=50 diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions index 6ee8940..5573487 100755 --- a/scripts/ovirt-functions +++ b/scripts/ovirt-functions @@ -92,6 +92,18 @@ is_auto_install() { fi } +# return 1 if booted from local disk +# return 0 if booted from other media +is_booted_from_local_disk() { + grep \/dev\/HostVG\/Root /proc/cmdline > /dev/null + + if [ $? -eq 0 ]; then + return 0 + else + return 1 + fi +} + # was firstboot menu already shown? # state is stored in persistent config partition is_firstboot() { -- 1.6.0.6