rescue_configure() { local hostname="${1}" # apt / conf printf "\ Acquire::AllowInsecureRepositories False; Acquire::AllowWeakRepositories False; Acquire::AllowDowngradeToInsecureRepositories False; Acquire::Check-Valid-Until True; APT::Install-Recommends False; APT::Install-Suggests False; APT::Get::Show-Versions True; Dir::Etc::SourceParts \"\"; Dpkg::Progress True; " >"/etc/apt/apt.conf.d/apt.conf" # apt / sources apt_sources_write # bash / rc main_link_bashrc mv .bashrc .bashrc.old # host name hostname "${hostname}" # locales printf "\ en_US.UTF-8 UTF-8 fr_FR.UTF-8 UTF-8 " >"/etc/locale.gen" # generate locales locale-gen # update catalog apt_update # disable frontend debian_disable_frontend # install backports apt_install_backports "tmux" # install packages apt_install_release "apt-file" "mosh" "screen" "byobu" # update catalog apt_update } rescue_install() { # update catalog apt_update # disable frontend debian_disable_frontend # upgrade packages apt_upgrade # install packages apt_install_release \ "man-db" \ "dmidecode" "efibootmgr" "lshw" "pciutils" "usbutils" \ "parted" "mdadm" "cryptsetup-bin" "lvm2" \ "btrfs-progs" "dosfstools" "duperemove" "squashfs-tools" \ "git" "micro" "nano" "python3" "rsync" "vim" \ "exa" "lf" "ncdu" "nnn" "ranger" "tree" \ "file" "htop" "iotop" "ipcalc" "libdigest-sha3-perl" "lsof" # install backports apt_install_backports \ "grub-pc-bin" \ \ "grub-efi-amd64-bin" } rescue_upload() { local host="${1}" local hostname="${2}" if [ -n "${hostname}" ]; then local user="root" # local user_host="${user}@${host}" # remove fingerprints ssh-keygen -R "${host}" # copy ssh id ssh-copy-id \ -o "StrictHostKeyChecking=accept-new" \ "${user_host}" # upload root rsync --delete --recursive \ "$(main_env_root)" "${user_host}:/etc" # call setup # TODO variable ssh "${user_host}" -- "\ . \"/etc/bash/main.sh\" ; rescue_configure \"${hostname}\"" # create session ssh "${user_host}" -- byobu new-session -d # send keys ssh "${user_host}" -- byobu send-keys "rescue_install" "C-m" # attach session mosh "${user_host}" -- byobu attach-session else echo "host & hostname" return 1 fi } rescue_wipe_1_zero() { fs_wipe "/dev/mapper/crypt" "512M" } rescue_wipe_3_close() { umount "/media/boot" umount "/media/crypt" && cryptsetup luksClose "crypt" }