From 5e5affea3429523fbcd03736fac860449dea2df7 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Thu, 23 Mar 2023 17:13:42 -0300 Subject: bin/vm: Report if VM is running as a snapshot in "status" action --- bin/vm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'bin/vm') diff --git a/bin/vm b/bin/vm index 75c1fc7..e1bb58f 100755 --- a/bin/vm +++ b/bin/vm @@ -255,7 +255,15 @@ case "$ACTION" in else STATUS=down fi - printf '%s\t%s\t%s\n' "$NAME" "$STATUS" "$PORTS" + + SNAPSHOT="$(cat "$RUNDIR/$NAME.snapshot")" + if [ "$SNAPSHOT" = true ] && [ "$STATUS" = 'up' ]; then + SNAPSHOT='snapshot' + else + SNAPSHOT='' + fi + + printf '%s\t%s\t%s\t%s\n' "$NAME" "$STATUS" "$PORTS" "$SNAPSHOT" done ;; up) @@ -270,6 +278,7 @@ case "$ACTION" in PID_F="$RUNDIR/$OS.pid" SSH_PORT_F="$RUNDIR/$OS.ssh" PORTMAPS_F="$RUNDIR/$OS.ports" + SNAPSHOT_F="$RUNDIR/$OS.snapshot" if [ -e "$PID_F" ]; then printf 'The VM for "%s" is already running with PID %s.\n' \ @@ -309,6 +318,7 @@ case "$ACTION" in printf '%s' "$PID" > "$PID_F" printf '%s' "$SSH_PORT" > "$SSH_PORT_F" printf '%s' "$PORTMAPS" > "$PORTMAPS_F" + printf '%s' "$SNAPSHOT" > "$SNAPSHOT_F" write_ssh_config ;; -- cgit v1.2.3