[Ovirt-devel] [PATCH node] Disable o-c-storage on systems booted from local storage.
Darryl L. Pierce
dpierce at redhat.com
Wed Mar 4 15:57:19 UTC 2009
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
More information about the ovirt-devel
mailing list