From 15b368cfc5c6d77a0640021326f5282dcc3d823f Mon Sep 17 00:00:00 2001 From: Morgan Aldridge Date: Thu, 8 Dec 2016 22:03:28 -0500 Subject: [PATCH] Added 'snapshots' command for listing snapshots in a VM. --- basiliskiivm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/basiliskiivm b/basiliskiivm index 99a7f37..428fb48 100755 --- a/basiliskiivm +++ b/basiliskiivm @@ -51,6 +51,7 @@ function usage() { echo " info : print basic configuration info for a .BasiliskIIVM" echo " list [] : list all .BasiliskIIVM in path (or none for default directory" echo " package : package the current BasiliskII configuration into a .BasiliskIIVM" + echo " snapshots : list all snapshots in a .BasiliskIIVM" echo " start : start a BasiliskII instance from a .BasiliskIIVM" echo " status : get the status of a .BasiliskIIVM" echo " stop : stop a running .BasiliskIIVM" @@ -289,6 +290,24 @@ function vm_stop() { $success } +function vm_pkg_list_snapshots() { + local success=false + + local vm="$(vm_pkg_name "$1")" + if [ -n "$vm" ]; then + local snapshots_path="${1}/Snapshots" + local count=0 + if [ -d "$snapshots_path "]; then + while IFS= read -r line; do + echo "$(basename "$line")" + done <<< "$(find "$snapshots_path" -type d -mindepth 1 -maxdepth 1)" + fi + success=true + fi + + $success +} + function list_vms() { success=false @@ -322,6 +341,9 @@ function main() { shift list_vms "$1" ;; + "snapshots") + vm_pkg_list_snapshots "$1" + ;; "start") shift vm_start "$1"