summaryrefslogtreecommitdiff
path: root/docs/tutorial/scripts/sudo-keepalive.sh
diff options
context:
space:
mode:
Diffstat (limited to 'docs/tutorial/scripts/sudo-keepalive.sh')
-rwxr-xr-xdocs/tutorial/scripts/sudo-keepalive.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/docs/tutorial/scripts/sudo-keepalive.sh b/docs/tutorial/scripts/sudo-keepalive.sh
new file mode 100755
index 0000000..4ae1e27
--- /dev/null
+++ b/docs/tutorial/scripts/sudo-keepalive.sh
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+# Refreshes the sudo timestamp every minute so a long demo regen never trips a
+# password prompt. Intended to be backgrounded by `mage demo` and killed at the
+# end of the run.
+
+set -u
+
+trap 'exit 0' TERM INT
+
+while true; do
+ sudo -n true 2>/dev/null || exit 1
+ sleep 60
+done