ovirt-node 2.2.0 release
[ovirt-node.git] / scripts / ovirt-config-uninstall
blob716e41a1c38ff88f6949fc8d5885f55a4033f50d
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 . /usr/libexec/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 vgs --noheadings HostVG -o vg_name >/dev/null 2>&1; then
32 log "Uninstalling node"
33 log "Detaching logging"
34 start_log
35 # multipathd holds all mounts under /var in a private namespace
36 service multipathd stop 6>&- 7>&-
37 rm -f /var/lib/multipath/bindings
38 unmount_logging
39 unmount_config /etc/default/ovirt
40 # remove rootfs labels
41 for label in Root RootBackup RootUpdate RootNew; do
42 root="$(findfs LABEL=$label 2>/dev/null)"
43 if [ "$root" ]; then
44 e2label "$root" ""
46 rm -f /dev/disk/by-label/$label
47 done
48 log "Removing volume groups"
49 wipe_volume_group HostVG
50 wipe_volume_group AppVG
51 #log "Removing partitions"
52 #wipe_partitions "$pv_dev"
53 #wipe_partitions "$root_dev"
54 #wipe_partitions "$root2_dev"
56 #restart multipath
57 multipath -F
58 multipath -v3
59 service multipathd start 6>&- 7>&-
60 log "Finished uninstalling node."
61 stop_log
62 else
63 log "There is no installed node instance to remove."
64 log "Aborting"
65 exit 1
67 else
68 log "Aborted"