From a8e8ba60393c7c0e07e96ac7b08a463ab71733d8 Mon Sep 17 00:00:00 2001 From: Bernhard Landauer Date: Sun, 15 Apr 2018 20:10:20 +0200 Subject: [PATCH] [deployiso] add ssh-agent support --- bin/deployiso.in | 1 + data/manjaro-tools.conf | 3 +++ lib/util-publish.sh | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/bin/deployiso.in b/bin/deployiso.in index f3f0268..a8c2dc4 100644 --- a/bin/deployiso.in +++ b/bin/deployiso.in @@ -56,6 +56,7 @@ display_settings(){ msg2 "account: %s" "${account}" msg2 "host: %s" "${host}" msg2 "alt_storage: %s" "${alt_storage}" + msg2 "ssh_agentt: %s" "${ssh_agent}" msg "UPLOAD QUEUE:" run show_profile "${build_list_iso}" diff --git a/data/manjaro-tools.conf b/data/manjaro-tools.conf index fdb389c..7de484c 100644 --- a/data/manjaro-tools.conf +++ b/data/manjaro-tools.conf @@ -57,6 +57,9 @@ # the server user # account=[SetUser] +# Set to 'true' to use ssh-agent to store passphrase. +# ssh_agent=false + # use alternative storage server (one or the other might be more stable) # alt_storage=false diff --git a/lib/util-publish.sh b/lib/util-publish.sh index 797a2a2..4b3fa13 100644 --- a/lib/util-publish.sh +++ b/lib/util-publish.sh @@ -42,6 +42,27 @@ prepare_transfer(){ ${hidden} && target_dir="${profile}/.${dist_release}" } +start_agent(){ + msg2 "Initializing SSH agent..." + ssh-agent | sed 's/^echo/#echo/' > "$1" + chmod 600 "$1" + . "$1" > /dev/null + ssh-add +} + +ssh_add(){ + local ssh_env="$USER_HOME/.ssh/environment" + + if [ -f "${ssh_env}" ]; then + . "${ssh_env}" > /dev/null + ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || { + start_agent ${ssh_env}; + } + else + start_agent ${ssh_env}; + fi +} + sync_dir(){ cont=1 max_cont=10 @@ -49,6 +70,7 @@ sync_dir(){ ${torrent} && make_torrent ${sign} && signiso "${src_dir}" + ${ssh_agent} && ssh_add msg "Start upload [%s] to [%s] ..." "$1" "${project}" while [[ $cont -le $max_cont ]]; do