aboutsummaryrefslogtreecommitdiff
path: root/bin/vm
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2023-03-23 17:13:42 -0300
committerEuAndreh <eu@euandre.org>2023-03-23 17:13:42 -0300
commit5e5affea3429523fbcd03736fac860449dea2df7 (patch)
tree057d051eac42c068ed5f4a32bd2a0b95f956b664 /bin/vm
parentMakefile: Exclude mint from upload (diff)
downloaddotfiles-5e5affea3429523fbcd03736fac860449dea2df7.tar.gz
dotfiles-5e5affea3429523fbcd03736fac860449dea2df7.tar.xz
bin/vm: Report if VM is running as a snapshot in "status" action
Diffstat (limited to 'bin/vm')
-rwxr-xr-xbin/vm12
1 files changed, 11 insertions, 1 deletions
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
;;