2022-01-11 16:43:02 +00:00
|
|
|
|
|
|
|
function zshlibs_update()
|
|
|
|
{
|
|
|
|
zshlibs_log zlibs_update "preparing self update …"
|
|
|
|
if [[ -n "$zshlibs_install" ]]
|
|
|
|
then
|
|
|
|
zshlibs_log zlibs_update "cd into '$zshlibs_install' …"
|
|
|
|
pushd $zshlibs_install 2>&1 > /dev/null
|
|
|
|
zshlibs_log zlibs_update "git pull …"
|
|
|
|
(
|
2022-01-11 17:37:27 +00:00
|
|
|
git pull 2>&1 |zshlibs_log zlibs_update &
|
2022-01-11 16:43:02 +00:00
|
|
|
)
|
|
|
|
zshlibs_log zlibs_update "update done"
|
|
|
|
popd 2>&1 > /dev/null
|
|
|
|
else
|
|
|
|
echo "\$zshlibs_install not set!"
|
|
|
|
return 1
|
|
|
|
zlibs_install
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function zshlibs_boot()
|
|
|
|
{
|
2022-01-11 17:37:27 +00:00
|
|
|
typeset -g zshlibs_bootlevel
|
|
|
|
if [[ $zshlibs_bootlevel -gt 1 ]]
|
|
|
|
then
|
|
|
|
echo "You are likely doing double bootstrap"
|
|
|
|
fi
|
|
|
|
zshlibs_bootlevel=0
|
2022-01-11 16:43:02 +00:00
|
|
|
zshlibs_log zbootstrap "ensure directory '${HOME}/.log/'"
|
|
|
|
zshlibs_ensure -d "${HOME}/.log/"
|
2022-01-11 17:37:27 +00:00
|
|
|
zshlibs_bootlevel=2
|
2022-01-11 16:43:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function zshlibs_ensure()
|
|
|
|
{
|
2022-01-11 21:06:48 +00:00
|
|
|
target="${2}"
|
|
|
|
typ="${1}"
|
|
|
|
if ! test -e "${target}"
|
2022-01-11 16:43:02 +00:00
|
|
|
then
|
|
|
|
zshlibs_log zshlibs_ensure "creating '${target}' ($typ) …"
|
|
|
|
case $typ in
|
|
|
|
-d)
|
2022-01-11 21:06:48 +00:00
|
|
|
mkdir -p "${target}" \
|
2022-01-11 16:43:02 +00:00
|
|
|
|| zshlibs_log $0 "unable to create directory '${target}'" \
|
|
|
|
&& return 2
|
|
|
|
;;
|
|
|
|
-f)
|
2022-01-11 21:06:48 +00:00
|
|
|
touch "${target}" \
|
2022-01-11 16:43:02 +00:00
|
|
|
|| zshlibs_log $0 "unable to create file '${target}'" \
|
|
|
|
&& return 2
|
|
|
|
esac
|
|
|
|
zshlibs_log zshlibs_ensure "target '${target}' created"
|
2022-01-11 21:06:48 +00:00
|
|
|
elif test "${typ}" "${target}"
|
2022-01-11 16:43:02 +00:00
|
|
|
then
|
|
|
|
zshlibs_log zshlibs_ensure "target '${target}' ($typ) present"
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
function zshlibs_path_add()
|
|
|
|
{
|
|
|
|
local pathtoadd="${1}"
|
|
|
|
zshlibs_log $0 "adding path '$pathtoadd' to \$PATH"
|
|
|
|
if [[ ! ${path[(r)${pathtoadd}]} ]]
|
|
|
|
then
|
|
|
|
path+=(${pathtoadd})
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function zshlibs_fpath_add()
|
|
|
|
{
|
|
|
|
local fpathtoadd="${1}"
|
|
|
|
zshlibs_log $0 "adding fpath '$fpathtoadd' to \$fpath"
|
|
|
|
if [[ ! ${fpath[(r)${fpathtoadd}]} ]]
|
|
|
|
then
|
|
|
|
path+=(${fpathtoadd})
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function zshlibs_start()
|
|
|
|
{
|
|
|
|
zshlibs_boot
|
2022-01-11 17:06:09 +00:00
|
|
|
zshlibs_update
|
2022-01-11 16:43:02 +00:00
|
|
|
zconfig_boot
|
2022-01-11 17:41:35 +00:00
|
|
|
global_boot
|
2022-01-11 16:43:02 +00:00
|
|
|
zssh_boot
|
2022-01-11 17:06:09 +00:00
|
|
|
zshlibs_log zbootstrap "zshlibs booted up
|
|
|
|
==========================================="
|
2022-01-11 16:43:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function zbootstrap()
|
|
|
|
{
|
|
|
|
zshlibs_start
|
|
|
|
}
|