split root file systems out of HostVG onto separate partitions
[ovirt-node/TEMP.git] / scripts / ovirt-config-uninstall
blob22633a04fe4ecd86fbae6906c41f63491352e42a
1 #!/bin/bash
3 # ovirt-config-uninstall - destroys an installed copy of the oVirt node
5 # SYNOPSIS
6 # Destroys the HostVG volume group and logical volumes.
9 . /etc/init.d/ovirt-functions
11 ME=$(basename "$0")
12 warn() { printf '%s: %s\n' "$ME" "$*" >&2; }
13 die() { warn "$*"; exit 1; }
15 trap '__st=$?; stop_log; exit $__st' 0
16 trap 'exit $?' 1 2 13 15
18 cat <<EOF
19 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
20 !! !!
21 !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
22 !! !!
23 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
25 If you proceed, you will DESTROY any existing data relating to the oVirt
26 installation on this machine.
28 EOF
30 if ask_yes_or_no "Do you wish to continue and uninstall this node ([Y]es/[N]o)?"; then
31 if [ -d /dev/HostVG ]; then
32 log "Uninstalling node"
33 log "Detaching logging"
34 unmount_logging
35 log "Removing volume group"
36 wipe_volume_group "HostVG"
37 partition=$(findfs LABEL=BOOT)
38 if [ -n "$partition" ]; then
39 log "Unmounting boot partition"
40 umount $partition
41 log "Removing partitions"
42 drive=$(echo $partition | awk '{ print substr($0, 1, length($0) - 1) }')
43 parted -s $drive "rm 1"
44 parted -s $drive "rm 2"
45 parted -s $drive "rm 3"
46 parted -s $drive "rm 4"
48 printf "Finished uninstalling node."
49 else
50 log "There is no installed node instance to remove."
51 log "Aborting"
52 exit 1
54 else
55 log "Aborted"