diff options
Diffstat (limited to 'scripts/bokftui-sudo')
| -rwxr-xr-x | scripts/bokftui-sudo | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/scripts/bokftui-sudo b/scripts/bokftui-sudo new file mode 100755 index 0000000..fc300ae --- /dev/null +++ b/scripts/bokftui-sudo @@ -0,0 +1,21 @@ +#!/bin/sh +# Start bokftui with a credential from a root-only file, unlocked with sudo. +# Looks for /etc/bokf/tui-token (preferred) then /etc/bokf/tui-password. +# The server and user are remembered by bokftui itself in +# ~/.config/bokf/tui.conf. +set -eu + +sudo -v + +if token=$(sudo cat /etc/bokf/tui-token 2>/dev/null) && [ -n "$token" ]; then + BOKFD_TOKEN="$token" + export BOKFD_TOKEN +elif pass=$(sudo cat /etc/bokf/tui-password 2>/dev/null) && [ -n "$pass" ]; then + BOKFD_PASSWORD="$pass" + export BOKFD_PASSWORD +else + echo "bokftui-sudo: no /etc/bokf/tui-token or /etc/bokf/tui-password" >&2 + exit 1 +fi + +exec bokftui "$@" |
