From 67896a891bec5064fc603792cf161e5e38dbac05 Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Thu, 28 Jul 2022 17:13:30 +0200 Subject: Add config options for ssh agent and bashboard --- bash/board.bash | 13 +++++++------ bash/ssh-agent.bash | 30 ++++++++++++++++++++++++++++++ bash/ssh-agent.profile | 8 +++++++- 3 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 bash/ssh-agent.bash (limited to 'bash') diff --git a/bash/board.bash b/bash/board.bash index dfee05f..4df9f2a 100644 --- a/bash/board.bash +++ b/bash/board.bash @@ -1,14 +1,15 @@ #!/bin/bash -BB_HIST_DIR="$HOME/.cache/bashboard/" -BB_SHORTCUT=() -BB_LIST_LEN=5 -BB_PRUNE_DAYS=5 +# config in ~/.files.config + +if [ "$BB_ENABLE"="yes" ]; then + return +fi [ ! -d "$BB_HIST_DIR" ] && mkdir -p "$BB_HIST_DIR" -BB_COLOR_HIGHLIGHT="\e[0;34m" -BB_COLOR_RESET="\e[39m" +# Public var, not config +BB_SHORTCUT=() # format # NUM EPOCH PATH diff --git a/bash/ssh-agent.bash b/bash/ssh-agent.bash new file mode 100644 index 0000000..2f3040b --- /dev/null +++ b/bash/ssh-agent.bash @@ -0,0 +1,30 @@ +# vi: ft=sh + +#SA_SSH_AGENT_STATIC='no' +#SA_SSH_SOCKET="/var/run/user/$UID/ssh-agent.sock" +#SA_SSH_PIDFILE="/var/run/user/$UID/ssh-agent.pid" + +# For use with graphical logins when DEs don't provide an agent +# Flatpak versions of KeePassXC don't allow file access to /var/run. Allow with: +# $ flatpak override org.keepassxc.KeePassXC --user --filesystem=/run/user/$UID/ssh-agent.sock +# Caution: /var/run symlinks to /run. Flatpak for some reason does not resolve symlinks. + +if [ "$SA_SSH_AGENT_STATIC"="yes" ]; then + AGENT_PID='' + if [ -e "$SA_SSH_PIDFILE" ]; then + AGENT_PID=$(cat $SA_SSH_PIDFILE) + fi + + if [ -z "$AGENT_PID" ] || ! kill -s 0 $AGENT_PID > /dev/null 2>&1; then + echo "Agent not running. creating one." + eval $(ssh-agent -s -a $SA_SSH_SOCKET) + + echo "PID: $SSH_AGENT_PID" + echo "$SSH_AGENT_PID" > "$SA_SSH_PIDFILE" + else + echo "Using existing Agent" + export SSH_AUTH_SOCK="$SA_SSH_SOCKET" + fi +fi + +unset AGENT_PID diff --git a/bash/ssh-agent.profile b/bash/ssh-agent.profile index 9912bbf..efa3724 100644 --- a/bash/ssh-agent.profile +++ b/bash/ssh-agent.profile @@ -1,3 +1,9 @@ # vi: ft=sh -[ -z $SSH_AUTH_SOCK ] && eval `ssh-agent` +#SA_SSH_AGENT_STATIC='no' +#SA_SSH_SOCKET="/var/run/user/$UID/ssh-agent.sock" +#SA_SSH_PIDFILE="/var/run/user/$UID/ssh-agent.pid" + +if [ ! "$SA_SSH_AGENT_STATIC"="yes" ]; then + [ -z $SSH_AUTH_SOCK ] && eval `ssh-agent` +fi -- cgit v1.2.3