94 lines
2.1 KiB
Bash
94 lines
2.1 KiB
Bash
rwx_rescue_configure() {
|
|
local hostname="${1}"
|
|
# apt / conf
|
|
rwx_apt_conf_write
|
|
# apt / sources
|
|
rwx_apt_sources_write
|
|
# bash / rc
|
|
main_link_bashrc
|
|
mv "${HOME}/.bashrc" "${HOME}/.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
|
|
rwx_apt_update
|
|
# disable frontend
|
|
rwx_debian_frontend_disable
|
|
# install backports
|
|
rwx_apt_install_backports "tmux"
|
|
# install packages
|
|
rwx_apt_install_release "apt-file" "mosh" "screen" "byobu"
|
|
# update catalog
|
|
rwx_apt_update
|
|
}
|
|
|
|
rwx_rescue_install() {
|
|
# update catalog
|
|
rwx_apt_update
|
|
# disable frontend
|
|
rwx_debian_frontend_disable
|
|
# upgrade packages
|
|
rwx_apt_upgrade
|
|
# install packages
|
|
rwx_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
|
|
rwx_apt_install_backports \
|
|
"grub-pc-bin" \
|
|
\
|
|
"grub-efi-amd64-bin"
|
|
}
|
|
|
|
rwx_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}\" ; rwx_rescue_configure \"${hostname}\""
|
|
# create session
|
|
ssh "${user_host}" -- byobu new-session -d
|
|
# send keys
|
|
ssh "${user_host}" -- byobu send-keys "rwx_rescue_install" "C-m"
|
|
# attach session
|
|
mosh "${user_host}" -- byobu attach-session
|
|
else
|
|
echo "host & hostname"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
rwx_rescue_wipe_1_zero() {
|
|
rwx_fs_wipe "/dev/mapper/crypt" "512M"
|
|
}
|
|
|
|
rwx_rescue_wipe_3_close() {
|
|
umount "/media/boot"
|
|
umount "/media/crypt" &&
|
|
cryptsetup luksClose "crypt"
|
|
}
|