2024-11-11 16:33:55 +00:00
|
|
|
rescue_configure() {
|
|
|
|
local hostname="${1}"
|
|
|
|
# apt / conf
|
2024-11-15 18:24:48 +00:00
|
|
|
apt_conf_write
|
2024-11-11 16:33:55 +00:00
|
|
|
# apt / sources
|
2024-11-15 18:23:33 +00:00
|
|
|
apt_sources_write
|
2024-11-11 16:33:55 +00:00
|
|
|
# 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
|
2024-11-11 19:42:37 +00:00
|
|
|
apt_update
|
2024-11-11 16:33:55 +00:00
|
|
|
# disable frontend
|
|
|
|
debian_disable_frontend
|
|
|
|
# install backports
|
2024-11-12 05:03:36 +00:00
|
|
|
apt_install_backports "tmux"
|
2024-11-11 16:33:55 +00:00
|
|
|
# install packages
|
2024-11-12 05:03:36 +00:00
|
|
|
apt_install_release "apt-file" "mosh" "screen" "byobu"
|
2024-11-11 16:33:55 +00:00
|
|
|
# update catalog
|
2024-11-11 19:42:37 +00:00
|
|
|
apt_update
|
2024-11-11 16:33:55 +00:00
|
|
|
}
|
2024-11-11 16:52:34 +00:00
|
|
|
|
|
|
|
rescue_install() {
|
|
|
|
# update catalog
|
2024-11-11 19:42:37 +00:00
|
|
|
apt_update
|
2024-11-11 16:52:34 +00:00
|
|
|
# disable frontend
|
|
|
|
debian_disable_frontend
|
|
|
|
# upgrade packages
|
2024-11-11 19:40:56 +00:00
|
|
|
apt_upgrade
|
2024-11-11 16:52:34 +00:00
|
|
|
# install packages
|
2024-11-12 05:03:36 +00:00
|
|
|
apt_install_release \
|
2024-11-11 16:52:34 +00:00
|
|
|
"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
|
2024-11-12 05:03:36 +00:00
|
|
|
apt_install_backports \
|
2024-11-11 16:52:34 +00:00
|
|
|
"grub-pc-bin" \
|
|
|
|
\
|
|
|
|
"grub-efi-amd64-bin"
|
|
|
|
}
|
2024-11-11 16:56:25 +00:00
|
|
|
|
|
|
|
rescue_upload() {
|
|
|
|
local host="${1}"
|
|
|
|
local hostname="${2}"
|
2024-11-12 09:25:44 +00:00
|
|
|
if [ -n "${hostname}" ]; then
|
2024-11-11 16:56:25 +00:00
|
|
|
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 \
|
2024-11-15 18:38:54 +00:00
|
|
|
"$(dirname "${ENV}")" "${user_host}:/etc"
|
2024-11-11 16:56:25 +00:00
|
|
|
# call setup
|
|
|
|
# TODO variable
|
2024-11-15 18:38:54 +00:00
|
|
|
ssh "${user_host}" -- \
|
|
|
|
". \"${ENV}\" ; rescue_configure \"${hostname}\""
|
2024-11-11 16:56:25 +00:00
|
|
|
# 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
|
2024-11-11 20:08:52 +00:00
|
|
|
echo "host & hostname"
|
2024-11-11 16:56:25 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
2024-11-11 16:59:03 +00:00
|
|
|
|
2024-11-11 17:02:21 +00:00
|
|
|
rescue_wipe_1_zero() {
|
2024-11-12 19:22:58 +00:00
|
|
|
fs_wipe "/dev/mapper/crypt" "512M"
|
2024-11-11 17:02:21 +00:00
|
|
|
}
|
|
|
|
|
2024-11-11 16:59:03 +00:00
|
|
|
rescue_wipe_3_close() {
|
|
|
|
umount "/media/boot"
|
|
|
|
umount "/media/crypt" &&
|
|
|
|
cryptsetup luksClose "crypt"
|
|
|
|
}
|