Merge "prototypes: bifrost: Ignore dnsmasq service failures"
[releng.git] / prototypes / bifrost / scripts / destroy-env.sh
index f092a65..cdc55df 100755 (executable)
@@ -7,6 +7,13 @@
 # which accompanies this distribution, and is available at
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
+
+# We need to execute everything as root
+if [[ $(whoami) != "root" ]]; then
+    echo "Error: This script must be run as root!"
+    exit 1
+fi
+
 virsh destroy jumphost.opnfvlocal || true
 virsh destroy controller00.opnfvlocal || true
 virsh destroy compute00.opnfvlocal || true
@@ -22,7 +29,7 @@ mysql -u root ironic --execute "delete from node_tags;"
 mysql -u root ironic --execute "delete from nodes;"
 mysql -u root ironic --execute "delete from conductors;"
 echo "removing leases"
-> /var/lib/dnsmasq/dnsmasq.leases
+[[ -e /var/lib/misc/dnsmasq/dnsmasq.leases ]] && > /var/lib/misc/dnsmasq/dnsmasq.leases
 echo "removing logs"
 rm -rf /var/log/libvirt/baremetal_logs/*.log
 
@@ -30,14 +37,16 @@ rm -rf /var/log/libvirt/baremetal_logs/*.log
 CLEAN_DIB_IMAGES=${CLEAN_DIB_IMAGES:-false}
 
 if [ $CLEAN_DIB_IMAGES = "true" ]; then
-    rm -rf /httpboot/*
-    rm -rf /tftpboot/*
+    rm -rf /httpboot /tftpboot
+    mkdir /httpboot /tftpboot
+    chmod -R 755 /httpboot /tftpboot
 fi
 
 # remove VM disk images
 rm -rf /var/lib/libvirt/images/*.qcow2
 
 echo "restarting services"
+service dnsmasq restart || true
 service libvirtd restart
 service ironic-api restart
 service ironic-conductor start