[Ovirt-devel] [PATCH node] Hostname is now properly persisted between reboots. rhbz#504166
Darryl L. Pierce
dpierce at redhat.com
Thu Jun 4 19:52:28 UTC 2009
The o-c-hostname script now checks to see if local storage has been
configured. If it has not then the script exits with an error.
Otherwise, after the user enters a hostname, the /etc/script/network
file is persisted.
Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
scripts/ovirt-config-hostname | 13 ++++++++++---
scripts/ovirt-functions | 11 ++++++++++-
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/scripts/ovirt-config-hostname b/scripts/ovirt-config-hostname
index cad0270..ac8cdf1 100755
--- a/scripts/ovirt-config-hostname
+++ b/scripts/ovirt-config-hostname
@@ -8,6 +8,13 @@
trap '__st=$?; stop_log; exit $__st' 0
trap 'exit $?' 1 2 13 15
+warn() { printf '%s\n' "$*" >&2; }
+
+if ! is_local_storage_configured; then
+ warn "Local storage must be configured prior to setting the hostname."
+ exit 99
+fi
+
HOSTNAME_FILE="/etc/sysconfig/network"
function set_hostname {
@@ -17,8 +24,9 @@ set /files$HOSTNAME_FILE/HOSTNAME "$1"
EOF
rc=$?
if [ $rc = 0 ]; then
- /bin/hostname "$1"
- rc=$?
+ /bin/hostname "$1"
+ rc=$?
+ if [ $rc -eq 0 ]; then /usr/sbin/persist $HOSTNAME_FILE; fi
fi
stop_log
return $rc
@@ -82,4 +90,3 @@ else
printf "\n\n Hostname Configuration\n\n"
prompt_user
fi
-
diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions
index 5997a4c..e938256 100755
--- a/scripts/ovirt-functions
+++ b/scripts/ovirt-functions
@@ -78,6 +78,16 @@ is_standalone() {
if is_managed; then return 1; else return 0; fi
}
+# return 0 if local storage is configured
+# return 1 if local storage is not configured
+is_local_storage_configured () {
+ if lvs HostVG/Config >/dev/null >&1; then
+ return 0
+ fi
+
+ return 1
+}
+
# perform automatic local disk installation
# when at least following boot parameters are present:
# for networking - OVIRT_BOOTIF, management NIC
@@ -624,4 +634,3 @@ chkconfig_persist() {
if [ "$(basename "$0")" = "ovirt-functions" ]; then
"$@"
fi
-
--
1.6.0.6
More information about the ovirt-devel
mailing list