mirror of
https://github.com/stornic56/debianito-post-install.git
synced 2026-07-16 05:49:49 +00:00
lang & firefox-esr
- Added `_detect_lang()` helper to `modules/utils.sh` (extracts first 2 chars from `$LANG`, fallback to `en`). - Created `_detect_lang_pkg()` utility for LibreOffice localization: handles regional variants (`es-ar` → `es`) and skips English packages. - Implemented `_check_network()` with cascade methods (ping→wget→curl) in `modules/utils.sh`. Warning-only pre-flight check after `check_sudo` in `debianito.sh`, compatible with `set -euo pipefail`. - Fixed system time validation: changed `2026` threshold to `2025` in `check_system_time()` (replaced self-referential `$(date +%Y)` which always evaluated false). - Refactored LibreOffice language selection in `office.sh`: replaced 10 lines of inline logic with `_detect_lang_pkg "libreoffice-l10n"`. - Overhauled Firefox ESR integration in `internet.sh`: added state detection, mutual exclusion guard (both Firefox variants selected → warning), new `install_firefox_esr()` function with language support. - Updated `install_firefox_mozilla()`: added Debian version guard (`<12`), replaced `_run_install` with `_run_cmd`. - Standardized header in internet menu and improved whiptail UX for Firefox options.
This commit is contained in:
+51
-2
@@ -48,7 +48,7 @@ check_system_time() {
|
||||
fi
|
||||
local year
|
||||
year=$(date +%Y)
|
||||
if [ "$year" -lt 2026 ]; then
|
||||
if [ "$year" -lt 2025 ]; then
|
||||
local msg="System date/time appears to be incorrect\n"
|
||||
msg+="($(date '+%Y-%m-%d %H:%M')). This will prevent Debian\n"
|
||||
msg+="repositories from working properly.\n\n"
|
||||
@@ -58,7 +58,7 @@ check_system_time() {
|
||||
sync_system_time
|
||||
local new_year
|
||||
new_year=$(date +%Y)
|
||||
if [ "$new_year" -ge 2026 ]; then
|
||||
if [ "$new_year" -ge 2025 ]; then
|
||||
echo -e "${GREEN}Time synced: $(date '+%Y-%m-%d %H:%M')${NC}"
|
||||
else
|
||||
echo -e "${RED}Could not sync time automatically.${NC}"
|
||||
@@ -581,3 +581,52 @@ get_backports_kernel_version() {
|
||||
echo "unknown"
|
||||
fi
|
||||
}
|
||||
|
||||
# ----------------------------------
|
||||
# Language helpers
|
||||
# ----------------------------------
|
||||
_detect_lang() {
|
||||
local sys_lang
|
||||
sys_lang=$(echo "${LANG:-en}" | cut -c1-2 | tr '[:upper:]' '[:lower:]')
|
||||
echo "$sys_lang"
|
||||
}
|
||||
|
||||
_detect_lang_pkg() {
|
||||
local base="$1"
|
||||
local lang2
|
||||
lang2=$(_detect_lang)
|
||||
|
||||
[ "$lang2" = "en" ] && echo "" && return
|
||||
|
||||
local full="${LANG%%.*}"
|
||||
local hyphenated_full
|
||||
hyphenated_full=$(echo "$full" | tr '[:upper:]' '[:lower:]' | tr '_' '-')
|
||||
local pkg
|
||||
|
||||
pkg=$(apt-cache search "^${base}-${hyphenated_full}$" 2>/dev/null | awk 'NR==1{print $1}')
|
||||
[ -z "$pkg" ] && pkg=$(apt-cache search "^${base}-${lang2}$" 2>/dev/null | awk 'NR==1{print $1}')
|
||||
[ -z "$pkg" ] && pkg=$(apt-cache search "^${base}-all$" 2>/dev/null | awk 'NR==1{print $1}')
|
||||
|
||||
echo "$pkg"
|
||||
}
|
||||
|
||||
# ----------------------------------
|
||||
# Network connectivity check
|
||||
# ----------------------------------
|
||||
_check_network() {
|
||||
local target="${1:-deb.debian.org}"
|
||||
|
||||
if command -v ping &>/dev/null; then
|
||||
ping -c 1 -W 3 "$target" &>/dev/null && return 0
|
||||
fi
|
||||
|
||||
if command -v wget &>/dev/null; then
|
||||
wget -q --timeout=5 --spider "http://${target}" &>/dev/null && return 0
|
||||
fi
|
||||
|
||||
if command -v curl &>/dev/null; then
|
||||
curl -s --connect-timeout 5 -o /dev/null "http://${target}" &>/dev/null && return 0
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user