rename funtion ztools_ensure to zshlibs_ensure

This commit is contained in:
accel 2022-01-11 17:38:50 +03:00
parent 3e308a76aa
commit 63f6e93cda
2 changed files with 27 additions and 26 deletions

View File

@ -35,35 +35,47 @@ function zshlibs_update()
fi fi
} }
function ztools_ensure() function zshlibs_ensure()
{ {
target=${2} target=${2}
typ=${1} typ=${1}
if ! test -e ${target} if ! test -e ${target}
then then
zshlibs_log ztools_ensure "creating '${target}' ($typ) …" zshlibs_log zshlibs_ensure "creating '${target}' ($typ) …"
case $typ in case $typ in
-d) -d)
mkdir -p ${target} \ mkdir -p ${target} \
|| zshlibs_log ztools_ensure "unable to create directory '${target}'" \ || zshlibs_log zshlibs_ensure "unable to create directory '${target}'" \
&& return 2 && return 2
;; ;;
-f) -f)
touch ${target} \ touch ${target} \
|| zshlibs_log ztools_ensure "unable to create file '${target}'" \ || zshlibs_log zshlibs_ensure "unable to create file '${target}'" \
&& return 2 && return 2
esac esac
zshlibs_log ztools_ensure "target '${target}' created" zshlibs_log zshlibs_ensure "target '${target}' created"
elif test ${typ} ${target} elif test ${typ} ${target}
then then
zshlibs_log ztools_ensure "target '${target}' ($typ) present" zshlibs_log zshlibs_ensure "target '${target}' ($typ) present"
return 0 return 0
else else
zshlibs_log ztools_ensure "target '${target}' already exists and it is not a directory" zshlibs_log zshlibs_ensure "target '${target}' already exists and it is not a directory"
return 1 return 1
fi fi
} }
function zshlibs_log()
{
local facility=$1
shift
if [[ -n "${@}" ]]
then
echo "$(date -Ins) ${@}" >> "${HOME}/.log/z_$facility.log"
else
echo "$(date -Ins) $(cat)" >> "${HOME}/.log/z_$facility.log"
fi
}
##### CONFIGURATION LIBRARIES ##### CONFIGURATION LIBRARIES
@ -131,23 +143,12 @@ function zconfigs_local_load()
fi fi
} }
function zshlibs_log()
{
local facility=$1
shift
if [[ -n "${@}" ]]
then
echo "$(date -Ins) ${@}" >> "${HOME}/.log/z_$facility.log"
else
echo "$(date -Ins) $(cat)" >> "${HOME}/.log/z_$facility.log"
fi
}
function zshlibs_boot() function zshlibs_boot()
{ {
# ensure log directory # ensure log directory
zshlibs_log zbootstrap "ensure directory '${HOME}/.log/'" zshlibs_log zbootstrap "ensure directory '${HOME}/.log/'"
ztools_ensure -d "${HOME}/.log/" zshlibs_ensure -d "${HOME}/.log/"
# loading configs # loading configs
typeset -a -g zconfig_loaded typeset -a -g zconfig_loaded
typeset -a -g path_extra typeset -a -g path_extra

View File

@ -15,10 +15,10 @@ function zssh_configure ()
if [[ -n "$zssh_host" ]] if [[ -n "$zssh_host" ]]
then then
zshlibs_log zssh "zssh_host is set" zshlibs_log zssh "zssh_host is set"
ztools_ensure -d $zssh_private_keys zshlibs_ensure -d $zssh_private_keys
ztools_ensure -d $zssh_private_configs zshlibs_ensure -d $zssh_private_configs
ztools_ensure -d ${zssh_global_configs} zshlibs_ensure -d ${zssh_global_configs}
ztools_ensure -d ${zssh_global_pubkeys} zshlibs_ensure -d ${zssh_global_pubkeys}
zssh_enumeratenodes zssh_enumeratenodes
if [[ ${#zssh_host_config_accesses} -gt 0 ]] if [[ ${#zssh_host_config_accesses} -gt 0 ]]
then then
@ -27,8 +27,8 @@ function zssh_configure ()
zshlibs_log zssh "global our config directory is $(zssh_host_info -c)" zshlibs_log zssh "global our config directory is $(zssh_host_info -c)"
typeset -g zssh_global_config_hostdir="${zssh_global_configs}/${zssh_host}" typeset -g zssh_global_config_hostdir="${zssh_global_configs}/${zssh_host}"
typeset -g zssh_global_pubkey_hostdir="${zssh_global_pubkeys}/${zssh_host}" typeset -g zssh_global_pubkey_hostdir="${zssh_global_pubkeys}/${zssh_host}"
ztools_ensure -d $(zssh_host_info -K) #"${zssh_global_pubkey_hostdir}" zshlibs_ensure -d $(zssh_host_info -K) #"${zssh_global_pubkey_hostdir}"
ztools_ensure -d $(zssh_host_info -C) # "${zssh_global_config_hostdir}" zshlibs_ensure -d $(zssh_host_info -C) # "${zssh_global_config_hostdir}"
else else
zshlibs_log zssh "zssh_host_config_accesses is NOT set, not going to bother accepting keys" zshlibs_log zssh "zssh_host_config_accesses is NOT set, not going to bother accepting keys"
fi fi
@ -135,7 +135,7 @@ function zssh_mail_pubkey2()
ssh_node="$1" ssh_node="$1"
if ! [[ $(zssh_node_info ${ssh_node} -k) -ot "$(zssh_node_info ${ssh_node} -K)/$zssh_host.key.pub" ]] if ! [[ $(zssh_node_info ${ssh_node} -k) -ot "$(zssh_node_info ${ssh_node} -K)/$zssh_host.key.pub" ]]
then then
ztools_ensure -d $(zssh_node_info ${ssh_node} -K) zshlibs_ensure -d $(zssh_node_info ${ssh_node} -K)
zshlibs_log zssh "sending '$(zssh_node_info ${ssh_node} -k) to '$(zssh_node_info ${ssh_node} -K ${zssh_host})'" zshlibs_log zssh "sending '$(zssh_node_info ${ssh_node} -k) to '$(zssh_node_info ${ssh_node} -K ${zssh_host})'"
cp $(zssh_node_info ${ssh_node} -k) (zssh_node_info ${ssh_node} -K ${zssh_host}) cp $(zssh_node_info ${ssh_node} -k) (zssh_node_info ${ssh_node} -K ${zssh_host})
else else