wip
This commit is contained in:
parent
b2541755b6
commit
df30c85bc8
132
global.funcs.zsh
132
global.funcs.zsh
@ -1,7 +1,75 @@
|
|||||||
|
typeset -g globaldots_path="${HOME}/.global"
|
||||||
|
if [[ -a $(realpath -m $(dirname $0)/../../.globaldir ) ]]
|
||||||
|
then
|
||||||
|
typeset -g globaldots_path=$(realpath -m $(dirname $0)/../../)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n ${GLOBALDOTS_PATH} ]]
|
||||||
|
then
|
||||||
|
typeset -g globaldots_path=${GLOBALDOTS_PATH}
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -z $globaldots_path ]]; then
|
if [[ -z $globaldots_path ]]; then
|
||||||
echo 'functions require $globaldots_path to be set!'
|
echo 'functions require $globaldots_path to be set!'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#### BASIC ZSHLIBS TOOLS
|
||||||
|
|
||||||
|
function zlibs_update()
|
||||||
|
{
|
||||||
|
zbootstrap_message zlibs_update "preparing self update …"
|
||||||
|
if [[ -n "$zshlibs_install" ]]
|
||||||
|
then
|
||||||
|
zbootstrap_message zlibs_update "cd into '$zshlibs_install' …"
|
||||||
|
pushd $zshlibs_install
|
||||||
|
zbootstrap_message zlibs_update "git pull …"
|
||||||
|
git pull
|
||||||
|
zbootstrap_message zlibs_update "update done"
|
||||||
|
popd
|
||||||
|
else
|
||||||
|
echo "\$zshlibs_install not set!"
|
||||||
|
return 1
|
||||||
|
zlibs_install
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function ztools_ensure()
|
||||||
|
{
|
||||||
|
target=${2}
|
||||||
|
typ=${1}
|
||||||
|
if ! test -e ${target}
|
||||||
|
then
|
||||||
|
zbootstrap_message ztools_ensure "creating '${target}' ($typ) …"
|
||||||
|
case $typ in
|
||||||
|
-d)
|
||||||
|
mkdir -p ${target} \
|
||||||
|
|| zbootstrap_message ztools_ensure "unable to create directory '${target}'" \
|
||||||
|
&& return 2
|
||||||
|
;;
|
||||||
|
-f)
|
||||||
|
touch ${target} \
|
||||||
|
|| zbootstrap_message ztools_ensure "unable to create file '${target}'" \
|
||||||
|
&& return 2
|
||||||
|
esac
|
||||||
|
zbootstrap_message ztools_ensure "target '${target}' created"
|
||||||
|
elif test ${typ} ${target}
|
||||||
|
then
|
||||||
|
zbootstrap_message ztools_ensure "target '${target}' ($typ) present"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
zbootstrap_message ztools_ensure "target '${target}' already exists and it is not a directory"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
##### CONFIGURATION LIBRARIES
|
||||||
|
|
||||||
|
|
||||||
|
function zlibs_path_expand()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function global_path_expand()
|
function global_path_expand()
|
||||||
{
|
{
|
||||||
local bin_base=${globaldots_path}/bin
|
local bin_base=${globaldots_path}/bin
|
||||||
@ -22,26 +90,16 @@ function global_fpath_expand()
|
|||||||
done;
|
done;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ztools_update()
|
|
||||||
{
|
|
||||||
#
|
|
||||||
if [[ -z "$ztools_install_directory" ]]
|
|
||||||
then
|
|
||||||
echo '$ztools_install_directory not set!'
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function zconfig_checkload()
|
function zconfig_checkload()
|
||||||
{
|
{
|
||||||
typeset -a -g globaldots_configs_loaded
|
typeset -a -g zconfig_loaded
|
||||||
if [[ ! ${globaldots_configs_loaded[(r)${1}]} ]]
|
if [[ ! ${zconfig_loaded[(r)${1}]} ]]
|
||||||
then
|
then
|
||||||
zbootstrap_message zbootstrap "sourcing config '$1'"
|
zbootstrap_message zbootstrap "sourcing config '$1'"
|
||||||
source -- $1 2>&1 >> "${HOME}/.log/z_zbootstrap.log"
|
source -- $1 2>&1 >> "${HOME}/.log/z_zbootstrap.log"
|
||||||
globaldots_configs_loaded+=("$1")
|
zconfig_loaded+=("$1")
|
||||||
zbootstrap_message zbootstrap "end sourcing config '$1'"
|
zbootstrap_message zbootstrap "end sourcing config '$1'"
|
||||||
else
|
else
|
||||||
zbootstrap_message zbootstrap "config '$1' already loaded"
|
zbootstrap_message zbootstrap "config '$1' already loaded"
|
||||||
@ -78,52 +136,21 @@ function zbootstrap_message()
|
|||||||
echo "$(date -Ins) ${@}" >> "${HOME}/.log/z_$facility.log"
|
echo "$(date -Ins) ${@}" >> "${HOME}/.log/z_$facility.log"
|
||||||
}
|
}
|
||||||
|
|
||||||
function ztools_ensure()
|
function zshlibs_boot()
|
||||||
{
|
|
||||||
target=${2}
|
|
||||||
typ=${1}
|
|
||||||
if ! test -e ${target}
|
|
||||||
then
|
|
||||||
zbootstrap_message ztools_ensure "creating '${target}' ($typ) …"
|
|
||||||
case $typ in
|
|
||||||
-d)
|
|
||||||
mkdir -p ${target} \
|
|
||||||
|| zbootstrap_message ztools_ensure "unable to create directory '${target}'" \
|
|
||||||
&& return 2
|
|
||||||
;;
|
|
||||||
-f)
|
|
||||||
touch ${target} \
|
|
||||||
|| zbootstrap_message ztools_ensure "unable to create file '${target}'" \
|
|
||||||
&& return 2
|
|
||||||
esac
|
|
||||||
zbootstrap_message ztools_ensure "target '${target}' created"
|
|
||||||
elif test ${typ} ${target}
|
|
||||||
then
|
|
||||||
zbootstrap_message ztools_ensure "target '${target}' ($typ) present"
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
zbootstrap_message ztools_ensure "target '${target}' already exists and it is not a directory"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function zbootstrap_noninteractive()
|
|
||||||
{
|
{
|
||||||
# ensure log directory
|
# ensure log directory
|
||||||
zbootstrap_message zbootstrap "ensure directory '${HOME}/.log/'"
|
zbootstrap_message zbootstrap "ensure directory '${HOME}/.log/'"
|
||||||
ztools_ensure -d "${HOME}/.log/"
|
ztools_ensure -d "${HOME}/.log/"
|
||||||
# if ! [[ -d "${HOME}/.log/" ]]
|
|
||||||
# then
|
|
||||||
# mkdir "${HOME}/.log/"
|
|
||||||
# else if [[ -e "${HOME}/.log/" ]]
|
|
||||||
# then
|
|
||||||
# zbootstrap_message zbootstrap "zbootstrap logdir '${HOME}/.log/' exist and is not a directory"
|
|
||||||
# fi
|
|
||||||
# fi
|
|
||||||
# loading configs
|
# loading configs
|
||||||
typeset -a -g globaldots_configs_loaded
|
typeset -a -g zconfig_loaded
|
||||||
typeset -a -g path_extra
|
typeset -a -g path_extra
|
||||||
typeset -a -g config_extra
|
typeset -a -g config_extra
|
||||||
|
typeset -g zconfig_shared_path="${zshlibs_install}/config"
|
||||||
|
typeset -g zconfig_local_path="${HOME}/.config/zsh"
|
||||||
|
}
|
||||||
|
|
||||||
|
function zbootstrap_noninteractive()
|
||||||
|
{
|
||||||
zbootstrap_message zbootstrap 'load global config'
|
zbootstrap_message zbootstrap 'load global config'
|
||||||
zconfig_checkload ${globaldots_path}/config/zsh/global.config.zsh
|
zconfig_checkload ${globaldots_path}/config/zsh/global.config.zsh
|
||||||
zbootstrap_message zbootstrap 'load local configs'
|
zbootstrap_message zbootstrap 'load local configs'
|
||||||
@ -142,6 +169,7 @@ function zbootstrap_noninteractive()
|
|||||||
|
|
||||||
function zbootstrap ()
|
function zbootstrap ()
|
||||||
{
|
{
|
||||||
|
zshlibs_boot
|
||||||
zbootstrap_noninteractive
|
zbootstrap_noninteractive
|
||||||
zconfig_checkload ${globaldots_path}/config/zsh/global.style.zsh
|
zconfig_checkload ${globaldots_path}/config/zsh/global.style.zsh
|
||||||
zbootstrap_message zbootstrap "done loading interactive config"
|
zbootstrap_message zbootstrap "done loading interactive config"
|
||||||
|
@ -1,20 +1,16 @@
|
|||||||
if [[ -z ${zshlibs_install} ]]
|
function zlibs_install()
|
||||||
then
|
{
|
||||||
typeset -g zshlibs_install="${HOME}/.local/zshlibs"
|
cat > .zshlibs_repo.key <<ZSHLIBSKEY
|
||||||
fi
|
-----BEGIN OPENSSH PRIVATE KEY-----
|
||||||
if ! [[ -d ${zshlibs_install} ]]
|
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
|
||||||
then
|
QyNTUxOQAAACDfCuaNlzXjZLgfatP3beiWip6YwcgqbiaOcdw6ii99lwAAAJACRt/xAkbf
|
||||||
cat > .zshlibs_repo.key <<ZSHLIBSKEY
|
8QAAAAtzc2gtZWQyNTUxOQAAACDfCuaNlzXjZLgfatP3beiWip6YwcgqbiaOcdw6ii99lw
|
||||||
-----BEGIN OPENSSH PRIVATE KEY-----
|
AAAEDS0oFdre+O4F8fRlMveXLBZGsIzYzjpL1mOZvzPcNZ9d8K5o2XNeNkuB9q0/dt6JaK
|
||||||
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
|
npjByCpuJo5x3DqKL32XAAAADGFjY2VsQHQtcmV4eAE=
|
||||||
QyNTUxOQAAACDfCuaNlzXjZLgfatP3beiWip6YwcgqbiaOcdw6ii99lwAAAJACRt/xAkbf
|
-----END OPENSSH PRIVATE KEY-----
|
||||||
8QAAAAtzc2gtZWQyNTUxOQAAACDfCuaNlzXjZLgfatP3beiWip6YwcgqbiaOcdw6ii99lw
|
|
||||||
AAAEDS0oFdre+O4F8fRlMveXLBZGsIzYzjpL1mOZvzPcNZ9d8K5o2XNeNkuB9q0/dt6JaK
|
|
||||||
npjByCpuJo5x3DqKL32XAAAADGFjY2VsQHQtcmV4eAE=
|
|
||||||
-----END OPENSSH PRIVATE KEY-----
|
|
||||||
ZSHLIBSKEY
|
ZSHLIBSKEY
|
||||||
cat > .zshlibs_repo.key.pub <<ZSHLIBSKEY
|
cat > .zshlibs_repo.key.pub <<ZSHLIBSKEY
|
||||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIN8K5o2XNeNkuB9q0/dt6JaKnpjByCpuJo5x3DqKL32X accel@t-rexx
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIN8K5o2XNeNkuB9q0/dt6JaKnpjByCpuJo5x3DqKL32X accel@t-rexx
|
||||||
ZSHLIBSKEY
|
ZSHLIBSKEY
|
||||||
chmod 600 .zshlibs_repo.key.pub .zshlibs_repo.key
|
chmod 600 .zshlibs_repo.key.pub .zshlibs_repo.key
|
||||||
GIT_SSH_COMMAND='ssh -i .zshlibs_repo.key' git clone --branch master git@casingator.brass.host:zshlibs.git "${zshlibs_install}"
|
GIT_SSH_COMMAND='ssh -i .zshlibs_repo.key' git clone --branch master git@casingator.brass.host:zshlibs.git "${zshlibs_install}"
|
||||||
@ -22,20 +18,16 @@ ZSHLIBSKEY
|
|||||||
git config core.sshCommand "ssh -i ${zshlibs_install}/zshlibs_ro.key"
|
git config core.sshCommand "ssh -i ${zshlibs_install}/zshlibs_ro.key"
|
||||||
chmod 600 "${zshlibs_install}/zshlibs_ro.key"
|
chmod 600 "${zshlibs_install}/zshlibs_ro.key"
|
||||||
rm .zshlibs_repo.key.pub .zshlibs_repo.key
|
rm .zshlibs_repo.key.pub .zshlibs_repo.key
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ -z ${zshlibs_install} ]]
|
||||||
|
then
|
||||||
|
typeset -g zshlibs_install="${HOME}/.local/zshlibs"
|
||||||
|
fi
|
||||||
|
if ! [[ -d ${zshlibs_install} ]]
|
||||||
|
then
|
||||||
|
zlibs_install
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
source ${zshlibs_install}/global.funcs.zsh
|
||||||
if [[ -n ${GLOBALDOTS_PATH} ]]
|
source ${zshlibs_install}/zssh.funcs.zsh
|
||||||
then
|
|
||||||
typeset -g globaldots_path=${GLOBALDOTS_PATH}
|
|
||||||
else
|
|
||||||
if [[ -a $(realpath -m $(dirname $0)/../../.globaldir ) ]]
|
|
||||||
then
|
|
||||||
typeset -g globaldots_path=$(realpath -m $(dirname $0)/../../)
|
|
||||||
else
|
|
||||||
typeset -g globaldots_path="${GLOBALDOTS_PATH:-${HOME}/.global}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
source ${globaldots_path}/lib/zsh/global.funcs.zsh
|
|
||||||
source ${globaldots_path}/lib/zsh/zssh.funcs.zsh
|
|
||||||
|
Loading…
Reference in New Issue
Block a user