split zconfig, adjust zssh

This commit is contained in:
Aleksey 2024-01-18 19:29:40 +04:00
parent d5faffd04c
commit c72676ccac
Signed by: tea
GPG Key ID: D9C68D34A3CAE37A
14 changed files with 78 additions and 92 deletions

View File

@ -1,6 +1,6 @@
function zbootstrap()
{
autoload zshlibs_boot zshlibs_log zshlibs_ensure zshlibs_fpath_add \
zshlibs_path_add zshlibs_start zshlibs_update
function zbootstrap()
{
zshlibs_start
}

View File

@ -15,8 +15,7 @@ else
zshlibs_update
fi
source ${zshlibs_install}/tools.zsh
source ${zshlibs_install}/zconfig.funcs.zsh
source ${zshlibs_install}/global.funcs.zsh
source ${zshlibs_install}/zconfig.zsh
source ${zshlibs_install}/global.zsh
source ${zshlibs_install}/zssh.zsh

View File

@ -1,82 +0,0 @@
function zconfig_checkload()
{
typeset -a -g zconfig_loaded
if [[ ! ${zconfig_loaded[(r)${1}]} ]]
then
zshlibs_log zconfig "sourcing config '$1'"
. -- $1 2>&1 >(zshlibs_log zconfig)
zconfig_loaded+=("$1")
zshlibs_log zconfig "end sourcing config '$1'"
else
zshlibs_log zconfig "config '$1' already loaded"
zshlibs_log zconfig "currently loaded configs: ${zconfig_loaded}"
fi
}
function zconfigs_load()
{
zshlibs_log zconfig "loading supplied config names"
for configfile in ${*}; do
zconfig_checkload $configfile
done
}
function zconfigs_local_load()
{
if [[ ! -a ${zconfig_local_path} ]]; then
zshlibs_log zconfig "local config missing, recreating from '${zconfig_shared_path}/zshconfig.example'"
mkdir -p -m 700 "${zconfig_local_path}"
cp ${zconfig_shared_path}/zshconfig.example ${zconfig_local_path}/local.config.zsh
fi
if [[ ! -d ${zconfig_local_path} ]]; then
zshlibs_log zconfig "local config appears to be a file, loading '${zconfig_local_path}'"
zconfig_checkload ${zconfig_local_path}
else
zshlibs_log zconfig "local config is a directory, loading '${zconfig_local_path}/*.config.zsh'"
zconfigs_load ${zconfig_local_path}/*.config.zsh;
fi
}
# zconfig bootup
function zconfig_boot()
{
zconfig_configure
zconfig_setup
zconfig_setup_interactive
}
function zconfig_configure()
{
typeset -a -g zconfig_loaded
typeset -a -g config_extra # user populatable config names in zshlibs location
typeset -g zconfig_shared_path="${zshlibs_install}/config"
typeset -g zconfig_local_path="${HOME}/.config/zsh"
}
function zbootstrap_noninteractive()
{
zshlibs_log zconfig "WARNING: legacy function called"
zconfig_configure
zconfig_setup
}
function zconfig_setup()
{
zshlibs_log zconfig 'load global config'
zconfig_checkload ${zconfig_shared_path}/global.config.zsh
zshlibs_log zconfig 'load local configs'
zconfigs_local_load
for zconfig in $config_extra; do
zshlibs_log zconfig 'load config extra $zconfig'
zconfig_checkload ${zconfig_shared_path}/${zconfig}.config.zsh
done
}
function zconfig_setup_interactive()
{
zshlibs_log zconfig "loading interactive config"
zconfig_checkload ${zconfig_shared_path}/global.style.zsh
zshlibs_log zconfig "done loading interactive config"
}

4
zconfig.zsh Normal file
View File

@ -0,0 +1,4 @@
fpath+=(${zshlibs_install}/zconfig)
autoload zconfig_boot zconfig_checkload zconfig_configure \
zconfig_setup zconfig_setup_interactive zconfigs_load \
zconfigs_local_load

6
zconfig/zconfig_boot Normal file
View File

@ -0,0 +1,6 @@
function zconfig_boot()
{
zconfig_configure
zconfig_setup
zconfig_setup_interactive
}

14
zconfig/zconfig_checkload Normal file
View File

@ -0,0 +1,14 @@
function zconfig_checkload()
{
typeset -a -g zconfig_loaded
if [[ ! ${zconfig_loaded[(r)${1}]} ]]
then
zshlibs_log zconfig "sourcing config '$1'"
. -- $1 2>&1 >(zshlibs_log zconfig)
zconfig_loaded+=("$1")
zshlibs_log zconfig "end sourcing config '$1'"
else
zshlibs_log zconfig "config '$1' already loaded"
zshlibs_log zconfig "currently loaded configs: ${zconfig_loaded}"
fi
}

View File

@ -0,0 +1,7 @@
function zconfig_configure()
{
typeset -a -g zconfig_loaded
typeset -a -g config_extra # user populatable config names in zshlibs location
typeset -g zconfig_shared_path="${zshlibs_install}/config"
typeset -g zconfig_local_path="${HOME}/.config/zsh"
}

11
zconfig/zconfig_setup Normal file
View File

@ -0,0 +1,11 @@
function zconfig_setup()
{
zshlibs_log zconfig 'load global config'
zconfig_checkload ${zconfig_shared_path}/global.config.zsh
zshlibs_log zconfig 'load local configs'
zconfigs_local_load
for zconfig in $config_extra; do
zshlibs_log zconfig 'load config extra $zconfig'
zconfig_checkload ${zconfig_shared_path}/${zconfig}.config.zsh
done
}

View File

@ -0,0 +1,6 @@
function zconfig_setup_interactive()
{
zshlibs_log zconfig "loading interactive config"
zconfig_checkload ${zconfig_shared_path}/global.style.zsh
zshlibs_log zconfig "done loading interactive config"
}

7
zconfig/zconfigs_load Normal file
View File

@ -0,0 +1,7 @@
function zconfigs_load()
{
zshlibs_log zconfig "loading supplied config names"
for configfile in ${*}; do
zconfig_checkload $configfile
done
}

View File

@ -0,0 +1,15 @@
function zconfigs_local_load()
{
if [[ ! -a ${zconfig_local_path} ]]; then
zshlibs_log zconfig "local config missing, recreating from '${zconfig_shared_path}/zshconfig.example'"
mkdir -p -m 700 "${zconfig_local_path}"
cp ${zconfig_shared_path}/zshconfig.example ${zconfig_local_path}/local.config.zsh
fi
if [[ ! -d ${zconfig_local_path} ]]; then
zshlibs_log zconfig "local config appears to be a file, loading '${zconfig_local_path}'"
zconfig_checkload ${zconfig_local_path}
else
zshlibs_log zconfig "local config is a directory, loading '${zconfig_local_path}/*.config.zsh'"
zconfigs_load ${zconfig_local_path}/*.config.zsh;
fi
}

View File

@ -1,3 +1,6 @@
fpath+=(${zshlibs_install}/zssh/)
autoload zssh_boot
autoload zssh_configure zssh_process zssh_check_pubkeys zssh_enumeratenodes \
zssh_generate_config4 zssh_generate_hostaccessconfig zssh_generate_privkey4 \
zssh_host_info zssh_install_peers zssh_mail_pubkey2 zssh_node_info \
zssh_publish_configs zssh_publish_pubkeys zssh_boot

View File

@ -7,10 +7,6 @@ function zssh_boot()
typeset -g zssh_private_configs="${zssh_ssh_dotdir}/config.d"
typeset -g zssh_global_configs=${globaldots_path}/config/ssh
typeset -g zssh_global_pubkeys=${globaldots_path}/keys/ssh
autoload zssh_configure zssh_process zssh_check_pubkeys zssh_enumeratenodes \
zssh_generate_config4 zssh_generate_hostaccessconfig zssh_generate_privkey4 \
zssh_host_info zssh_install_peers zssh_mail_pubkey2 zssh_node_info \
zssh_publish_configs zssh_publish_pubkeys
zssh_configure
zssh_process
}