diff --git a/bash/apt.sh b/bash/apt.sh index 5b821e2..a0f7353 100644 --- a/bash/apt.sh +++ b/bash/apt.sh @@ -3,6 +3,30 @@ apt_clean() { clean } +apt_install_backports() { + apt_install_target "${DEBIAN_CODENAME}-backports" "${@}" +} + +apt_install_release() { + apt_install_target "${DEBIAN_CODENAME}" "${@}" +} + +apt_install_target() { + local target="${1}" + shift + local package + for package in "${@}"; do + log_info + log_info "${package} ← ${target}" + apt-get \ + install \ + --assume-yes \ + --target-release "${target}" \ + "${package}" + apt_clean + done +} + apt_update() { apt-get \ update @@ -12,4 +36,5 @@ apt_upgrade() { apt-get \ upgrade \ --assume-yes + apt_clean } diff --git a/bash/debian.sh b/bash/debian.sh index acf628d..e3aa7ba 100644 --- a/bash/debian.sh +++ b/bash/debian.sh @@ -1,3 +1,8 @@ -function debian_disable_frontend { - export DEBIAN_FRONTEND='noninteractive' +DEBIAN_CODENAME="$( + grep "VERSION_CODENAME" "/etc/os-release" | + cut --delimiter "=" --fields "2" +)" + +debian_disable_frontend() { + export DEBIAN_FRONTEND='noninteractive' } diff --git a/bash/rescue.sh b/bash/rescue.sh index 732d1ea..3a4bb7d 100644 --- a/bash/rescue.sh +++ b/bash/rescue.sh @@ -1,7 +1,5 @@ rescue_configure() { local hostname="${1}" - local release="bookworm" - local package # apt / conf printf "\ Acquire::AllowInsecureRepositories False; @@ -17,13 +15,13 @@ Dpkg::Progress True; # apt / sources printf "%s" "\ deb https://deb.debian.org/debian \ -${release} main non-free-firmware contrib non-free +${DEBIAN_CODENAME} main non-free-firmware contrib non-free deb https://deb.debian.org/debian \ -${release}-backports main non-free-firmware contrib non-free +${DEBIAN_CODENAME}-backports main non-free-firmware contrib non-free deb https://deb.debian.org/debian \ -${release}-updates main non-free-firmware contrib non-free +${DEBIAN_CODENAME}-updates main non-free-firmware contrib non-free deb https://deb.debian.org/debian-security \ -${release}-security main non-free-firmware contrib non-free +${DEBIAN_CODENAME}-security main non-free-firmware contrib non-free " >"/etc/apt/sources.list" # bash / rc main_link_bashrc @@ -42,41 +40,22 @@ fr_FR.UTF-8 UTF-8 # disable frontend debian_disable_frontend # install backports - set "tmux" - for package in "${@}"; do - echo - echo "${package}" - apt-get install --assume-yes \ - --target-release "${release}-backports" \ - "${package}" - apt_clean - done + apt_install_backports "tmux" # install packages - set "apt-file" "mosh" "screen" "byobu" - for package in "${@}"; do - echo - echo "${package}" - apt-get install --assume-yes \ - "${package}" - apt_clean - done + apt_install_release "apt-file" "mosh" "screen" "byobu" # update catalog apt_update } rescue_install() { - local package - local release="bookworm" # update catalog apt_update # disable frontend debian_disable_frontend # upgrade packages apt_upgrade - # clean cache - apt_clean # install packages - set \ + apt_install_release \ "man-db" \ "dmidecode" "efibootmgr" "lshw" "pciutils" "usbutils" \ "parted" "mdadm" "cryptsetup-bin" "lvm2" \ @@ -84,26 +63,11 @@ rescue_install() { "git" "micro" "nano" "python3" "rsync" "vim" \ "exa" "lf" "ncdu" "nnn" "ranger" "tree" \ "file" "htop" "iotop" "ipcalc" "libdigest-sha3-perl" "lsof" - for package in "${@}"; do - echo - echo "${package}" - apt-get install --assume-yes \ - "${package}" - apt_clean - done # install backports - set \ + apt_install_backports \ "grub-pc-bin" \ \ "grub-efi-amd64-bin" - for package in "${@}"; do - echo - echo "${package}" - apt-get install --assume-yes \ - --target-release "${release}-backports" \ - "${package}" - apt_clean - done } rescue_upload() {