|
|
|
@ -5,12 +5,11 @@
|
|
|
|
|
# ╰───╯
|
|
|
|
|
|
|
|
|
|
_spcd_fill() {
|
|
|
|
|
_spcd_fill__index=${1}
|
|
|
|
|
while [ "${_spcd_fill__index}" -gt 0 ]; do
|
|
|
|
|
local index="${1}"
|
|
|
|
|
while [ "${index}" -gt 0 ]; do
|
|
|
|
|
printf "%s" "${2}"
|
|
|
|
|
_spcd_fill__index=$((_spcd_fill__index - 1))
|
|
|
|
|
index=$((index - 1))
|
|
|
|
|
done
|
|
|
|
|
unset _spcd_fill__index
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# ╭───┬────────╮
|
|
|
|
@ -28,35 +27,33 @@ _SPCD_BANNER_VERTICAL="│"
|
|
|
|
|
|
|
|
|
|
_spcd_banner_add() {
|
|
|
|
|
if [ -n "${1}" ]; then
|
|
|
|
|
spcd_ba__text=" ${1} "
|
|
|
|
|
spcd_ba__length=${#spcd_ba__text}
|
|
|
|
|
spcd_ba__filler="$(
|
|
|
|
|
_spcd_fill "${spcd_ba__length}" "${_SPCD_BANNER_HORIZONTAL}"
|
|
|
|
|
)"
|
|
|
|
|
local text=" ${1} "
|
|
|
|
|
local length=${#text}
|
|
|
|
|
local filler="$(_spcd_fill "${length}" "${_SPCD_BANNER_HORIZONTAL}")"
|
|
|
|
|
if [ -n "${__SPCD_BANNER_MIDDLE}" ]; then
|
|
|
|
|
_spcd_banner_split
|
|
|
|
|
else
|
|
|
|
|
_spcd_banner_open
|
|
|
|
|
fi
|
|
|
|
|
_spcd_banner_append \
|
|
|
|
|
"${spcd_ba__filler}" "${spcd_ba__text}" "${spcd_ba__filler}"
|
|
|
|
|
_spcd_banner_append "${filler}" "${text}" "${filler}"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_spcd_banner_add_index() {
|
|
|
|
|
unset spcd_bai__label
|
|
|
|
|
unset spcd_bai__level
|
|
|
|
|
local label
|
|
|
|
|
local level
|
|
|
|
|
local value
|
|
|
|
|
while true; do
|
|
|
|
|
spcd_bai__level=$((spcd_bai__level + 1))
|
|
|
|
|
eval "spcd_bai__value=\"\${__SPCD_STEP_${spcd_bai__level}_INDEX}\""
|
|
|
|
|
[ -n "${spcd_bai__value}" ] || break
|
|
|
|
|
if [ -n "${spcd_bai__label}" ]; then
|
|
|
|
|
spcd_bai__label="${spcd_bai__label}.${spcd_bai__value}"
|
|
|
|
|
level=$((level + 1))
|
|
|
|
|
eval "value=\"\${__SPCD_STEP_${level}_INDEX}\""
|
|
|
|
|
[ -n "${value}" ] || break
|
|
|
|
|
if [ -n "${label}" ]; then
|
|
|
|
|
label="${label}.${value}"
|
|
|
|
|
else
|
|
|
|
|
spcd_bai__label="${spcd_bai__value}"
|
|
|
|
|
label="${value}"
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
_spcd_banner_add "${spcd_bai__label}"
|
|
|
|
|
_spcd_banner_add "${label}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_spcd_banner_append() {
|
|
|
|
@ -86,12 +83,13 @@ _spcd_banner_render() {
|
|
|
|
|
_spcd_banner_add "S"
|
|
|
|
|
_spcd_banner_add_index
|
|
|
|
|
#
|
|
|
|
|
unset spcd_br__level
|
|
|
|
|
local level
|
|
|
|
|
local value
|
|
|
|
|
while true; do
|
|
|
|
|
spcd_br__level=$((spcd_br__level + 1))
|
|
|
|
|
eval "spcd_br__value=\"\${__SPCD_STEP_${spcd_br__level}_LABEL}\""
|
|
|
|
|
[ -n "${spcd_br__value}" ] || break
|
|
|
|
|
_spcd_banner_add "${spcd_br__value}"
|
|
|
|
|
level=$((level + 1))
|
|
|
|
|
eval "value=\"\${__SPCD_STEP_${level}_LABEL}\""
|
|
|
|
|
[ -n "${value}" ] || break
|
|
|
|
|
_spcd_banner_add "${value}"
|
|
|
|
|
done
|
|
|
|
|
#
|
|
|
|
|
_spcd_banner_shut
|
|
|
|
@ -223,10 +221,10 @@ spcd_openssl_x509() {
|
|
|
|
|
# ╰───────────┴────╯
|
|
|
|
|
|
|
|
|
|
spcd_os_grep() {
|
|
|
|
|
spcd_os_grep__variable="${1}"
|
|
|
|
|
[ -n "${spcd_os_grep__variable}" ] &&
|
|
|
|
|
grep "^${spcd_os_grep__variable}=" "/etc/os-release" |
|
|
|
|
|
sed "s|^${spcd_os_grep__variable}=||" |
|
|
|
|
|
local variable="${1}"
|
|
|
|
|
[ -n "${variable}" ] &&
|
|
|
|
|
grep "^${variable}=" "/etc/os-release" |
|
|
|
|
|
sed "s|^${variable}=||" |
|
|
|
|
|
sed "s|^\"\(.*\)\"$|\1|"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -245,10 +243,11 @@ spcd_os_mkdir() {
|
|
|
|
|
|
|
|
|
|
spcd_os_printenv() {
|
|
|
|
|
if [ -n "${1}" ]; then
|
|
|
|
|
for spcd_os_printenv__name in "${@}"; do
|
|
|
|
|
spcd_os_printenv__text=""
|
|
|
|
|
eval "spcd_os_printenv__text=\"\${${spcd_os_printenv__name}}\""
|
|
|
|
|
echo "${spcd_os_printenv__name} = \"${spcd_os_printenv__text}\""
|
|
|
|
|
local name
|
|
|
|
|
local text
|
|
|
|
|
for name in "${@}"; do
|
|
|
|
|
eval "text=\"\${${name}}\""
|
|
|
|
|
echo "${name} = \"${text}\""
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
@ -261,26 +260,27 @@ spcd_os_rm() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spcd_os_sed() {
|
|
|
|
|
spcd_os_sed__file="${1}"
|
|
|
|
|
local file="${1}"
|
|
|
|
|
shift
|
|
|
|
|
if [ -f "${spcd_os_sed__file}" ]; then
|
|
|
|
|
_spcd_os_cat "${spcd_os_sed__file}"
|
|
|
|
|
for spcd_os_sed__regex in "${@}"; do
|
|
|
|
|
sed --in-place "s${spcd_os_sed__regex}g" "${spcd_os_sed__file}" &&
|
|
|
|
|
_spcd_os_cat "${spcd_os_sed__file}"
|
|
|
|
|
if [ -f "${file}" ]; then
|
|
|
|
|
local regex
|
|
|
|
|
_spcd_os_cat "${file}"
|
|
|
|
|
for regex in "${@}"; do
|
|
|
|
|
sed --in-place "s${regex}g" "${file}" &&
|
|
|
|
|
_spcd_os_cat "${file}"
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spcd_os_write() {
|
|
|
|
|
spcd_os_write__file="${1}"
|
|
|
|
|
spcd_os_write__text="${2}"
|
|
|
|
|
if [ -n "${spcd_os_write__file}" ]; then
|
|
|
|
|
[ -f "${spcd_os_write__file}" ] &&
|
|
|
|
|
_spcd_os_cat "${spcd_os_write__file}"
|
|
|
|
|
echo "→ ${spcd_os_write__file}"
|
|
|
|
|
printf "%s" "${spcd_os_write__text}" >"${spcd_os_write__file}"
|
|
|
|
|
_spcd_os_cat "${spcd_os_write__file}"
|
|
|
|
|
local file="${1}"
|
|
|
|
|
local text="${2}"
|
|
|
|
|
if [ -n "${file}" ]; then
|
|
|
|
|
[ -f "${file}" ] &&
|
|
|
|
|
_spcd_os_cat "${file}"
|
|
|
|
|
echo "→ ${file}"
|
|
|
|
|
printf "%s" "${text}" >"${file}"
|
|
|
|
|
_spcd_os_cat "${file}"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|