rescue_configure() { local hostname="${1}" # apt / conf apt_conf_write # 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 \ "$(dirname "${ENV}")" "${user_host}:/etc" # call setup # TODO variable ssh "${user_host}" -- \ ". \"${ENV}\" ; 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" }