V8.00.000.2025.06.17
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m54s
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m54s
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
@@ -16,9 +16,12 @@ guard_sourcing
|
||||
# Install a minimal Debian environment using the 'debootstrap' command.
|
||||
# Globals:
|
||||
# LOG_DBS
|
||||
# LOG_REC
|
||||
# RECOVERY
|
||||
# TARGET
|
||||
# VAR_ARCHITECTURE
|
||||
# VAR_CODENAME
|
||||
# VAR_RUN_RECOVERY
|
||||
# debootstrap_includes
|
||||
# debootstrap_mirror
|
||||
# Arguments:
|
||||
@@ -31,11 +34,17 @@ func_debootstrap() {
|
||||
### Declare Arrays, HashMaps, and Variables.
|
||||
declare -r var_arch="${VAR_ARCHITECTURE}"
|
||||
declare -r var_dist="${VAR_CODENAME}"
|
||||
declare -r var_target="${TARGET}"
|
||||
declare -r var_mirror="${debootstrap_mirror}"
|
||||
declare -r var_includes="${debootstrap_includes}"
|
||||
declare -a ary_cmd=()
|
||||
|
||||
declare var_log="${LOG_DBS}"
|
||||
declare var_target="${TARGET}"
|
||||
|
||||
### Check for TARGET / RECOVERY.
|
||||
[[ "${VAR_RUN_RECOVERY}" == "true" ]] && var_log="${LOG_REC}"
|
||||
[[ "${VAR_RUN_RECOVERY}" == "true" ]] && var_target="${RECOVERY}"
|
||||
|
||||
ary_cmd+=( "debootstrap" "--arch=${var_arch}" "--keep-debootstrap-dir" "--log-extra-deps" "--merged-usr" )
|
||||
|
||||
if [[ -n "${var_includes}" ]]; then ary_cmd+=( "--include=${var_includes}" ); fi
|
||||
@@ -45,7 +54,7 @@ func_debootstrap() {
|
||||
do_log "debug" "file_only" "4000() Executing: [${ary_cmd[*]}]"
|
||||
|
||||
# shellcheck disable=SC2312
|
||||
if "${ary_cmd[@]}" | tee "${LOG_DBS}"; then
|
||||
if "${ary_cmd[@]}" | tee "${var_log}"; then
|
||||
|
||||
do_log "info" "file_only" "4000() [${ary_cmd[*]}] successful."
|
||||
|
||||
|
||||
@@ -15,7 +15,9 @@ guard_sourcing
|
||||
#######################################
|
||||
# Preliminary post debootstrap checks.
|
||||
# Globals:
|
||||
# RECOVERY
|
||||
# TARGET
|
||||
# VAR_RUN_RECOVERY
|
||||
# Arguments:
|
||||
# None
|
||||
# Returns:
|
||||
@@ -24,10 +26,14 @@ guard_sourcing
|
||||
check_debootstrap() {
|
||||
### Declare Arrays, HashMaps, and Variables.
|
||||
declare -r var_logfile="/root/.ciss/cdi/log/4005_debootstrap_checks.log"
|
||||
declare var_target="${TARGET}"
|
||||
|
||||
chroot_logger "${TARGET}${var_logfile}"
|
||||
### Check for TARGET / RECOVERY.
|
||||
[[ "${VAR_RUN_RECOVERY}" == "true" ]] && var_target="${RECOVERY}"
|
||||
|
||||
chroot_script "${TARGET}" "
|
||||
chroot_logger "${var_target}${var_logfile}"
|
||||
|
||||
chroot_script "${var_target}" "
|
||||
{
|
||||
### Header
|
||||
echo '==[debootstrap checks]=='
|
||||
|
||||
@@ -15,10 +15,11 @@ guard_sourcing
|
||||
#######################################
|
||||
# Configure the target system for chroot.
|
||||
# Globals:
|
||||
# RECOVERY
|
||||
# TARGET
|
||||
# VAR_CHROOT_ACTIVATED
|
||||
# VAR_CHROOT_SYS_MASK_HELPER
|
||||
# VAR_NEED_RUN_IN_TARGET
|
||||
# VAR_RUN_RECOVERY
|
||||
# Arguments:
|
||||
# None
|
||||
# Returns:
|
||||
@@ -52,10 +53,14 @@ prepare_mounts() {
|
||||
)
|
||||
|
||||
declare var_path="" var_fs="" var_src="" var_opts=""
|
||||
declare var_target="${TARGET}"
|
||||
|
||||
### Check for TARGET / RECOVERY.
|
||||
[[ "${VAR_RUN_RECOVERY}" == "true" ]] && var_target="${RECOVERY}"
|
||||
|
||||
for var_path in "${!HMP_SPECIAL_MOUNTS[@]}"; do
|
||||
|
||||
mkdir -p "${TARGET}${var_path}"
|
||||
mkdir -p "${var_target}${var_path}"
|
||||
|
||||
done
|
||||
|
||||
@@ -64,55 +69,65 @@ prepare_mounts() {
|
||||
|
||||
IFS=" " read -r var_fs var_src var_opts <<< "${HMP_SPECIAL_MOUNTS[${var_path}]}"
|
||||
|
||||
if mountpoint -q "${TARGET}${var_path}"; then
|
||||
if mountpoint -q "${var_target}${var_path}"; then
|
||||
|
||||
do_log "info" "file_only" "4010() Skipped: '${TARGET}${var_path}' is already a mountpoint."
|
||||
do_log "info" "file_only" "4010() Skipped: '${var_target}${var_path}' is already a mountpoint."
|
||||
continue
|
||||
|
||||
fi
|
||||
|
||||
if ! mount -t "${var_fs}" "${var_src}" "${TARGET}${var_path}" -o "${var_opts}"; then
|
||||
if ! mount -t "${var_fs}" "${var_src}" "${var_target}${var_path}" -o "${var_opts}"; then
|
||||
|
||||
do_log "emergency" "file_only" "4010() Command: [mount -t ${var_fs} ${var_src} ${TARGET}${var_path} -o ${var_opts}] failed."
|
||||
do_log "emergency" "file_only" "4010() Command: [mount -t ${var_fs} ${var_src} ${var_target}${var_path} -o ${var_opts}] failed."
|
||||
return "${ERR_CHRT_MOUNTS}"
|
||||
|
||||
fi
|
||||
|
||||
do_log "info" "file_only" "4010() Command: [mount -t ${var_fs} ${var_src} ${TARGET}${var_path} -o ${var_opts}] successful."
|
||||
do_log "info" "file_only" "4010() Command: [mount -t ${var_fs} ${var_src} ${var_target}${var_path} -o ${var_opts}] successful."
|
||||
|
||||
done
|
||||
|
||||
|
||||
if [[ "${VAR_NEED_RUN_IN_TARGET:-false}" == "true" ]]; then
|
||||
|
||||
mkdir -p "${TARGET}/run"
|
||||
mkdir -p "${var_target}/run"
|
||||
|
||||
if ! mount --make-rslave --rbind /run "${TARGET}/run"; then
|
||||
if ! mount --make-rslave --rbind /run "${var_target}/run"; then
|
||||
|
||||
do_log "emergency" "file_only" "4010() Command: [mount --make-rslave --rbind /run ${TARGET}/run] failed."
|
||||
do_log "emergency" "file_only" "4010() Command: [mount --make-rslave --rbind /run ${var_target}/run] failed."
|
||||
return "${ERR_CHRT_MOUNTS}"
|
||||
|
||||
fi
|
||||
|
||||
do_log "info" "file_only" "4010() Command: [mount --make-rslave --rbind /run ${TARGET}/run] successful."
|
||||
do_log "info" "file_only" "4010() Command: [mount --make-rslave --rbind /run ${var_target}/run] successful."
|
||||
|
||||
fi
|
||||
|
||||
|
||||
if ! chroot_exec "${TARGET}" mkdir -p /etc/systemd/system/multi-user.target.wants; then
|
||||
if ! chroot_exec "${var_target}" mkdir -p /etc/systemd/system/multi-user.target.wants; then
|
||||
|
||||
do_log "emergency" "file_only" "4010() Command: [chroot_exec ${TARGET} mkdir -p /etc/systemd/system/multi-user.target.wants] failed."
|
||||
do_log "emergency" "file_only" "4010() Command: [chroot_exec ${var_target} mkdir -p /etc/systemd/system/multi-user.target.wants] failed."
|
||||
return "${ERR_CHRT_MOUNTS}"
|
||||
|
||||
fi
|
||||
|
||||
do_log "info" "file_only" "4010() Command: [chroot_exec ${TARGET} mkdir -p /etc/systemd/system/multi-user.target.wants] successful."
|
||||
do_log "info" "file_only" "4010() Command: [chroot_exec ${var_target} mkdir -p /etc/systemd/system/multi-user.target.wants] successful."
|
||||
|
||||
mkdir -p "${TARGET}/media/cdrom0"
|
||||
mkdir -p "${var_target}/media/cdrom0"
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
declare -gx VAR_CHROOT_ACTIVATED="system"
|
||||
do_log "info" "file_only" "4010() Command: [declare -gx VAR_CHROOT_ACTIVATED=system]"
|
||||
|
||||
if [[ "${VAR_RUN_RECOVERY}" == "false" ]]; then
|
||||
|
||||
declare -gx VAR_CHROOT_ACTIVATED="system"
|
||||
do_log "info" "file_only" "4010() Command: [declare -gx VAR_CHROOT_ACTIVATED=system]"
|
||||
|
||||
elif [[ "${VAR_RUN_RECOVERY}" == "true" ]]; then
|
||||
|
||||
declare -gx VAR_CHROOT_ACTIVATED="recovery"
|
||||
do_log "info" "file_only" "4010() Command: [declare -gx VAR_CHROOT_ACTIVATED=recovery]"
|
||||
|
||||
fi
|
||||
|
||||
guard_dir && return 0
|
||||
}
|
||||
|
||||
@@ -15,7 +15,9 @@ guard_sourcing
|
||||
#######################################
|
||||
# Check if the target system is not 'tainted: unmerged-usr'.
|
||||
# Globals:
|
||||
# RECOVERY
|
||||
# TARGET
|
||||
# VAR_RUN_RECOVERY
|
||||
# architecture
|
||||
# Arguments:
|
||||
# None
|
||||
@@ -25,11 +27,15 @@ guard_sourcing
|
||||
check_usr_merge() {
|
||||
### Declare Arrays, HashMaps, and Variables.
|
||||
declare -r var_logfile="/root/.ciss/cdi/log/4015_check_usr_merge.log"
|
||||
declare var_target="${TARGET}"
|
||||
|
||||
chroot_logger "${TARGET}${var_logfile}"
|
||||
### Check for TARGET / RECOVERY.
|
||||
[[ "${VAR_RUN_RECOVERY}" == "true" ]] && var_target="${RECOVERY}"
|
||||
|
||||
chroot_logger "${var_target}${var_logfile}"
|
||||
|
||||
# shellcheck disable=SC2312
|
||||
chroot_script "${TARGET}" "
|
||||
chroot_script "${var_target}" "
|
||||
test -L /bin && test $(readlink -f /bin) = '/usr/bin' && echo 'MERGED:/bin' >> ${var_logfile} || echo 'UNMERGED:/bin' >> ${var_logfile}
|
||||
test -L /sbin && test $(readlink -f /sbin) = '/usr/sbin' && echo 'MERGED:/sbin' >> ${var_logfile} || echo 'UNMERGED:/sbin' >> ${var_logfile}
|
||||
test -L /lib && test $(readlink -f /lib) = '/usr/lib' && echo 'MERGED:/lib' >> ${var_logfile} || echo 'UNMERGED:/lib' >> ${var_logfile}
|
||||
@@ -38,7 +44,7 @@ check_usr_merge() {
|
||||
|
||||
if [[ "${architecture}" == "amd64" ]]; then
|
||||
# shellcheck disable=SC2312
|
||||
chroot_script "${TARGET}" "
|
||||
chroot_script "${var_target}" "
|
||||
test -L /lib64 && test $(readlink -f /lib64) = '/usr/lib64' && echo 'MERGED:/lib64' >> ${var_logfile} || echo 'UNMERGED:/lib64' >> ${var_logfile}
|
||||
echo ExitCode: \$? >> ${var_logfile}
|
||||
"
|
||||
|
||||
@@ -15,7 +15,9 @@ guard_sourcing
|
||||
#######################################
|
||||
# Chroot hook for deleting all expired X.509 certificates in the target system.
|
||||
# Globals:
|
||||
# RECOVERY
|
||||
# TARGET
|
||||
# VAR_RUN_RECOVERY
|
||||
# VAR_SETUP_PATH
|
||||
# Arguments:
|
||||
# None
|
||||
@@ -23,17 +25,22 @@ guard_sourcing
|
||||
# 0: on success
|
||||
#######################################
|
||||
remove_x509() {
|
||||
### Declare Arrays, HashMaps, and Variables.
|
||||
declare var_target="${TARGET}"
|
||||
|
||||
### Check for TARGET / RECOVERY.
|
||||
[[ "${VAR_RUN_RECOVERY}" == "true" ]] && var_target="${RECOVERY}"
|
||||
|
||||
install -m 0700 -o root -g root "${VAR_SETUP_PATH}/includes/chroot/hooks/4020_remove_x509.hooks.sh" \
|
||||
"${TARGET}/root/.ciss/cdi/hooks/4020_remove_x509.hooks.sh"
|
||||
"${var_target}/root/.ciss/cdi/hooks/4020_remove_x509.hooks.sh"
|
||||
|
||||
if ! chroot_script "${TARGET}" "/root/.ciss/cdi/hooks/4020_remove_x509.hooks.sh" "emergency"; then
|
||||
if ! chroot_script "${var_target}" "/root/.ciss/cdi/hooks/4020_remove_x509.hooks.sh" "emergency"; then
|
||||
|
||||
do_log "warn" "file_only" "4020() Command: [chroot_script ${TARGET} /root/.ciss/cdi/hooks/4020_remove_x509.hooks.sh emergency] failed."
|
||||
do_log "warn" "file_only" "4020() Command: [chroot_script ${var_target} /root/.ciss/cdi/hooks/4020_remove_x509.hooks.sh emergency] failed."
|
||||
|
||||
else
|
||||
|
||||
do_log "debug" "file_only" "4020() Command: [chroot_script ${TARGET} /root/.ciss/cdi/hooks/4020_remove_x509.hooks.sh emergency] successful."
|
||||
do_log "debug" "file_only" "4020() Command: [chroot_script ${var_target} /root/.ciss/cdi/hooks/4020_remove_x509.hooks.sh emergency] successful."
|
||||
|
||||
fi
|
||||
|
||||
|
||||
@@ -15,11 +15,13 @@ guard_sourcing
|
||||
#######################################
|
||||
# Configure the '/etc/hostname' | '/etc/hosts' | '/etc/mailname' files.
|
||||
# Globals:
|
||||
# RECOVERY
|
||||
# TARGET
|
||||
# VAR_FINAL_FQDN
|
||||
# VAR_FINAL_IPV4
|
||||
# VAR_FINAL_IPV6
|
||||
# VAR_LINK_IPV6
|
||||
# VAR_RUN_RECOVERY
|
||||
# network_ipv6
|
||||
# Arguments:
|
||||
# None
|
||||
@@ -27,36 +29,42 @@ guard_sourcing
|
||||
# 0: on success
|
||||
#######################################
|
||||
setup_hostname() {
|
||||
### Create the '${TARGET}/etc/hostname' file.
|
||||
cat << EOF >| "${TARGET}/etc/hostname"
|
||||
### Declare Arrays, HashMaps, and Variables.
|
||||
declare var_target="${TARGET}"
|
||||
|
||||
### Check for TARGET / RECOVERY.
|
||||
[[ "${VAR_RUN_RECOVERY}" == "true" ]] && var_target="${RECOVERY}"
|
||||
|
||||
### Create the '${var_target}/etc/hostname' file.
|
||||
cat << EOF >| "${var_target}/etc/hostname"
|
||||
${VAR_FINAL_FQDN}
|
||||
EOF
|
||||
chmod 0644 "${TARGET}/etc/hostname"
|
||||
do_log "info" "file_only" "4030() File generated: '${TARGET}/etc/hostname' | hostname '${VAR_FINAL_FQDN}'."
|
||||
chmod 0644 "${var_target}/etc/hostname"
|
||||
do_log "info" "file_only" "4030() File generated: '${var_target}/etc/hostname' | hostname '${VAR_FINAL_FQDN}'."
|
||||
|
||||
|
||||
### Create the '${TARGET}/etc/mailname' file.
|
||||
cat << EOF >| "${TARGET}/etc/mailname"
|
||||
### Create the '${var_target}/etc/mailname' file.
|
||||
cat << EOF >| "${var_target}/etc/mailname"
|
||||
${VAR_FINAL_FQDN}
|
||||
EOF
|
||||
chmod 0644 "${TARGET}/etc/mailname"
|
||||
do_log "info" "file_only" "4030() File generated: '${TARGET}/etc/mailname' | mailname '${VAR_FINAL_FQDN}'."
|
||||
chmod 0644 "${var_target}/etc/mailname"
|
||||
do_log "info" "file_only" "4030() File generated: '${var_target}/etc/mailname' | mailname '${VAR_FINAL_FQDN}'."
|
||||
|
||||
|
||||
### Generate '${TARGET}/etc/hosts' basic IPv4 entries
|
||||
cat << EOF >| "${TARGET}/etc/hosts"
|
||||
### Generate '${var_target}/etc/hosts' basic IPv4 entries
|
||||
cat << EOF >| "${var_target}/etc/hosts"
|
||||
127.0.0.1 localhost
|
||||
${VAR_FINAL_IPV4} ${VAR_FINAL_FQDN}
|
||||
|
||||
EOF
|
||||
chmod 0644 "${TARGET}/etc/hosts"
|
||||
do_log "info" "file_only" "4030() File generated: '${TARGET}/etc/hosts' with basic IPv4 entries."
|
||||
chmod 0644 "${var_target}/etc/hosts"
|
||||
do_log "info" "file_only" "4030() File generated: '${var_target}/etc/hosts' with basic IPv4 entries."
|
||||
|
||||
|
||||
### Generate '${TARGET}/etc/hosts' basic IPv6 entries
|
||||
### Generate '${var_target}/etc/hosts' basic IPv6 entries
|
||||
if [[ "${VAR_LINK_IPV6,,}" == "true" || "${network_ipv6,,}" == "true" ]]; then
|
||||
|
||||
cat << EOF >> "${TARGET}/etc/hosts"
|
||||
cat << EOF >> "${var_target}/etc/hosts"
|
||||
# The following lines are desirable for IPv6 capable hosts
|
||||
::1 localhost ip6-localhost ip6-loopback
|
||||
fe00::0 ip6-localnet
|
||||
@@ -68,10 +76,13 @@ ${VAR_FINAL_IPV6} ${VAR_FINAL_FQDN}
|
||||
|
||||
EOF
|
||||
|
||||
do_log "info" "file_only" "4030() File updated: '${TARGET}/etc/hosts' with basic IPv6 entries."
|
||||
do_log "info" "file_only" "4030() File updated: '${var_target}/etc/hosts' with basic IPv6 entries."
|
||||
|
||||
fi
|
||||
|
||||
guard_dir && return 0
|
||||
}
|
||||
### Prevents accidental 'unset -f'.
|
||||
# shellcheck disable=SC2034
|
||||
readonly -f setup_hostname
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
|
||||
@@ -17,13 +17,11 @@ guard_sourcing
|
||||
# Globals:
|
||||
# ARY_IPV4_NS
|
||||
# ARY_IPV6_NS
|
||||
# DIR_BAK
|
||||
# RECOVERY
|
||||
# TARGET
|
||||
# VAR_ARCHITECTURE
|
||||
# VAR_CODENAME
|
||||
# VAR_FINAL_IPV6
|
||||
# VAR_LINK_IPV6
|
||||
# VAR_VERSION
|
||||
# VAR_RUN_RECOVERY
|
||||
# Arguments:
|
||||
# None
|
||||
# Returns:
|
||||
@@ -32,59 +30,66 @@ guard_sourcing
|
||||
setup_resolv() {
|
||||
### Declare Arrays, HashMaps, and Variables.
|
||||
declare ns=""
|
||||
declare var_target="${TARGET}"
|
||||
|
||||
if [[ -f "${TARGET}/etc/resolv.conf" ]]; then
|
||||
### Check for TARGET / RECOVERY.
|
||||
[[ "${VAR_RUN_RECOVERY}" == "true" ]] && var_target="${RECOVERY}"
|
||||
|
||||
mkdir -p "${TARGET}/root/.ciss/cdi/backup/etc"
|
||||
mv "${TARGET}/etc/resolv.conf" "${TARGET}/root/.ciss/cdi/backup/etc/resolv.conf.bak"
|
||||
do_log "info" "file_only" "4035() Existing '${TARGET}/etc/resolv.conf' moved."
|
||||
if [[ -f "${var_target}/etc/resolv.conf" ]]; then
|
||||
|
||||
mkdir -p "${var_target}/root/.ciss/cdi/backup/etc"
|
||||
mv "${var_target}/etc/resolv.conf" "${var_target}/root/.ciss/cdi/backup/etc/resolv.conf.bak"
|
||||
do_log "info" "file_only" "4035() Existing '${var_target}/etc/resolv.conf' moved."
|
||||
|
||||
fi
|
||||
|
||||
touch "${TARGET}/etc/resolv.conf"
|
||||
chmod 0644 "${TARGET}/etc/resolv.conf"
|
||||
touch "${var_target}/etc/resolv.conf"
|
||||
chmod 0644 "${var_target}/etc/resolv.conf"
|
||||
|
||||
### Create '/etc/resolv.conf' IPv4 entries for static configuration.
|
||||
insert_header "${TARGET}/etc/resolv.conf"
|
||||
insert_comments "${TARGET}/etc/resolv.conf"
|
||||
cat << EOF >> "${TARGET}/etc/resolv.conf"
|
||||
insert_header "${var_target}/etc/resolv.conf"
|
||||
insert_comments "${var_target}/etc/resolv.conf"
|
||||
cat << EOF >> "${var_target}/etc/resolv.conf"
|
||||
### Custom DNS IPv4 configuration
|
||||
EOF
|
||||
|
||||
for ns in "${ARY_IPV4_NS[@]}"; do
|
||||
|
||||
echo "nameserver ${ns}" >> "${TARGET}/etc/resolv.conf"
|
||||
echo "nameserver ${ns}" >> "${var_target}/etc/resolv.conf"
|
||||
do_log "info" "file_only" "4035() IPv4 nameserver added: [${ns}]."
|
||||
|
||||
done
|
||||
|
||||
echo "" >> "${TARGET}/etc/resolv.conf"
|
||||
do_log "info" "file_only" "4035() IPv4 nameserver at: '${TARGET}/etc/resolv.conf' configured."
|
||||
echo "" >> "${var_target}/etc/resolv.conf"
|
||||
do_log "info" "file_only" "4035() IPv4 nameserver at: '${var_target}/etc/resolv.conf' configured."
|
||||
|
||||
|
||||
### Create '/etc/resolv.conf' IPv6 entries for static configuration.
|
||||
if [[ "${VAR_LINK_IPV6,,}" == "true" || -n "${VAR_FINAL_IPV6}" ]]; then
|
||||
|
||||
cat << EOF >> "${TARGET}/etc/resolv.conf"
|
||||
cat << EOF >> "${var_target}/etc/resolv.conf"
|
||||
### Custom DNS IPv6 configuration
|
||||
EOF
|
||||
|
||||
for ns in "${ARY_IPV6_NS[@]}"; do
|
||||
|
||||
echo "nameserver ${ns}" >> "${TARGET}/etc/resolv.conf"
|
||||
echo "nameserver ${ns}" >> "${var_target}/etc/resolv.conf"
|
||||
do_log "info" "file_only" "4035() IPv6 nameserver added: [${ns}]."
|
||||
|
||||
done
|
||||
|
||||
echo "" >> "${TARGET}/etc/resolv.conf"
|
||||
do_log "info" "file_only" "4035() IPv6 nameserver at: '${TARGET}/etc/resolv.conf' configured."
|
||||
echo "" >> "${var_target}/etc/resolv.conf"
|
||||
do_log "info" "file_only" "4035() IPv6 nameserver at: '${var_target}/etc/resolv.conf' configured."
|
||||
|
||||
fi
|
||||
|
||||
cat << EOF >> "${TARGET}/etc/resolv.conf"
|
||||
cat << EOF >> "${var_target}/etc/resolv.conf"
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
EOF
|
||||
|
||||
guard_dir && return 0
|
||||
}
|
||||
### Prevents accidental 'unset -f'.
|
||||
# shellcheck disable=SC2034
|
||||
readonly -f setup_resolv
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
|
||||
@@ -15,7 +15,9 @@ guard_sourcing
|
||||
#######################################
|
||||
# Configure the '/etc/timezone' | '/etc/localtime' files.
|
||||
# Globals:
|
||||
# RECOVERY
|
||||
# TARGET
|
||||
# VAR_RUN_RECOVERY
|
||||
# ntp_timezone
|
||||
# Arguments:
|
||||
# None
|
||||
@@ -23,17 +25,26 @@ guard_sourcing
|
||||
# 0: on success
|
||||
#######################################
|
||||
setup_timezone() {
|
||||
### Create '${TARGET}/etc/timezone' file.
|
||||
cat << EOF >| "${TARGET}/etc/timezone"
|
||||
### Declare Arrays, HashMaps, and Variables.
|
||||
declare var_target="${TARGET}"
|
||||
|
||||
### Check for TARGET / RECOVERY.
|
||||
[[ "${VAR_RUN_RECOVERY}" == "true" ]] && var_target="${RECOVERY}"
|
||||
|
||||
### Create the '$ {var_target}/etc / timezone' file.
|
||||
cat << EOF >| "${var_target}/etc/timezone"
|
||||
${ntp_timezone:-UTC}
|
||||
EOF
|
||||
chmod 0644 "${TARGET}/etc/timezone"
|
||||
do_log "info" "file_only" "4040() File generated: '${TARGET}/etc/timezone' | timezone '${ntp_timezone:-UTC}'."
|
||||
chmod 0644 "${var_target}/etc/timezone"
|
||||
do_log "info" "file_only" "4040() File generated: '${var_target}/etc/timezone' | timezone '${ntp_timezone:-UTC}'."
|
||||
|
||||
chroot_exec "${TARGET}" ln -sf "/usr/share/zoneinfo/${ntp_timezone}" /etc/localtime
|
||||
chroot_exec "${var_target}" ln -sf "/usr/share/zoneinfo/${ntp_timezone}" /etc/localtime
|
||||
|
||||
chroot_exec "${TARGET}" dpkg-reconfigure -f noninteractive tzdata
|
||||
chroot_exec "${var_target}" dpkg-reconfigure -f noninteractive tzdata
|
||||
|
||||
guard_dir && return 0
|
||||
}
|
||||
### Prevents accidental 'unset -f'.
|
||||
# shellcheck disable=SC2034
|
||||
readonly -f setup_timezone
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
|
||||
@@ -16,10 +16,10 @@ guard_sourcing
|
||||
# Set locale, locale overrides and configure keyboard layout.
|
||||
# Globals:
|
||||
# ARY_LOCALE
|
||||
# RECOVERY
|
||||
# TARGET
|
||||
# VAR_ARCHITECTURE
|
||||
# VAR_CODENAME
|
||||
# VAR_VERSION
|
||||
# VAR_DATE
|
||||
# VAR_RUN_RECOVERY
|
||||
# locale_country
|
||||
# locale_keyboard_xkb_keymap
|
||||
# locale_language
|
||||
@@ -42,15 +42,22 @@ guard_sourcing
|
||||
setup_locales() {
|
||||
### Declare Arrays, HashMaps, and Variables.
|
||||
declare var_locale_hook="/root/.ciss/cdi/hooks/4050_setup_locales.hooks.sh"
|
||||
declare var_target="${TARGET}"
|
||||
|
||||
### Check for TARGET / RECOVERY.
|
||||
[[ "${VAR_RUN_RECOVERY}" == "true" ]] && var_target="${RECOVERY}"
|
||||
|
||||
### Give priority to '${locale_locale}' over separately configured variables '${locale_country}' and '${locale_language}'.
|
||||
### If 'locale_locale' is not set, build it from 'locale_language' and 'locale_country'.
|
||||
if [[ -n "${locale_language:-}" && -n "${locale_country:-}" && -z "${ARY_LOCALE[0]:-}" ]]; then
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
ARY_LOCALE+="${locale_language}_${locale_country}.UTF-8"
|
||||
|
||||
fi
|
||||
|
||||
### Creat Hook in target.
|
||||
cat << EOF >| "${TARGET}${var_locale_hook}"
|
||||
cat << EOF >| "${var_target}${var_locale_hook}"
|
||||
#!/bin/bash
|
||||
# SPDX-Version: 3.0
|
||||
# SPDX-CreationInfo: ${VAR_DATE}; WEIDNER, Marc S.; <msw@coresecret.dev>
|
||||
@@ -72,7 +79,7 @@ declare loc=""
|
||||
|
||||
EOF
|
||||
|
||||
cat << 'EOF' >> "${TARGET}${var_locale_hook}"
|
||||
cat << 'EOF' >> "${var_target}${var_locale_hook}"
|
||||
ary_locale+=( "${locale_0}" )
|
||||
[[ -n "${locale_1}" ]] && ary_locale+=( "${locale_1}" )
|
||||
|
||||
@@ -94,7 +101,7 @@ done
|
||||
|
||||
EOF
|
||||
|
||||
cat << EOF >> "${TARGET}${var_locale_hook}"
|
||||
cat << EOF >> "${var_target}${var_locale_hook}"
|
||||
update-locale \
|
||||
LANG=${ARY_LOCALE[0]} \
|
||||
LC_ADDRESS=${locale_override_address:-${ARY_LOCALE[0]}} \
|
||||
@@ -112,13 +119,13 @@ LC_IDENTIFICATION=${ARY_LOCALE[0]}
|
||||
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
EOF
|
||||
chmod 0700 "${TARGET}${var_locale_hook}"
|
||||
chroot_script "${TARGET}" "${var_locale_hook}"
|
||||
chmod 0700 "${var_target}${var_locale_hook}"
|
||||
chroot_script "${var_target}" "${var_locale_hook}"
|
||||
|
||||
### Set the keyboard layout for the system (for consoles).
|
||||
insert_header "${TARGET}/etc/default/keyboard"
|
||||
insert_comments "${TARGET}/etc/default/keyboard"
|
||||
cat << EOF >> "${TARGET}/etc/default/keyboard"
|
||||
insert_header "${var_target}/etc/default/keyboard"
|
||||
insert_comments "${var_target}/etc/default/keyboard"
|
||||
cat << EOF >> "${var_target}/etc/default/keyboard"
|
||||
# KEYBOARD CONFIGURATION FILE
|
||||
# Consult the keyboard(5) manual page.
|
||||
|
||||
@@ -130,9 +137,12 @@ BACKSPACE="guess"
|
||||
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=conf
|
||||
EOF
|
||||
chmod 0644 "${TARGET}/etc/default/keyboard"
|
||||
do_log "info" "file_only" "4050() Keyboard layout updated: 'XKBLAYOUT=${locale_keyboard_xkb_keymap}' -> '${TARGET}/etc/default/keyboard'."
|
||||
chmod 0644 "${var_target}/etc/default/keyboard"
|
||||
do_log "info" "file_only" "4050() Keyboard layout updated: 'XKBLAYOUT=${locale_keyboard_xkb_keymap}' -> '${var_target}/etc/default/keyboard'."
|
||||
|
||||
guard_dir && return 0
|
||||
}
|
||||
### Prevents accidental 'unset -f'.
|
||||
# shellcheck disable=SC2034
|
||||
readonly -f setup_locales
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
|
||||
Reference in New Issue
Block a user