From 3e308a76aad65d09c044b65fecb3729e8dcebbaa Mon Sep 17 00:00:00 2001 From: accel Date: Tue, 11 Jan 2022 17:35:56 +0300 Subject: [PATCH] rename funtion zbootstrap_message to zshlibs_log --- global.funcs.zsh | 48 ++++++++++++++++++++--------------------- zssh.funcs.zsh | 56 ++++++++++++++++++++++++------------------------ 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/global.funcs.zsh b/global.funcs.zsh index bdbea69..b70d735 100644 --- a/global.funcs.zsh +++ b/global.funcs.zsh @@ -17,16 +17,16 @@ fi function zshlibs_update() { - zbootstrap_message zlibs_update "preparing self update …" + zshlibs_log zlibs_update "preparing self update …" if [[ -n "$zshlibs_install" ]] then - zbootstrap_message zlibs_update "cd into '$zshlibs_install' …" + zshlibs_log zlibs_update "cd into '$zshlibs_install' …" pushd $zshlibs_install 2>&1 > /dev/null - zbootstrap_message zlibs_update "git pull …" + zshlibs_log zlibs_update "git pull …" ( - git pull 2>&1 |zbootstrap_message zlibs_update & # > "${HOME}/.log/z_zshlibs_update" & + git pull 2>&1 |zshlibs_log zlibs_update & # > "${HOME}/.log/z_zshlibs_update" & ) - zbootstrap_message zlibs_update "update done" + zshlibs_log zlibs_update "update done" popd 2>&1 > /dev/null else echo "\$zshlibs_install not set!" @@ -41,25 +41,25 @@ function ztools_ensure() typ=${1} if ! test -e ${target} then - zbootstrap_message ztools_ensure "creating '${target}' ($typ) …" + zshlibs_log ztools_ensure "creating '${target}' ($typ) …" case $typ in -d) mkdir -p ${target} \ - || zbootstrap_message ztools_ensure "unable to create directory '${target}'" \ + || zshlibs_log ztools_ensure "unable to create directory '${target}'" \ && return 2 ;; -f) touch ${target} \ - || zbootstrap_message ztools_ensure "unable to create file '${target}'" \ + || zshlibs_log ztools_ensure "unable to create file '${target}'" \ && return 2 esac - zbootstrap_message ztools_ensure "target '${target}' created" + zshlibs_log ztools_ensure "target '${target}' created" elif test ${typ} ${target} then - zbootstrap_message ztools_ensure "target '${target}' ($typ) present" + zshlibs_log ztools_ensure "target '${target}' ($typ) present" return 0 else - zbootstrap_message ztools_ensure "target '${target}' already exists and it is not a directory" + zshlibs_log ztools_ensure "target '${target}' already exists and it is not a directory" return 1 fi } @@ -99,12 +99,12 @@ function zconfig_checkload() typeset -a -g zconfig_loaded if [[ ! ${zconfig_loaded[(r)${1}]} ]] then - zbootstrap_message zbootstrap "sourcing config '$1'" - . -- $1 2>&1 >(zbootstrap_message zbootstrap) # >> "${HOME}/.log/z_zbootstrap.log" + zshlibs_log zbootstrap "sourcing config '$1'" + . -- $1 2>&1 >(zshlibs_log zbootstrap) # >> "${HOME}/.log/z_zbootstrap.log" zconfig_loaded+=("$1") - zbootstrap_message zbootstrap "end sourcing config '$1'" + zshlibs_log zbootstrap "end sourcing config '$1'" else - zbootstrap_message zbootstrap "config '$1' already loaded" + zshlibs_log zbootstrap "config '$1' already loaded" fi } @@ -131,7 +131,7 @@ function zconfigs_local_load() fi } -function zbootstrap_message() +function zshlibs_log() { local facility=$1 shift @@ -146,7 +146,7 @@ function zbootstrap_message() function zshlibs_boot() { # ensure log directory - zbootstrap_message zbootstrap "ensure directory '${HOME}/.log/'" + zshlibs_log zbootstrap "ensure directory '${HOME}/.log/'" ztools_ensure -d "${HOME}/.log/" # loading configs typeset -a -g zconfig_loaded @@ -158,20 +158,20 @@ function zshlibs_boot() function zbootstrap_noninteractive() { - zbootstrap_message zbootstrap 'load global config' + zshlibs_log zbootstrap 'load global config' zconfig_checkload ${zconfig_shared_path}/global.config.zsh - zbootstrap_message zbootstrap 'load local configs' + zshlibs_log zbootstrap 'load local configs' zconfigs_local_load for zconfig in $config_extra; do - zbootstrap_message zbootstrap 'load config extra $zconfig' + zshlibs_log zbootstrap 'load config extra $zconfig' zconfig_checkload ${zconfig_shared_path}/${zconfig}.config.zsh done # expanding settings - zbootstrap_message zbootstrap "expanding path with '$path_extra'" + zshlibs_log zbootstrap "expanding path with '$path_extra'" global_path_expand $path_extra - zbootstrap_message zbootstrap "expanding fpath with '$fpath_extra'" + zshlibs_log zbootstrap "expanding fpath with '$fpath_extra'" global_fpath_expand vanilla - zbootstrap_message zbootstrap "done loading noninteractive config" + zshlibs_log zbootstrap "done loading noninteractive config" } function zbootstrap () @@ -180,5 +180,5 @@ function zbootstrap () zbootstrap_noninteractive zconfig_checkload ${zconfig_shared_path}/global.style.zsh zshlibs_update - zbootstrap_message zbootstrap "done loading interactive config" + zshlibs_log zbootstrap "done loading interactive config" } diff --git a/zssh.funcs.zsh b/zssh.funcs.zsh index db4d9de..64d9d39 100644 --- a/zssh.funcs.zsh +++ b/zssh.funcs.zsh @@ -1,6 +1,6 @@ function zssh_boot() { - zbootstrap_message zssh "zssh is booting up ----------------------------" + zshlibs_log zssh "zssh is booting up ----------------------------" typeset -g zssh_ssh_dotdir="${HOME}/.ssh" typeset -g zssh_private_keys="${zssh_ssh_dotdir}/keystore" typeset -g zssh_private_configs="${zssh_ssh_dotdir}/config.d" @@ -14,7 +14,7 @@ function zssh_configure () { if [[ -n "$zssh_host" ]] then - zbootstrap_message zssh "zssh_host is set" + 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} @@ -22,18 +22,18 @@ function zssh_configure () zssh_enumeratenodes if [[ ${#zssh_host_config_accesses} -gt 0 ]] then - zbootstrap_message zssh "zssh_host_config_accesses is set" - zbootstrap_message zssh "global our pubkey directory is $(zssh_host_info -K)" - zbootstrap_message zssh "global our config directory is $(zssh_host_info -c)" + zshlibs_log zssh "zssh_host_config_accesses is set" + zshlibs_log zssh "global our pubkey directory is $(zssh_host_info -K)" + 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}" else - zbootstrap_message 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 else - zbootstrap_message zssh "zssh_host is NOT set, which means we cannot neither publish keys nor accept them" + zshlibs_log zssh "zssh_host is NOT set, which means we cannot neither publish keys nor accept them" fi } @@ -88,17 +88,17 @@ function zssh_process() then if [[ ${#zssh_host_config_accesses} -gt 0 ]] then - zbootstrap_message zssh "processing ssh server setup" + zshlibs_log zssh "processing ssh server setup" if [[ "${HOME}/.config/zsh/local.config.zsh" -nt $(zssh_host_info -c) ]] then - zbootstrap_message zssh "publishing our configs …" + zshlibs_log zssh "publishing our configs …" zssh_publish_configs else - zbootstrap_message zssh "no need to publish our configs" + zshlibs_log zssh "no need to publish our configs" fi zssh_check_pubkeys fi - zbootstrap_message zssh "processing ssh client setup" + zshlibs_log zssh "processing ssh client setup" zssh_install_peers zssh_publish_pubkeys fi @@ -112,10 +112,10 @@ function zssh_check_pubkeys() function zssh_install_peers() { [[ -n $zssh_host ]] || return 63 - zbootstrap_message zssh "installing peers" + zshlibs_log zssh "installing peers" for ssh_node in $zssh_nodes do - zbootstrap_message zssh "installing peer $ssh_node …" + zshlibs_log zssh "installing peer $ssh_node …" zssh_generate_privkey4 $ssh_node zssh_generate_config4 $ssh_node done @@ -136,10 +136,10 @@ function zssh_mail_pubkey2() 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) - zbootstrap_message 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}) else - zbootstrap_message zssh "'$(zssh_node_info ${ssh_node} -K ${zssh_host})' already mailed" + zshlibs_log zssh "'$(zssh_node_info ${ssh_node} -K ${zssh_host})' already mailed" fi } @@ -148,10 +148,10 @@ function zssh_publish_configs() [[ "${#zssh_host_config_accesses}" -gt 0 ]] || return 62 for sshmatch in ${(k)zssh_host_config_accesses} do - zbootstrap_message zssh "generating our server access config '$(zssh_host_info -E ${sshmatch})'" # '${hostaccessconfig_file}'" + zshlibs_log zssh "generating our server access config '$(zssh_host_info -E ${sshmatch})'" # '${hostaccessconfig_file}'" zssh_generate_hostaccessconfig $sshmatch > "$(zssh_host_info -E ${sshmatch})" # "$hostaccessconfig_file" done - zbootstrap_message zssh "updating mtime for $(zssh_host_info -C)" + zshlibs_log zssh "updating mtime for $(zssh_host_info -C)" touch "$(zssh_host_info -C)" } @@ -177,36 +177,36 @@ function zssh_generate_config4 ssh_node="$1" dst="$zssh_private_configs/$ssh_node.sshconf" srcs="$zssh_global_configs/$ssh_node" - zbootstrap_message zssh "checking configs for $ssh_node …" + zshlibs_log zssh "checking configs for $ssh_node …" if [[ -d "$srcs" ]] && ! [[ $dst -nt $srcs ]] then sshkey="$zssh_private_keys/$ssh_node.key" - zbootstrap_message zssh "found fresh configs directory for $ssh_node" - zbootstrap_message zssh "config destination is '$dst'" - zbootstrap_message zssh "tied ssh key is '$sshkey'" + zshlibs_log zssh "found fresh configs directory for $ssh_node" + zshlibs_log zssh "config destination is '$dst'" + zshlibs_log zssh "tied ssh key is '$sshkey'" rm "$dst" 2> /dev/null for src in "$srcs"/*.sshconf(N) do - zbootstrap_message zssh "sourcing $src" + zshlibs_log zssh "sourcing $src" cat "$src" >> "$dst" printf "\n IdentityFile %s\n\n" "$sshkey" >> "$dst" done fi - zbootstrap_message zssh "done with $ssh_node" + zshlibs_log zssh "done with $ssh_node" } function zssh_generate_privkey4 { ssh_node="$1" - zbootstrap_message zssh "checking keys for peer $ssh_node …" + zshlibs_log zssh "checking keys for peer $ssh_node …" local newkey=$zssh_private_keys/$ssh_node.key if ! [[ -s $newkey ]] then - zbootstrap_message zssh "generate key for $ssh_node" + zshlibs_log zssh "generate key for $ssh_node" ssh-keygen -t ed25519 -N '' -C "$ssh_host($USER@$HOST) for $ssh_node" -f $newkey >> "${HOME}/.log/ssh-keygen.log" if [[ "$ssh_node" == "$zssh_host" ]] then - zbootstrap_message zssh "Self accepting key: $ssh_node" + zshlibs_log zssh "Self accepting key: $ssh_node" cat "$newkey.pub" >> ${HOME}/.ssh/authorized_keys fi fi @@ -216,7 +216,7 @@ function zssh_generate_privkey4 function zssh_enumeratenodes() { typeset -g -a zssh_nodes; - zbootstrap_message zssh "enumerating nodes" + zshlibs_log zssh "enumerating nodes" if [[ -d $zssh_global_configs ]] then for __ssh_node in ${zssh_global_configs}/*(/) @@ -224,5 +224,5 @@ function zssh_enumeratenodes() zssh_nodes+=($(basename $__ssh_node)) done fi - zbootstrap_message zssh "got ${#zssh_nodes} nodes" + zshlibs_log zssh "got ${#zssh_nodes} nodes" }