Darryl L. Pierce
2009-Feb-19 15:31 UTC
[Ovirt-devel] [PATCH node] Adds an uninstall option to the standalone node menu.
If the user selects this option from the firstboot menu, then the HostVG volume group is removed. First all logical volumes are removed, swap file disabled. Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- Makefile.am | 1 + ovirt-node.spec.in | 5 +++- scripts/ovirt-config-storage | 15 +------------ scripts/ovirt-config-uninstall | 45 ++++++++++++++++++++++++++++++++++++++++ scripts/ovirt-functions | 22 +++++++++++++++++++ 5 files changed, 73 insertions(+), 15 deletions(-) create mode 100755 scripts/ovirt-config-uninstall diff --git a/Makefile.am b/Makefile.am index 733fef1..af23ae4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -38,6 +38,7 @@ EXTRA_DIST = \ scripts/ovirt-config-password \ scripts/ovirt-config-setup \ scripts/ovirt-config-storage \ + scripts/ovirt-config-uninstall \ scripts/ovirt-early \ scripts/ovirt-firstboot \ scripts/ovirt-functions \ diff --git a/ovirt-node.spec.in b/ovirt-node.spec.in index 5845d2b..84f10a3 100644 --- a/ovirt-node.spec.in +++ b/ovirt-node.spec.in @@ -140,6 +140,7 @@ cd - %{__install} -p -m0755 scripts/ovirt-config-password %{buildroot}%{_sbindir} %{__install} -p -m0755 scripts/ovirt-config-setup %{buildroot}%{_sbindir} %{__install} -p -m0755 scripts/ovirt-config-storage %{buildroot}%{_sbindir} +%{__install} -p -m0755 scripts/ovirt-config-uninstall %{buildroot}%{_sbindir} %{__install} -p -m0755 scripts/ovirt-process-config %{buildroot}%{_sbindir} %{__install} -D -m0755 scripts/ovirt-install-node-stateful %{buildroot}%{_sbindir} %{__install} -D -m0755 scripts/ovirt-install-node-stateless %{buildroot}%{_sbindir} @@ -201,7 +202,8 @@ install -p -m 644 images/syslinux-vesa-splash.jpg %{buildroot}/usr/lib/anaconda- %{__ln_s} ../..%{_sbindir}/ovirt-config-networking %{buildroot}%{_sysconfdir}/ovirt-config-setup.d/"15_Networking Setup" %{__ln_s} ../..%{_sbindir}/ovirt-config-logging %{buildroot}%{_sysconfdir}/ovirt-config-setup.d/"30_Logging Setup" %{__ln_s} ../..%{_sbindir}/ovirt-config-collectd %{buildroot}%{_sysconfdir}/ovirt-config-setup.d/"35_Collectd Setup" -%{__ln_s} ../..%{_sbindir}/ovirt-config-boot-wrapper %{buildroot}%{_sysconfdir}/ovirt-config-setup.d/"99_Local install and reboot" +%{__ln_s} ../..%{_sbindir}/ovirt-config-boot-wrapper %{buildroot}%{_sysconfdir}/ovirt-config-setup.d/"98_Local install and reboot" +%{__ln_s} ../..%{_sbindir}/ovirt-config-uninstall %{buildroot}%{_sysconfdir}/ovirt-config-setup.d/"99_Uninstall_node" %clean @@ -275,6 +277,7 @@ fi %{_sbindir}/ovirt-config-password %{_sbindir}/ovirt-config-setup %{_sbindir}/ovirt-config-storage +%{_sbindir}/ovirt-config-uninstall %{_sbindir}/ovirt-process-config %{_sbindir}/ovirt-install-node-stateless %{_sbindir}/gptsync diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage index faaf006..954a814 100755 --- a/scripts/ovirt-config-storage +++ b/scripts/ovirt-config-storage @@ -251,20 +251,7 @@ wipe_lvm_on_disk() { unmount_logging for vg in $(pvdisplay -c $DRIVE* 2>/dev/null|awk -F: '{print $2}'|sort -u); do - for d in $(grep $vg /proc/mounts|awk '{print $2}'); do - log "Unmounting $d" - umount $d - done - for d in $(grep $vg /proc/swaps|awk '{print $1}'); do - log "Turning off $d" - swapoff $d - done - for lv in $(lvdisplay -c $vg|awk -F: '{print $1}'); do - log "Removing $lv" - lvremove -f $lv - done - log "Removing $vg" - vgremove -f $vg + wipe_volume_group $vg done } diff --git a/scripts/ovirt-config-uninstall b/scripts/ovirt-config-uninstall new file mode 100755 index 0000000..70dcb47 --- /dev/null +++ b/scripts/ovirt-config-uninstall @@ -0,0 +1,45 @@ +#!/bin/bash +# +# ovirt-config-uninstall - destroys an installed copy of the oVirt node + +# SYNOPSIS +# Destroys the HostVG volume group and logical volumes. +# + +. /etc/init.d/ovirt-functions + +ME=$(basename "$0") +warn() { printf '%s: %s\n' "$ME" "$*" >&2; } +die() { warn "$*"; exit 1; } + +trap '__st=$?; stop_log; exit $__st' 0 +trap 'exit $?' 1 2 13 15 + +cat <<EOF +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!! !! +!! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! +!! !! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + If you proceed, you will DESTROY any existing data relating to the oVirt + installation on this machine. + +EOF + +read -ep "Do you wish to continue and uninstall this node (Y/N)? " + +if [ "$REPLY" == "Y" -o "$REPLY" == "y" ]; then + if [ -d /dev/HostVG ]; then + printf "\nUNINSTALLING NODE...\n\n" + unmount_logging + wipe_volume_group "HostVG" + printf "\nDONE!\n" + else + printf "\nThere is no installed node instance to remove.\n" + printf "\nAborting...\n" + return 1 + fi +else + printf "\nABORTED!\n" +fi diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions index 4be1310..8ff908b 100755 --- a/scripts/ovirt-functions +++ b/scripts/ovirt-functions @@ -112,6 +112,28 @@ EOF fi } +# Destroys a particular volume group and its logical volumes. +# +wipe_volume_group() +{ + vg=$1 + + for d in $(grep $vg /proc/mounts|awk '{print $2}'); do + log "Unmounting $d" + umount $d + done + for d in $(grep $vg /proc/swaps|awk '{print $1}'); do + log "Turning off $d" + swapoff $d + done + for lv in $(lvdisplay -c $vg|awk -F: '{print $1}'); do + log "Removing $lv" + lvremove -f $lv + done + log "Removing $vg" + vgremove -f $vg +} + # find_srv SERVICE PROTO # # reads DNS SRV record -- 1.6.0.6