commit 17f66008e754a1a4a0cb3781b63ae83f3da69ea7
parent 62ea09a7bd596c272a624f56e5adc6cc35796058
Author: Alex Balgavy <a.balgavy@gmail.com>
Date: Mon, 22 Jun 2020 12:00:35 +0200
vbox: fix restoring from saved state
Former-commit-id: ee82db6fa56080937bd090650b886e0ee388dcb5
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scripts/vbox b/scripts/vbox
@@ -4,6 +4,7 @@ die() {
exit 1
}
+command -v gstat &>/dev/null && statcmd="gstat"
start() {
[ $# -eq 1 ] || die "Only one argument: VM name"
VBoxManage startvm "$1" --type headless
@@ -27,7 +28,7 @@ resume() {
vminfo="$(VBoxManage showvminfo "$1")"
if [ "$(awk '/^State/ { print $2 }' <<< "$vminfo")" = "saved" ]; then
snapshots="$(awk '/^Snapshot folder/ { print $3 }' <<< "$vminfo")"
- snapfile="$(find "$snapshots" -name "*.sav" -exec stat -c "%y %n" {} + | sort -r | head -n1 | cut -d " " -f 4-)"
+ snapfile="$(find "$snapshots" -name "*.sav" -exec "${statcmd:-stat}" -c "%y %n" {} + | sort -r | head -n1 | cut -d " " -f 4-)"
[ -n "$snapfile" ] \
&& echo "VM suspended, resuming from saved state..." \