Dev: Many little improvement, output reduxx
DONE: - Reduce wasted output blank lines - Simplifie ls output on all modules - Remove sterr output on ls - Clean function syntax (for hier output) - Fix a bug on missing pid for ssh-agent - Remove portion of debug traces (mod_ssh)
This commit is contained in:
parent
30f457a9a0
commit
131e5c8db1
26
bin/idmgr
26
bin/idmgr
@ -99,7 +99,7 @@ idm_core__ls ()
|
|||||||
local id=${1}
|
local id=${1}
|
||||||
#set -x
|
#set -x
|
||||||
|
|
||||||
idm_core_exec_mod $id __ls "\n%s ls" ${IDM_MOD_ORDER//:/ }
|
idm_core_exec_mod $id __ls "%s ls" ${IDM_MOD_ORDER//:/ }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,14 +243,26 @@ idm_core_exec_mod ()
|
|||||||
#set +x
|
#set +x
|
||||||
|
|
||||||
#lib_log INFO "Loading module $i ..."
|
#lib_log INFO "Loading module $i ..."
|
||||||
[ "$sep" == "_" ] || lib_log NOTICE "$(printf "$sep" $i )"
|
#${val} $id || \
|
||||||
|
# {
|
||||||
|
# # DO NOT DISABLE THIS BLOCK, that force plugin to load in anyway
|
||||||
|
# true
|
||||||
|
# lib_log WARN "Module $i failed in some way ... ($action)"
|
||||||
|
# }
|
||||||
|
|
||||||
export IDM_MOD_EXEC=chain
|
export IDM_MOD_EXEC=chain
|
||||||
${val} $id || \
|
local rc=0
|
||||||
{
|
out="$( ${val} $id || rc=$? )"
|
||||||
# DO NOT DISABLE THIS BLOCK, that force plugin to load in anyway
|
|
||||||
true
|
if [ "$rc" -eq 0 -a ! -z "$out" ]; then
|
||||||
|
[ "$sep" == "_" ] ||
|
||||||
|
lib_log NOTICE "$(printf "$sep" $i )"
|
||||||
|
echo -e "$out\n"
|
||||||
|
elif [ "$rc" -ne 0 ]; then
|
||||||
lib_log WARN "Module $i failed in some way ... ($action)"
|
lib_log WARN "Module $i failed in some way ... ($action)"
|
||||||
}
|
echo -e "$out\n"
|
||||||
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
echo ""
|
echo ""
|
||||||
lib_log INFO "Skip module $i"
|
lib_log INFO "Skip module $i"
|
||||||
|
|||||||
@ -22,11 +22,11 @@ idm_cloud__ls ()
|
|||||||
if lib_id_is_enabled $id; then
|
if lib_id_is_enabled $id; then
|
||||||
if [ -f "${OS_CLOUD-}" ]; then
|
if [ -f "${OS_CLOUD-}" ]; then
|
||||||
echo " enabled ($OS_CLOUD)"
|
echo " enabled ($OS_CLOUD)"
|
||||||
else
|
#else
|
||||||
echo " disabled (config is absent ${OS_CLOUD:-${OS_CLOUD:+$OS_CLOUD}})"
|
# echo " disabled (config is absent ${OS_CLOUD:-${OS_CLOUD:+$OS_CLOUD}})"
|
||||||
fi
|
fi
|
||||||
else
|
#else
|
||||||
echo " disabled"
|
# echo " disabled"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,7 +66,10 @@ idm_gpg__ls ()
|
|||||||
local id=${1}
|
local id=${1}
|
||||||
lib_id_is_enabled $id || return 0
|
lib_id_is_enabled $id || return 0
|
||||||
|
|
||||||
gpg --list-keys | sed 's/^/ /' #| lib_log DUMP -
|
{
|
||||||
|
gpg --list-keys 2>/dev/null \
|
||||||
|
|| true
|
||||||
|
} | sed 's/^/ /' #| lib_log DUMP -
|
||||||
}
|
}
|
||||||
|
|
||||||
idm_gpg__new ()
|
idm_gpg__new ()
|
||||||
|
|||||||
@ -33,7 +33,10 @@ idm_pass__ls ()
|
|||||||
local id=${1}
|
local id=${1}
|
||||||
lib_id_is_enabled $id || return 0
|
lib_id_is_enabled $id || return 0
|
||||||
|
|
||||||
PASSWORD_STORE_DIR=~/.config/pass/${id} pass ls | sed 's/^/ /'
|
{
|
||||||
|
PASSWORD_STORE_DIR=~/.config/pass/${id} \
|
||||||
|
pass ls || true
|
||||||
|
} 2>/dev/null | sed 's/^/ /'
|
||||||
}
|
}
|
||||||
|
|
||||||
idm_pass__help ()
|
idm_pass__help ()
|
||||||
|
|||||||
@ -58,7 +58,7 @@ idm_ssh__ls ()
|
|||||||
|
|
||||||
lib_id_is_enabled $id || return 0
|
lib_id_is_enabled $id || return 0
|
||||||
|
|
||||||
{ ssh-add $opt || true ; } | sed 's/^/ /'
|
{ ssh-add $opt || true ; } 2>/dev/null | sed 's/^/ /'
|
||||||
}
|
}
|
||||||
|
|
||||||
idm_ssh__disable ()
|
idm_ssh__disable ()
|
||||||
@ -97,7 +97,8 @@ idm_ssh__enable ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
# LOGOUT
|
# LOGOUT
|
||||||
idm_ssh__kill () {
|
idm_ssh__kill ()
|
||||||
|
{
|
||||||
|
|
||||||
#set -x
|
#set -x
|
||||||
|
|
||||||
@ -178,26 +179,27 @@ idm_ssh__agent_start() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
idm_ssh__agent_clean () {
|
idm_ssh__agent_clean ()
|
||||||
|
{
|
||||||
local id=$1
|
local id=$1
|
||||||
local socket=$2
|
local socket=$2
|
||||||
local pid=${3:-0}
|
local pid=${3:-0}
|
||||||
|
|
||||||
# We should kill all agents ....
|
# We should kill all agents ....
|
||||||
if [ "${pid}" == '0' ]; then
|
if [ "${pid}" == '0' ]; then
|
||||||
set +x
|
#set +x
|
||||||
pid=$(grep -a "$socket" /proc/*/cmdline \
|
pid=$(grep -a "$socket" /proc/*/cmdline \
|
||||||
| grep -a -v 'thread-self' \
|
| grep -a -v 'thread-self' \
|
||||||
| strings -s' ' -1 \
|
| strings -s' ' -1 \
|
||||||
| sed -E 's@ /proc/@ \n/proc/@g'
|
| sed -E 's@ /proc/@ \n/proc/@g'
|
||||||
)
|
)
|
||||||
set -x
|
#set -x
|
||||||
pid="$( sed -E 's@/proc/([0-9]*)/.*@\1@' <<<"$pid" )"
|
pid="$( sed -E 's@/proc/([0-9]*)/.*@\1@' <<<"$pid" )"
|
||||||
fi
|
fi
|
||||||
set -x
|
#set -x
|
||||||
|
|
||||||
# Remove process
|
# Remove process
|
||||||
if [ "$pid" != '0' ]; then
|
if [ "$pid" != '0' -a "$pid" -gt 0 ]; then
|
||||||
kill $pid
|
kill $pid
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@ -70,15 +70,23 @@ idm_tomb__ls ()
|
|||||||
{
|
{
|
||||||
local id=$1
|
local id=$1
|
||||||
|
|
||||||
|
# Show files if there are some
|
||||||
|
if [ -d "$IDM_CONFIG_DIR/enc/" ]; then
|
||||||
echo " Tombs:"
|
echo " Tombs:"
|
||||||
find $IDM_CONFIG_DIR/enc/ -type f -name "*.tomb" | sed "s@$HOME@ ~@"
|
find $IDM_CONFIG_DIR/enc/ -type f -name "*.tomb" | sed "s@$HOME@ ~@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Leave if not enabled
|
||||||
|
lib_id_is_enabled $id &&
|
||||||
|
return 0
|
||||||
|
|
||||||
if lib_id_is_enabled $id; then
|
# Status vars
|
||||||
local tomb_status=
|
local tomb_status=
|
||||||
local tomb_date=
|
local tomb_date=
|
||||||
|
local tomb_show=0
|
||||||
local git_status=
|
local git_status=
|
||||||
local git_date=
|
local git_date=
|
||||||
|
local git_show=0
|
||||||
|
|
||||||
# Load local vars
|
# Load local vars
|
||||||
idm_tomb_header $id
|
idm_tomb_header $id
|
||||||
@ -88,6 +96,7 @@ idm_tomb__ls ()
|
|||||||
tomb_status=present
|
tomb_status=present
|
||||||
tomb_date=$( lib_date_diff_human $(find $git_tomb_enc -printf "%Ts") )
|
tomb_date=$( lib_date_diff_human $(find $git_tomb_enc -printf "%Ts") )
|
||||||
tomb_date=", $tomb_date old"
|
tomb_date=", $tomb_date old"
|
||||||
|
tomb_show=1
|
||||||
else
|
else
|
||||||
tomb_status=absent
|
tomb_status=absent
|
||||||
fi
|
fi
|
||||||
@ -98,9 +107,12 @@ idm_tomb__ls ()
|
|||||||
#git_date=$( lib_date_diff_human $(find $git_tomb_dir -maxdepth 0 -printf "%Ts") )
|
#git_date=$( lib_date_diff_human $(find $git_tomb_dir -maxdepth 0 -printf "%Ts") )
|
||||||
#git_date=" $git_date"
|
#git_date=" $git_date"
|
||||||
else
|
else
|
||||||
git_status=closed
|
git_status="absent (closed)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Leave if nothing to show
|
||||||
|
[ $(( $git_show + $tomb_show )) -eq 0 ] && return
|
||||||
|
|
||||||
# Display
|
# Display
|
||||||
echo " Status:"
|
echo " Status:"
|
||||||
printf " %-20s: %s\n" "encrypted tomb" "$tomb_status${tomb_date}"
|
printf " %-20s: %s\n" "encrypted tomb" "$tomb_status${tomb_date}"
|
||||||
@ -108,15 +120,16 @@ idm_tomb__ls ()
|
|||||||
printf " %-20s: %s\n" "tomb git status" "$git_status${git_date}"
|
printf " %-20s: %s\n" "tomb git status" "$git_status${git_date}"
|
||||||
printf " %-20s: %s\n" "tomb git dir" "$git_tomb_dir"
|
printf " %-20s: %s\n" "tomb git dir" "$git_tomb_dir"
|
||||||
|
|
||||||
|
# Check if local repo is enabled
|
||||||
|
lib_git_is_repo id &>/dev/null ||
|
||||||
|
return 0
|
||||||
|
|
||||||
# Show git remotes
|
# Show git remotes
|
||||||
if lib_git_is_repo id &>/dev/null ; then
|
|
||||||
echo " Git remotes:"
|
echo " Git remotes:"
|
||||||
lib_git id remote -v | sed 's/^/ /'
|
lib_git id remote -v | sed 's/^/ /'
|
||||||
echo " Last commits:"
|
echo " Last commits:"
|
||||||
lib_git id l --color=always | sed 's/^/ /'
|
lib_git id l --color=always | sed 's/^/ /'
|
||||||
echo
|
echo
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user