Compare commits

..

7 commits

Author SHA1 Message Date
6a202f7f75
readme/codecs
Some checks failed
/ arch (push) Failing after 5s
/ alpine (push) Failing after 5s
/ fedora (push) Failing after 5s
/ debian (push) Failing after 5s
/ opensuse (push) Failing after 5s
/ ubuntu (push) Failing after 4s
/ alma (push) Failing after 5s
/ rocky (push) Failing after 5s
2024-09-01 21:02:20 +02:00
33f0bab4ef
readme 2024-09-01 21:00:28 +02:00
c2b3a78617
spcd_ca 2024-09-01 21:00:03 +02:00
e41d0e976f
dns/printenv 2024-09-01 19:39:12 +02:00
ccc7619a6b
tasks/dns 2024-09-01 19:32:05 +02:00
f33bc6bbab
dns/list 2024-09-01 19:31:30 +02:00
31e2875965
dns/write 2024-09-01 19:27:43 +02:00
2 changed files with 68 additions and 39 deletions

View file

@ -236,14 +236,14 @@ Handle project workflows in a unified way:
* pacman * pacman
* zypper * zypper
* repositories * repositories
* codecs
* epel
* fedora
* opensuse
* opensuse * opensuse
* codecs repository
* disable & enable https * disable & enable https
* persist locales * persist locales
* test * test
* variables
* CA_n
* DNS_n
#### Shell → Python #### Shell → Python

View file

@ -199,6 +199,65 @@ _spcd_txt_pick() {
# │ functions │ # │ functions │
# ╰───────────╯ # ╰───────────╯
spcd_ca() {
local index name value
local grep="\(After\|Before\|Issuer\|Signature Algorithm\|Subject:\)"
case "${1}" in
"list")
while true; do
index=$((index + 1))
name="SPCD_CA_${index}"
eval "value=\"\${name}\""
[ -n "${value}" ] || break
echo "${name} ="
echo "${value}" |
openssl x509 -noout -text |
grep "${grep}"
done
;;
"write")
local root="${2}"
while true; do
index=$((index + 1))
name="SPCD_CA_${index}"
eval "value=\"\${name}\""
[ -n "${value}" ] || break
spcd_os_write "${root}/${index}.crt" "${value}"
done
;;
*) ;;
esac
}
spcd_dns() {
local index name value
case "${1}" in
"list")
while true; do
index=$((index + 1))
name="SPCD_DNS_${index}"
eval "value=\"\${name}\""
[ -n "${value}" ] || break
spcd_os_printenv "${name}"
done
;;
"write")
local text
while true; do
index=$((index + 1))
name="SPCD_DNS_${index}"
eval "value=\"\${name}\""
[ -n "${value}" ] || break
text="${text}\
nameserver ${value}
"
done
spcd_os_write "/etc/resolv.conf" "${text}"
;;
*) ;;
esac
}
# ╭───────────┬───────╮ # ╭───────────┬───────╮
# │ functions │ error │ # │ functions │ error │
# ╰───────────┴───────╯ # ╰───────────┴───────╯
@ -214,19 +273,6 @@ spcd_error_os() {
exit "${_SPCD_ERROR_OS}" exit "${_SPCD_ERROR_OS}"
} }
# ╭───────────┬─────────╮
# │ functions │ openssl │
# ╰───────────┴─────────╯
spcd_openssl_x509() {
if [ -f "${1}" ]; then
openssl x509 \
-in "${1}" \
-noout -text |
grep "\(After\|Before\|Issuer\|Signature A\|Subject:\)"
fi
}
# ╭───────────┬────╮ # ╭───────────┬────╮
# │ functions │ os │ # │ functions │ os │
# ╰───────────┴────╯ # ╰───────────┴────╯
@ -434,9 +480,9 @@ SPCD_PM_ZYPPER="zypper"
# ╰──────┴─────────────╯ # ╰──────┴─────────────╯
spcd_step__environment_defaults_print() { spcd_step__environment_defaults_print() {
spcd_ca "list"
spcd_dns "list"
set -- \ set -- \
\
\
"GIT_RWX" \ "GIT_RWX" \
"GIT_SPCD" \ "GIT_SPCD" \
"GIT_SHUNIT" \ "GIT_SHUNIT" \
@ -896,16 +942,7 @@ spcd_query_package() {
spcd_step__dns() { spcd_step__dns() {
spcd_step "DNS" spcd_step "DNS"
local index value text spcd_dns "write"
while true; do
index=$((index + 1))
eval "value=\"\${SPCD_DNS_${index}}\""
[ -n "${value}" ] || break
text="${text}\
nameserver ${value}
"
done
spcd_os_write "/etc/resolv.conf" "${text}"
} }
# ╭──────┬──────────╮ # ╭──────┬──────────╮
@ -1152,7 +1189,7 @@ spcd_step__ca_install_package() {
spcd_step__ca_write_certificates() { spcd_step__ca_write_certificates() {
spcd_step "Write certificates" spcd_step "Write certificates"
local root index text path local root
case "${SPCD_OS_ID}" in case "${SPCD_OS_ID}" in
"${SPCD_OS_ALMA}" | "${SPCD_OS_FEDORA}" | "${SPCD_OS_ROCKY}") "${SPCD_OS_ALMA}" | "${SPCD_OS_FEDORA}" | "${SPCD_OS_ROCKY}")
root="/etc/pki/ca-trust/source/anchors" root="/etc/pki/ca-trust/source/anchors"
@ -1169,15 +1206,7 @@ spcd_step__ca_write_certificates() {
*) ;; *) ;;
esac esac
spcd_os_mkdir "${root}" spcd_os_mkdir "${root}"
while true; do spcd_ca "write" "${root}"
index=$((index + 1))
eval "text=\"\${SPCD_CA_${index}}\""
[ -n "${text}" ] || break
path="${root}/${index}.crt"
spcd_split
spcd_os_write "${path}" "${text}"
spcd_openssl_x509 "${path}"
done
} }
spcd_step__ca_update_certificates() { spcd_step__ca_update_certificates() {