From 63f6e93cda69285ecc4448b53d6806e0e135afbc Mon Sep 17 00:00:00 2001 From: accel Date: Tue, 11 Jan 2022 17:38:50 +0300 Subject: [PATCH] rename funtion ztools_ensure to zshlibs_ensure --- global.funcs.zsh | 39 ++++++++++++++++++++------------------- zssh.funcs.zsh | 14 +++++++------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/global.funcs.zsh b/global.funcs.zsh index b70d735..ea05a4e 100644 --- a/global.funcs.zsh +++ b/global.funcs.zsh @@ -35,35 +35,47 @@ function zshlibs_update() fi } -function ztools_ensure() +function zshlibs_ensure() { target=${2} typ=${1} if ! test -e ${target} then - zshlibs_log ztools_ensure "creating '${target}' ($typ) …" + zshlibs_log zshlibs_ensure "creating '${target}' ($typ) …" case $typ in -d) mkdir -p ${target} \ - || zshlibs_log ztools_ensure "unable to create directory '${target}'" \ + || zshlibs_log zshlibs_ensure "unable to create directory '${target}'" \ && return 2 ;; -f) touch ${target} \ - || zshlibs_log ztools_ensure "unable to create file '${target}'" \ + || zshlibs_log zshlibs_ensure "unable to create file '${target}'" \ && return 2 esac - zshlibs_log ztools_ensure "target '${target}' created" + zshlibs_log zshlibs_ensure "target '${target}' created" elif test ${typ} ${target} then - zshlibs_log ztools_ensure "target '${target}' ($typ) present" + zshlibs_log zshlibs_ensure "target '${target}' ($typ) present" return 0 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 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 @@ -131,23 +143,12 @@ function zconfigs_local_load() 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() { # ensure log directory zshlibs_log zbootstrap "ensure directory '${HOME}/.log/'" - ztools_ensure -d "${HOME}/.log/" + zshlibs_ensure -d "${HOME}/.log/" # loading configs typeset -a -g zconfig_loaded typeset -a -g path_extra diff --git a/zssh.funcs.zsh b/zssh.funcs.zsh index 64d9d39..9274df7 100644 --- a/zssh.funcs.zsh +++ b/zssh.funcs.zsh @@ -15,10 +15,10 @@ function zssh_configure () if [[ -n "$zssh_host" ]] then zshlibs_log zssh "zssh_host is set" - ztools_ensure -d $zssh_private_keys - ztools_ensure -d $zssh_private_configs - ztools_ensure -d ${zssh_global_configs} - ztools_ensure -d ${zssh_global_pubkeys} + zshlibs_ensure -d $zssh_private_keys + zshlibs_ensure -d $zssh_private_configs + zshlibs_ensure -d ${zssh_global_configs} + zshlibs_ensure -d ${zssh_global_pubkeys} zssh_enumeratenodes if [[ ${#zssh_host_config_accesses} -gt 0 ]] then @@ -27,8 +27,8 @@ function zssh_configure () 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_pubkey_hostdir="${zssh_global_pubkeys}/${zssh_host}" - ztools_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 -K) #"${zssh_global_pubkey_hostdir}" + zshlibs_ensure -d $(zssh_host_info -C) # "${zssh_global_config_hostdir}" else zshlibs_log zssh "zssh_host_config_accesses is NOT set, not going to bother accepting keys" fi @@ -135,7 +135,7 @@ function zssh_mail_pubkey2() ssh_node="$1" if ! [[ $(zssh_node_info ${ssh_node} -k) -ot "$(zssh_node_info ${ssh_node} -K)/$zssh_host.key.pub" ]] 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})'" cp $(zssh_node_info ${ssh_node} -k) (zssh_node_info ${ssh_node} -K ${zssh_host}) else