cleanup code
This commit is contained in:
parent
3572ea87af
commit
86045791d5
5 changed files with 110 additions and 79 deletions
53
bashrc_add
53
bashrc_add
|
@ -10,7 +10,7 @@
|
|||
|
||||
|
||||
# set SSHS to false, if not set
|
||||
if [ -z ${SSHS+x} ]; then export SSHS=false;fi
|
||||
[ -z ${SSHS+x} ] && export SSHS=false
|
||||
|
||||
# check if we are a interactive shell
|
||||
# https://guide.bash.academy/expansions/
|
||||
|
@ -19,40 +19,51 @@ if [[ $- = *i* ]] ; then
|
|||
#echo "interactive shell" >&2
|
||||
|
||||
# define variables
|
||||
# default timeouts defined in myshellconfig_load_default
|
||||
#[ -z "${MYSHELLCONFIG_ROOT_TMOUT+x}" ] && MYSHELLCONFIG_ROOT_TMOUT=500
|
||||
#[ -z "${MYSHELLCONFIG_USER_TMOUT+x}" ] && MYSHELLCONFIG_USER_TMOUT=0
|
||||
# Base Path
|
||||
[ -z "${MYSHELLCONFIG_SUBPATH+x}" ] && export MYSHELLCONFIG_SUBPATH=".local/myshellconfig"
|
||||
[ -z "${MYSHELLCONFIG_BASE+x}" ] && export MYSHELLCONFIG_BASE="${HOME}/${MYSHELLCONFIG_SUBPATH}"
|
||||
# hardcoded paths
|
||||
export MYSHELLCONFIG_BASE_PARENT="$(dirname $MYSHELLCONFIG_BASE)"
|
||||
export MYSHELLCONFIG_BASH_COMPLETION="${HOME}/${MYSHELLCONFIG_SUBPATH}/bash_completion.d"
|
||||
|
||||
# Userdata
|
||||
[ -z "${USERNAME+x}" ] && export USERNAME="$USER"
|
||||
[ -z "${USEREMAIL+x}" ] && export USEREMAIL="$USER@$(domainname -d)"
|
||||
[ -z "${FULLNAME+x}" ] && export FULLNAME="$(getent passwd $USER | cut -d ":" -f 5 | cut -d ',' -f 1)"
|
||||
|
||||
# GIT
|
||||
[ -z "${GIT_AUTHOR_NAME+x}" ] && export GIT_AUTHOR_NAME=$FULLNAME
|
||||
[ -z "${GIT_AUTHOR_EMAIL+x}" ] && export GIT_AUTHOR_EMAIL=$USEREMAIL
|
||||
[ -z "${GIT_COMMITTER_NAME+x}" ] && export GIT_COMMITTER_NAME=$FULLNAME
|
||||
[ -z "${GIT_COMMITTER_EMAIL+x}" ] && export GIT_COMMITTER_EMAIL=$USEREMAIL
|
||||
|
||||
[ -z "${MYSHELLCONFIG_SUBPATH+x}" ] && MYSHELLCONFIG_SUBPATH=".local/myshellconfig"
|
||||
[ -z "${MYSHELLCONFIG_BASE+x}" ] && export MYSHELLCONFIG_BASE="${HOME}/${MYSHELLCONFIG_SUBPATH}"
|
||||
MYSHELLCONFIG_BASE_PARENT="$(dirname $MYSHELLCONFIG_BASE)"
|
||||
[ -z "${MYSHELLCONFIG_LOGDIR+x}" ] && export MYSHELLCONFIG_LOGDIR="${HOME}/logs"
|
||||
[ -z "${MYSHELLCONFIG_LOGFILE+x}" ] && export MYSHELLCONFIG_LOGFILE="${MYSHELLCONFIG_LOGDIR}/myshellconfig.log"
|
||||
[ -z "${MYSHELLCONFIG_GIT_TIMEOUT+x}" ] && MYSHELLCONFIG_GIT_TIMEOUT=5s
|
||||
[ -z "${MYSHELLCONFIG_GIT_CHECKOUT_TIMEOUT+x}" ] && MYSHELLCONFIG_GIT_CHECKOUT_TIMEOUT=20s
|
||||
MYSHELLCONFIG_BASH_COMPLETION="${HOME}/${MYSHELLCONFIG_SUBPATH}/bash_completion.d"
|
||||
[ -z "${MYSHELLCONFIG_GIT_SYNC+x}" ] && MYSHELLCONFIG_GIT_SYNC=true
|
||||
|
||||
[ -z "${MYHSELLCONFIG_LOGLEVEL_DEFAULT+x}" ] && { MYHSELLCONFIG_LOGLEVEL_DEFAULT="INFO"; export MYHSELLCONFIG_LOGLEVEL_DEFAULT; }
|
||||
[ -z "${MYHSELLCONFIG_FILELOGLEVEL_DEFAULT+x}" ] && { MYHSELLCONFIG_FILELOGLEVEL_DEFAULT="INFO"; export MYHSELLCONFIG_FILELOGLEVEL_DEFAULT; }
|
||||
|
||||
# hardcoded git
|
||||
export SGIT="git -C ${MYSHELLCONFIG_BASE}"
|
||||
|
||||
|
||||
|
||||
# git-repo-url for vim plugin
|
||||
# TODO: check how to use
|
||||
export MYSHELLCONFIG_VIM_PLUGINS
|
||||
|
||||
# Create necessary directories
|
||||
[ -n "${MYSHELLCONFIG_LOGDIR-x}" ] && mkdir -p "$MYSHELLCONFIG_LOGDIR"
|
||||
|
||||
[ -z "${SCRIPT_LOG+x}" ] && { SCRIPT_LOG="${MYSHELLCONFIG_LOGFILE}"; export SCRIPT_LOG; }
|
||||
. ${MYSHELLCONFIG_BASE}/loggingfunctions
|
||||
# Logging
|
||||
[ -z "${MYSHELLCONFIG_LOGDIR+x}" ] && export MYSHELLCONFIG_LOGDIR="${HOME}/logs"
|
||||
[ -z "${MYSHELLCONFIG_LOGFILE+x}" ] && export MYSHELLCONFIG_LOGFILE="${MYSHELLCONFIG_LOGDIR}/myshellconfig.log"
|
||||
[ -z "${MYHSELLCONFIG_LOGLEVEL_DEFAULT+x}" ] && export MYHSELLCONFIG_LOGLEVEL_DEFAULT="INFO"
|
||||
[ -z "${MYHSELLCONFIG_FILELOGLEVEL_DEFAULT+x}" ] && export MYHSELLCONFIG_FILELOGLEVEL_DEFAULT="INFO"
|
||||
[ -z "${SCRIPT_LOG+x}" ] && { SCRIPT_LOG="${MYSHELLCONFIG_LOGFILE}"; export SCRIPT_LOG; }
|
||||
[ -z "${LOGLEVEL_DEFAULT+x}" ] && { LOGLEVEL_DEFAULT="${MYHSELLCONFIG_LOGLEVEL_DEFAULT-INFO}"; export LOGLEVEL_DEFAULT; }
|
||||
[ -z "${FILELOGLEVEL_DEFAULT+x}" ] && { FILELOGLEVEL_DEFAULT=${MYHSELLCONFIG_FILELOGLEVEL_DEFAULT-INFO}; export FILELOGLEVEL_DEFAULT; }
|
||||
# Create necessary directories for logging
|
||||
[ -n "${MYSHELLCONFIG_LOGDIR-x}" ] && mkdir -p "$MYSHELLCONFIG_LOGDIR"
|
||||
# load logging functions
|
||||
. ${MYSHELLCONFIG_BASE}/logging
|
||||
|
||||
cat << EOF >> "${MYSHELLCONFIG_LOGFILE}"
|
||||
------- start -------------- $(date) ---------------8<--
|
||||
------- start configure new shell -------------- $(date) ---------------8<--
|
||||
|
||||
EOF
|
||||
|
||||
|
@ -125,7 +136,7 @@ EOF
|
|||
|
||||
|
||||
cat << EOF >> "${MYSHELLCONFIG_LOGFILE}"
|
||||
--8<--- end ---------------- $(date) ---------------8<--
|
||||
--8<--- finished configure new shell ---------------- $(date) ---------------8<--
|
||||
SCRIPTEXIT
|
||||
|
||||
EOF
|
||||
|
|
|
@ -10,6 +10,7 @@ logdebug "SSH_IDENTITIES_DIR: $SSH_IDENTITIES_DIR" >&2
|
|||
[ -z "${SSH_AGENTS_DIR-x}" ] || mkdir -vp "$SSH_AGENTS_DIR"
|
||||
[ -z "${SSH_AGENT_SOCKETS_DIR-x}" ] || mkdir -vp "$SSH_AGENT_SOCKETS_DIR"
|
||||
[ -z "${SSH_IDENTITIES_DIR-x}" ] || mkdir -vp "$SSH_IDENTITIES_DIR"
|
||||
|
||||
agent-start-or-restart () {
|
||||
|
||||
ENTRY
|
||||
|
@ -26,33 +27,30 @@ agent-start-or-restart () {
|
|||
logdebug "ssh-identität: $ssh_identity" >&2
|
||||
if [ -e $agentfile ]; then
|
||||
|
||||
# look if agent is reachable
|
||||
# local sshsock sshpid
|
||||
# sshsock=$SSH_AUTH_SOCK
|
||||
# sshpid=$SSH_AGENT_PID
|
||||
# unset SSH_AUTH_SOCK SSH_AGENT_PID
|
||||
logdebug "$(/bin/sh -c "unset SSH_AUTH_SOCK SSH_AGENT_PID; . $agentfile >/dev/null 2>&1; ssh-add -l")"
|
||||
loginfo "$(/bin/sh -c "unset SSH_AUTH_SOCK SSH_AGENT_PID; . $agentfile >/dev/null 2>&1; ssh-add -l >/dev/null")"
|
||||
case $? in
|
||||
0|1)
|
||||
logdebug "agent is running" >&2
|
||||
0)
|
||||
loginfo "agent is running" >&2
|
||||
;;
|
||||
1)
|
||||
logwarn "command failed on ssh-agent"
|
||||
;;
|
||||
2)
|
||||
logdebug "agent is not running 1" >&2
|
||||
[ -e $agentsocket ] && rm "$agentsocket"
|
||||
ssh-agent -a $agentsocket $SSH_AGENT_OPTIONS > $agentfile 2>&2
|
||||
logdebug "agent started" >&2
|
||||
loginfo "former agent is not running" >&2
|
||||
[ -e $agentsocket ] && { logdebug -n "remove socketfile: $( rm -v "$agentsocket" )"; }
|
||||
logdebug "$(ssh-agent -a $agentsocket $SSH_AGENT_OPTIONS > $agentfile )"
|
||||
loginfo "agent started" >&2
|
||||
;;
|
||||
esac
|
||||
else
|
||||
logdebug "agent is not running 2" >&2
|
||||
loginfo "agent did not exist" >&2
|
||||
#rm "$agentsocket"
|
||||
logdebug "ssh-agent -a $agentsocket \> $agentfile"
|
||||
ssh-agent -a $agentsocket $SSH_AGENT_OPTIONS > $agentfile 2>&2
|
||||
logdebug "agent started" >&2
|
||||
logdebug "$(ssh-agent -a $agentsocket $SSH_AGENT_OPTIONS > $agentfile )"
|
||||
loginfo "agent started" >&2
|
||||
fi
|
||||
|
||||
loginfo "agent for $ssh_identity: $agentfile"
|
||||
echo -n "agent for $ssh_identity: " >&2
|
||||
logdebug "agent for $ssh_identity: $agentfile"
|
||||
echo $agentfile
|
||||
return 0
|
||||
|
||||
|
@ -79,37 +77,39 @@ agent-load-identity-keys () {
|
|||
if [ -n "${1+x}" ]; then
|
||||
ssh_identity="$1"
|
||||
identitydir=${SSH_IDENTITIES_DIR}/${ssh_identity}
|
||||
[ -e "${identitydir}/.config" ] && . "${identitydir}/.config"
|
||||
[ -e "${identitydir}/config" ] && . "${identitydir}/config"
|
||||
agentfile="${SSH_AGENTS_DIR}/agent-${ssh_identity}-$(hostname)"
|
||||
agentsocket="${SSH_AGENT_SOCKETS_DIR}/socket-${ssh_identity}-$(hostname)"
|
||||
logdebug "agentfile: $agentfile" >&2
|
||||
logdebug "agentsocket: $agentsocket" >&2
|
||||
logdebug "ssh-identität: $ssh_identity" >&2
|
||||
logdebug "identitydir: $identitydir"
|
||||
loginfo "ssh-identität: $ssh_identity" >&2
|
||||
loginfo "SSH_ADD_OPTIONS: $SSH_ADD_OPTIONS"
|
||||
|
||||
fingerprints=( $(ssh-runinagent $agentfile "ssh-add -l|awk '{print \$2}'") )
|
||||
for key in $(ls ${SSH_IDENTITIES_DIR}/${ssh_identity}|grep -v "pub$\|so$"); do
|
||||
logtrace "key: $key"
|
||||
for key in $(ls ${SSH_IDENTITIES_DIR}/${ssh_identity}/id_*|grep -v "pub$\|so$\|config$\|public$"); do
|
||||
logdebug "key: $key"
|
||||
fingerprint=$(ssh-keygen -l -f ~/.ssh/identities/bmi/id_ed25519|awk '{print $2}')
|
||||
logtrace "${fingerprints[*]} and $fingerprint"
|
||||
if [[ ${fingerprints[*]} =~ "$fingerprint" ]]; then
|
||||
logdebug "$key is loaded" >&2
|
||||
else
|
||||
logdebug "$key is not loaded" >&2
|
||||
loginfo "$(ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} ${identitydir}/${key})"
|
||||
loginfo "$(ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} ${key})"
|
||||
fi
|
||||
done
|
||||
for token in $(ls ${SSH_IDENTITIES_DIR}/${ssh_identity}|grep "so$"); do
|
||||
logtrace "token: $token"
|
||||
for token in $(ls ${SSH_IDENTITIES_DIR}/${ssh_identity}/*|grep "\.so$"); do
|
||||
logdebug "token: $token"
|
||||
tokenfingerprint="$(ssh-keygen -l -D $token|tr -s ' '|awk '{print $2}')"
|
||||
logtrace "${fingerprints[*]} and $tokenfingerprint"
|
||||
if [[ ${fingerprints[*]} =~ "$tokenfingerprint" ]]; then
|
||||
logdebug "$token is loaded" >&2
|
||||
else
|
||||
logdebug "$token is not loaded" >&2
|
||||
loginfo "$(ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -s ${identitydir}/${token})"
|
||||
loginfo "$(ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -s /${token})"
|
||||
fi
|
||||
done
|
||||
logdebug "current loaded keys: $(ssh-runinagent $agentfile ssh-add -l)"
|
||||
fi
|
||||
EXIT
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ ssh-runinagent () {
|
|||
shift
|
||||
sshcommand=${@}
|
||||
|
||||
logtrace "run command »$sshcommand« in agent $agentfile" >&2
|
||||
logdebug "run command »$sshcommand« in agent $agentfile" >&2
|
||||
if [ -e "$agentfile" ]; then
|
||||
/bin/sh -c "unset SSH_AUTH_SOCK SSH_AGENT_PID; . $agentfile >/dev/null 2>/dev/null; $sshcommand"
|
||||
EXIT
|
||||
|
|
|
@ -844,7 +844,7 @@ loadagent() {
|
|||
ENTRY
|
||||
local af
|
||||
af=$(ssh-agent-start-or-restart $1 2>/dev/null)
|
||||
echo $af
|
||||
loginfo "Load agent from $af"
|
||||
# eval $(<$af)
|
||||
. $af
|
||||
EXIT
|
||||
|
@ -871,6 +871,7 @@ ssh-runinagent () {
|
|||
setloglevel () {
|
||||
ENTRY
|
||||
local loglevels
|
||||
local oldloglevel=$LOGLEVEL
|
||||
declare -a loglevels
|
||||
loglevels=("ERROR" "WARN" "INFO" "DEBUG" "TRACE")
|
||||
if [[ ${loglevels[*]} =~ "$1" ]]; then
|
||||
|
@ -878,13 +879,14 @@ setloglevel () {
|
|||
else
|
||||
logerror "LOGLEVEL must be one of ERROR, WARN, INFO, DEBUG or TRACE"
|
||||
fi
|
||||
logerror "new LOGLEVEL is $LOGLEVEL"
|
||||
logerror "new LOGLEVEL is $LOGLEVEL (changed from $oldloglevel)"
|
||||
EXIT
|
||||
}
|
||||
|
||||
setfileloglevel () {
|
||||
ENTRY
|
||||
local loglevels
|
||||
local oldloglevel=${FILELOGLEVEL-${MYSHELLCONFIG_FILELOGLEVEL_DEFAULT}}
|
||||
declare -a loglevels
|
||||
loglevels=("ERROR" "WARN" "INFO" "DEBUG" "TRACE")
|
||||
if [[ ${loglevels[*]} =~ "$1" ]]; then
|
||||
|
@ -892,7 +894,7 @@ setfileloglevel () {
|
|||
else
|
||||
logerror "FILELOGLEVEL must be one of ERROR, WARN, INFO, DEBUG or TRACE"
|
||||
fi
|
||||
logerror "new FILELOGLEVEL is $FILELOGLEVEL"
|
||||
logerror "new FILELOGLEVEL is $FILELOGLEVEL (changed from $oldloglevel)"
|
||||
EXIT
|
||||
}
|
||||
|
||||
|
|
|
@ -5,32 +5,50 @@
|
|||
mkdir -p "$(dirname ${SCRIPT_LOG})"
|
||||
touch $SCRIPT_LOG
|
||||
|
||||
[ -z "${MYHSELLCONFIG_LOGLEVEL_DEFAULT+x}" ] && { MYHSELLCONFIG_LOGLEVEL_DEFAULT="INFO"; export MYHSELLCONFIG_LOGLEVEL_DEFAULT; }
|
||||
[ -z "${MYHSELLCONFIG_FILELOGLEVEL_DEFAULT+x}" ] && { MYHSELLCONFIG_FILELOGLEVEL_DEFAULT="INFO"; export MYHSELLCONFIG_FILELOGLEVEL_DEFAULT; }
|
||||
|
||||
function SCRIPTENTRY(){
|
||||
timeAndDate=`date`
|
||||
script_name=`basename -- "$0"`
|
||||
script_name="${script_name%.*}"
|
||||
echo "[$timeAndDate] [DEBUG] > $script_name $FUNCNAME" >> $SCRIPT_LOG
|
||||
local loglevels
|
||||
declare -a loglevels
|
||||
loglevels=("ERROR" "WARN" "INFO")
|
||||
if [[ ! ${loglevels[*]} =~ "${LOGLEVEL-$LOGLEVEL_DEFAULT}" ]];then
|
||||
timeAndDate=`date`
|
||||
script_name=`basename -- "$0"`
|
||||
script_name="${script_name%.*}"
|
||||
echo "[$timeAndDate] [DEBUG] > $script_name $FUNCNAME" >> $SCRIPT_LOG
|
||||
fi
|
||||
}
|
||||
|
||||
function SCRIPTEXIT(){
|
||||
script_name=`basename -- "$0"`
|
||||
script_name="${script_name%.*}"
|
||||
echo "[$timeAndDate] [DEBUG] < $script_name $FUNCNAME" >> $SCRIPT_LOG
|
||||
local loglevels
|
||||
declare -a loglevels
|
||||
loglevels=("ERROR" "WARN" "INFO")
|
||||
if [[ ! ${loglevels[*]} =~ "${LOGLEVEL-$LOGLEVEL_DEFAULT}" ]];then
|
||||
script_name=`basename -- "$0"`
|
||||
script_name="${script_name%.*}"
|
||||
echo "[$timeAndDate] [DEBUG] < $script_name $FUNCNAME" >> $SCRIPT_LOG
|
||||
fi
|
||||
}
|
||||
|
||||
function ENTRY(){
|
||||
local cfn="${FUNCNAME[1]}"
|
||||
timeAndDate=`date`
|
||||
echo "[$timeAndDate] [DEBUG] > $cfn $FUNCNAME" >> $SCRIPT_LOG
|
||||
local loglevels
|
||||
declare -a loglevels
|
||||
loglevels=("ERROR" "WARN" "INFO")
|
||||
if [[ ! ${loglevels[*]} =~ "${LOGLEVEL-$LOGLEVEL_DEFAULT}" ]];then
|
||||
local cfn="${FUNCNAME[1]}"
|
||||
timeAndDate=`date`
|
||||
echo "[$timeAndDate] [DEBUG] > $cfn $FUNCNAME" >> $SCRIPT_LOG
|
||||
fi
|
||||
}
|
||||
|
||||
function EXIT(){
|
||||
local cfn="${FUNCNAME[1]}"
|
||||
timeAndDate=`date`
|
||||
echo "[$timeAndDate] [DEBUG] < $cfn $FUNCNAME" >> $SCRIPT_LOG
|
||||
local loglevels
|
||||
declare -a loglevels
|
||||
loglevels=("ERROR" "WARN" "INFO")
|
||||
if [[ ! ${loglevels[*]} =~ "${LOGLEVEL-$LOGLEVEL_DEFAULT}" ]];then
|
||||
local cfn="${FUNCNAME[1]}"
|
||||
timeAndDate=`date`
|
||||
echo "[$timeAndDate] [DEBUG] < $cfn $FUNCNAME" >> $SCRIPT_LOG
|
||||
fi
|
||||
}
|
||||
|
||||
function logerror(){
|
||||
|
@ -46,10 +64,10 @@ function logerror(){
|
|||
local loglevels
|
||||
declare -a loglevels
|
||||
loglevels=()
|
||||
if [[ ! ${loglevels[*]} =~ "${LOGLEVEL-$MYHSELLCONFIG_LOGLEVEL_DEFAULT}" ]];then
|
||||
if [[ ! ${loglevels[*]} =~ "${LOGLEVEL-$LOGLEVEL_DEFAULT}" ]];then
|
||||
echo $opts $msg >&2
|
||||
fi
|
||||
if [[ ! ${loglevels[*]} =~ "${FILELOGLEVEL-$MYHSELLCONFIG_FILELOGLEVEL_DEFAULT}" ]];then
|
||||
if [[ ! ${loglevels[*]} =~ "${FILELOGLEVEL-$FILELOGLEVEL_DEFAULT}" ]];then
|
||||
echo "[$timeAndDate] [ERROR] $msg" >> $SCRIPT_LOG
|
||||
fi
|
||||
}
|
||||
|
@ -67,10 +85,10 @@ function logwarn(){
|
|||
local loglevels
|
||||
declare -a loglevels
|
||||
loglevels=("ERROR" )
|
||||
if [[ ! ${loglevels[*]} =~ "${LOGLEVEL-$MYHSELLCONFIG_LOGLEVEL_DEFAULT}" ]];then
|
||||
if [[ ! ${loglevels[*]} =~ "${LOGLEVEL-$LOGLEVEL_DEFAULT}" ]];then
|
||||
echo $opts $msg >&2
|
||||
fi
|
||||
if [[ ! ${loglevels[*]} =~ "${FILELOGLEVEL-$MYHSELLCONFIG_FILELOGLEVEL_DEFAULT}" ]];then
|
||||
if [[ ! ${loglevels[*]} =~ "${FILELOGLEVEL-$FILELOGLEVEL_DEFAULT}" ]];then
|
||||
echo "[$timeAndDate] [WARN] $msg" >> $SCRIPT_LOG
|
||||
fi
|
||||
}
|
||||
|
@ -88,10 +106,10 @@ function loginfo(){
|
|||
local loglevels
|
||||
declare -a loglevels
|
||||
loglevels=("ERROR" "WARN" )
|
||||
if [[ ! ${loglevels[*]} =~ "${LOGLEVEL-$MYHSELLCONFIG_LOGLEVEL_DEFAULT}" ]];then
|
||||
if [[ ! ${loglevels[*]} =~ "${LOGLEVEL-$LOGLEVEL_DEFAULT}" ]];then
|
||||
echo $opts $msg >&2
|
||||
fi
|
||||
if [[ ! ${loglevels[*]} =~ "${FILELOGLEVEL-$MYHSELLCONFIG_FILELOGLEVEL_DEFAULT}" ]];then
|
||||
if [[ ! ${loglevels[*]} =~ "${FILELOGLEVEL-$FILELOGLEVEL_DEFAULT}" ]];then
|
||||
echo "[$timeAndDate] [INFO] $msg" >> $SCRIPT_LOG
|
||||
fi
|
||||
}
|
||||
|
@ -110,10 +128,10 @@ function logdebug(){
|
|||
local loglevels
|
||||
declare -a loglevels
|
||||
loglevels=("ERROR" "WARN" "INFO")
|
||||
if [[ ! ${loglevels[*]} =~ "${LOGLEVEL-$MYHSELLCONFIG_LOGLEVEL_DEFAULT}" ]];then
|
||||
if [[ ! ${loglevels[*]} =~ "${LOGLEVEL-$LOGLEVEL_DEFAULT}" ]];then
|
||||
echo $opts $msg >&2
|
||||
fi
|
||||
if [[ ! ${loglevels[*]} =~ "${FILELOGLEVEL-$MYHSELLCONFIG_FILELOGLEVEL_DEFAULT}" ]];then
|
||||
if [[ ! ${loglevels[*]} =~ "${FILELOGLEVEL-$FILELOGLEVEL_DEFAULT}" ]];then
|
||||
echo "[$timeAndDate] [DEBUG] $msg" >> $SCRIPT_LOG
|
||||
fi
|
||||
}
|
||||
|
@ -131,10 +149,10 @@ function logtrace(){
|
|||
local loglevels
|
||||
declare -a loglevels
|
||||
loglevels=("ERROR" "WARN" "INFO" "DEBUG")
|
||||
if [[ ! ${loglevels[*]} =~ "${LOGLEVEL-$MYHSELLCONFIG_LOGLEVEL_DEFAULT}" ]];then
|
||||
if [[ ! ${loglevels[*]} =~ "${LOGLEVEL-$LOGLEVEL_DEFAULT}" ]];then
|
||||
echo $opts $msg >&2
|
||||
fi
|
||||
if [[ ! ${loglevels[*]} =~ "${FILELOGLEVEL-$MYHSELLCONFIG_FILELOGLEVEL_DEFAULT}" ]];then
|
||||
if [[ ! ${loglevels[*]} =~ "${FILELOGLEVEL-$FILELOGLEVEL_DEFAULT}" ]];then
|
||||
echo "[$timeAndDate] [TRACE] $msg" >> $SCRIPT_LOG
|
||||
fi
|
||||
}
|
|
@ -142,7 +142,7 @@ SSH_AGENT_PID=${SSH_AGENT_PID}; export SSH_AGENT_PID;
|
|||
loginfo Agent pid ${SSH_AGENT_PID};
|
||||
EOF
|
||||
|
||||
[ -z "${SSH_ADD_DEFAULT_OPTIONS+x}" ] && { SSH_ADD_DEFAULT_OPTIONS="-t 7200"; export SSH_ADD_DEFAULT_OPTIONS; }
|
||||
[ -z "${SSH_IDENTITIES_DEFAULT_DIR+x}" ] && { SSH_IDENTITIES_DEFAULT_DIR="${HOME}/.ssh/identities"; export SSH_IDENTITIES_DEFAULT_DIR; }
|
||||
[ -z "${SSH_AGENTS_DEFAULT_DIR+x}" ] && { SSH_AGENTS_DEFAULT_DIR="${HOME}/.ssh/agents"; export SSH_AGENTS_DEFAULT_DIR; }
|
||||
[ -z "${SSH_AGENT_SOCKETS_DEFAULT_DIR+x}" ] && { SSH_AGENT_SOCKETS_DEFAULT_DIR="${HOME}/.ssh/agents"; export SSH_AGENT_SOCKETS_DEFAULT_DIR; }
|
||||
[ -z "${SSH_ADD_DEFAULT_OPTIONS+x}" ] && { SSH_ADD_DEFAULT_OPTIONS="-t 7200"; export SSH_ADD_DEFAULT_OPTIONS; }
|
||||
[ -z "${SSH_IDENTITIES_DEFAULT_DIR+x}" ] && { SSH_IDENTITIES_DEFAULT_DIR="${HOME}/.ssh/identities"; export SSH_IDENTITIES_DEFAULT_DIR; }
|
||||
[ -z "${SSH_AGENTS_DEFAULT_DIR+x}" ] && { SSH_AGENTS_DEFAULT_DIR="${HOME}/.ssh/agents"; export SSH_AGENTS_DEFAULT_DIR; }
|
||||
[ -z "${SSH_AGENT_SOCKETS_DEFAULT_DIR+x}" ] && { SSH_AGENT_SOCKETS_DEFAULT_DIR="${HOME}/.ssh/agents"; export SSH_AGENT_SOCKETS_DEFAULT_DIR; }
|
||||
|
|
Loading…
Reference in a new issue