Init script to "preserve" device nodes bmo keeping a file /.devnodes.tgz
authorRalph Ronnquist <rrq@rrq.au>
Tue, 14 Nov 2023 20:06:37 +0000 (07:06 +1100)
committerRalph Ronnquist <rrq@rrq.au>
Tue, 14 Nov 2023 20:06:37 +0000 (07:06 +1100)
devnodes-init.sh [new file with mode: 0755]

diff --git a/devnodes-init.sh b/devnodes-init.sh
new file mode 100755 (executable)
index 0000000..5e5402c
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh /lib/init/init-d-script
+### BEGIN INIT INFO
+# Provides:          devices
+# Required-Start:    
+# Required-Stop:     
+# Default-Start:     S
+# Default-Stop:      0 1 6
+# Short-Description: set up devnodes
+# Description:       Initialize /dev from /.devnodes.tgz
+### END INIT INFO
+
+DAEMON=none
+DESC="devnodes: restore and capture /dev on startup and shutdown."
+TGZ=/.devnodes.tgz
+
+do_start_override() {
+    [ -e $TGZ ] && tar -xzf $TGZ --skip-old-files -C /dev
+}
+
+do_stop_override() {
+    cd /dev && tar czf $TGZ *
+}
+
+do_status_override() {
+    find /dev -type d -exec ls -ld '{}' ';'
+    stat -c %Y $TGZ
+}