From 35167ac125f0834627002a5eaecc16188538cd7f Mon Sep 17 00:00:00 2001
From: Recolic <git@me.recolic.net>
Date: Sun, 2 Feb 2025 04:37:00 -0800
Subject: [PATCH] .

---
 .../check_extern.fish                         |  0
 rpi-scripts/HOWTO                             |  2 ++
 rpi-scripts/keep-awake.patch                  | 22 +++++++++++++++++++
 storage-server-backup-sh/daily.fish           |  8 +------
 storage-server-backup-sh/targets.fish         |  7 +-----
 5 files changed, 26 insertions(+), 13 deletions(-)
 rename {storage-server-backup-sh => archived}/check_extern.fish (100%)
 create mode 100644 rpi-scripts/HOWTO
 create mode 100644 rpi-scripts/keep-awake.patch

diff --git a/storage-server-backup-sh/check_extern.fish b/archived/check_extern.fish
similarity index 100%
rename from storage-server-backup-sh/check_extern.fish
rename to archived/check_extern.fish
diff --git a/rpi-scripts/HOWTO b/rpi-scripts/HOWTO
new file mode 100644
index 0000000..6a9b286
--- /dev/null
+++ b/rpi-scripts/HOWTO
@@ -0,0 +1,2 @@
+1. copy keep_unlocked.py to app/
+2. apply keep-awake.patch to app/main.py
diff --git a/rpi-scripts/keep-awake.patch b/rpi-scripts/keep-awake.patch
new file mode 100644
index 0000000..c2025d3
--- /dev/null
+++ b/rpi-scripts/keep-awake.patch
@@ -0,0 +1,22 @@
+diff --git a/app/main.py b/app/main.py
+index 6cab2c0..4048607 100755
+--- a/app/main.py
++++ b/app/main.py
+@@ -19,6 +19,8 @@ import socket_api
+ import views
+ from find_files import find as find_files
+ 
++import keep_unlocked
++
+ host = os.environ.get('HOST', '127.0.0.1')
+ port = int(os.environ.get('PORT', 48000))
+ debug = 'DEBUG' in os.environ
+@@ -79,6 +81,8 @@ def handle_error(e):
+ 
+ 
+ def main():
++    with app.app_context():
++        keep_unlocked.start_keep_awake_thread(flask.current_app.config.get('KEYBOARD_PATH'))
+     socketio = socket_api.socketio
+     socketio.init_app(app)
+     socketio.run(app,
diff --git a/storage-server-backup-sh/daily.fish b/storage-server-backup-sh/daily.fish
index 9797768..6d737c9 100755
--- a/storage-server-backup-sh/daily.fish
+++ b/storage-server-backup-sh/daily.fish
@@ -39,11 +39,7 @@ else
     end
 
     # Check if extern target needs packing
-    # TODO: remove this fallback after upgrade client side do.bash
-    if test -f /storage/backups/extern/NEED_PACKING
-        rm -f /storage/backups/extern/NEED_PACKING
-        reach_target target_extern_lwl
-    else if test -f /storage/cache/target_extern_lwl/NEED_PACKING
+    if test -f /storage/cache/target_extern_lwl/NEED_PACKING
         rm -f /storage/cache/target_extern_lwl/NEED_PACKING
         reach_target target_extern_lwl
     end
@@ -59,5 +55,3 @@ end
 test (df -T | grep /dev/ploop | tr -s ' ' | cut -d ' ' -f 3,5 | sed 's/^.* //g') -lt 104857600
     and email_notify "Backup system has low disk space. "(df -Th | grep /dev/ploop)
 
-fish check_extern.fish
-
diff --git a/storage-server-backup-sh/targets.fish b/storage-server-backup-sh/targets.fish
index 23181f4..7c40d8f 100644
--- a/storage-server-backup-sh/targets.fish
+++ b/storage-server-backup-sh/targets.fish
@@ -89,12 +89,7 @@ function target_mail_www_recolic_net_data
 end
 
 function target_extern_lwl
-    # Temporary: Remove this fallback after upgrading client side do.bash.
-    if test -d /storage/cache/target_extern_lwl
-        pack_backup_dir /storage/cache/target_extern_lwl
-    else
-        pack_backup_dir /storage/backups/extern
-    end
+    pack_backup_dir /storage/cache/target_extern_lwl
 end
 
 
-- 
GitLab