Tweaks to ./restore.
authorEric Blake <eblake@redhat.com>
Fri, 25 Oct 2019 03:55:46 +0000 (22:55 -0500)
committerEric Blake <eblake@redhat.com>
Fri, 25 Oct 2019 04:57:08 +0000 (23:57 -0500)
Only attempt sudo when needed, vet myself as willing to use it

2019-kvm-forum/restore

index c25a368..620e30e 100755 (executable)
@@ -1,14 +1,18 @@
 #!/bin/bash -
 
-# Only do this on Rich's laptop.
-if [ "$LOGNAME" = "rjones" ]; then
-    if [ "$talkdir" = "" ]; then exit 1; fi
+# Safety-valve for unwary users...
+if [ "$LOGNAME" != "rjones" ] && [ "$LOGNAME" != "eblake" ]; then
+    exit 1
+fi
 
-    fusermount -u $talkdir/6200-vddk.d/mp >& /dev/null
+if [ "$talkdir" = "" ]; then exit 1; fi
 
-    sudo rm -rf $talkdir/6400-boot.d/root
+fusermount -u $talkdir/6200-vddk.d/mp >& /dev/null
 
-    sleep 0.5; killall nbdkit >& /dev/null
+if [ -d "$talkdir/6400-boot.d/root" ]; then
+    sudo rm -rf $talkdir/6400-boot.d/root
 fi
 
+sleep 0.5; killall nbdkit >& /dev/null
+
 exit 0