From b9f0daba7fcb351f6a833fdfc5fed0fe7a793c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Mon, 5 May 2025 22:51:11 +0200 Subject: [PATCH] Improve noita-helper --- home/scripts/noita-helper.sh | 57 +++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/home/scripts/noita-helper.sh b/home/scripts/noita-helper.sh index 7c692f5..c08886d 100644 --- a/home/scripts/noita-helper.sh +++ b/home/scripts/noita-helper.sh @@ -6,24 +6,41 @@ RESTIC_REPOSITORY="/home/$(whoami)/tmp/noita-backup" export RESTIC_REPOSITORY export RESTIC_PASSWORD="noita" -echo "Doing initial backup" -restic backup -q "$SAVE_DIR" -echo "Backup done" - -echo "Mounting tmpfs for save folder..." -sudo mount -o size=2G,noswap -t tmpfs none "$SAVE_DIR" - -echo "Restoring initial backup..." -restic restore "latest:$SAVE_DIR" --target "$SAVE_DIR" - -echo "Ready to play Noita!" -echo "Remember to unmount the tmpfs after playing:" -echo "" -echo "restic -r $RESTIC_REPOSITORY backup -q $SAVE_DIR && sudo umount $SAVE_DIR && restic -r $RESTIC_REPOSITORY restore latest:$SAVE_DIR --target $SAVE_DIR" - -while true -do +function start { + echo "Doing initial backup" restic backup -q "$SAVE_DIR" - echo "Periodic backup done..." - sleep 10m -done + echo "Backup done" + + echo "Mounting tmpfs for save folder..." + sudo mount -o size=2G,noswap -t tmpfs none "$SAVE_DIR" + + echo "Restoring initial backup..." + restic restore "latest:$SAVE_DIR" --target "$SAVE_DIR" + + echo "Ready to play Noita!" + echo "Remember to unmount the tmpfs after playing:" + + while true + do + restic backup -q "$SAVE_DIR" + echo "Periodic backup done..." + sleep 10m + done +} + +function stop { + restic backup -q $SAVE_DIR + sudo umount $SAVE_DIR + restic restore latest:$SAVE_DIR --target $SAVE_DIR + echo "Backup and unmount done..." +} + +# Parse command line arguments +if [ "$1" == "start" ]; then + start +elif [ "$1" == "stop" ]; then + stop +else + echo "Usage: $0 {start|stop}" + exit 1 +fi