configure

This commit is contained in:
Marc Beninca 2024-11-11 17:33:55 +01:00
parent ef87d4d410
commit d11ab01afe
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F
3 changed files with 74 additions and 129 deletions

View file

@ -1,59 +1,3 @@
rescue_hetzner_configure() {
local hostname="${1}"
local package
local packages=(
'mosh'
'screen' 'tmux' 'byobu'
'apt-file'
)
# apt / conf
echo -n "\
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'
# apt / sources
echo -n "\
deb https://deb.debian.org/debian bookworm main non-free-firmware contrib non-free
deb https://deb.debian.org/debian bookworm-backports main non-free-firmware contrib non-free
deb https://deb.debian.org/debian bookworm-updates main non-free-firmware contrib non-free
deb https://deb.debian.org/debian-security bookworm-security main non-free-firmware contrib non-free
" >'/etc/apt/sources.list'
# bash / rc
main_link_bashrc
mv .bashrc .bashrc.old
# host name
hostname "${hostname}"
# locales
echo -n "\
en_US.UTF-8 UTF-8
fr_FR.UTF-8 UTF-8
" >'/etc/locale.gen'
# generate locales
locale-gen
# update catalog
apt-get update
#
debian_disable_frontend
# install packages
for package in "${packages[@]}"; do
echo
echo "${package}"
apt-get install \
--assume-yes \
"${package}"
apt_clean_cache
done
# update catalog
apt-get update
}
rescue_hetzner_install() {
local package
local release='bookworm'
@ -107,28 +51,30 @@ rescue_hetzner_upload() {
local host="${1}"
local hostname="${2}"
if [ "${hostname}" ]; then
local user='root'
local user="root"
#
local user_host="${user}@${host}"
# remove fingerprints
ssh-keygen -R "${host}"
# copy ssh id
ssh-copy-id \
-o 'StrictHostKeyChecking=accept-new' \
-o "StrictHostKeyChecking=accept-new" \
"${user_host}"
# upload root
rsync --delete --recursive "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/"
rsync --delete --recursive \
"${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/"
# call setup
# TODO variable
ssh "${user_host}" -- "source '/etc/bash/main.sh' ; rescue_hetzner_configure '${hostname}'"
ssh "${user_host}" -- "\
source \"/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_hetzner_install' 'C-m'
ssh "${user_host}" -- byobu send-keys "rescue_hetzner_install" "C-m"
# attach session
mosh "${user_host}" -- byobu attach-session
else
echo 'Host?'
echo "Host?"
return 1
fi
}

View file

@ -1,71 +1,5 @@
#! /usr/bin/env sh
rescue_ovh_configure() {
local hostname="${1}"
local release="bookworm"
local package
# 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
printf "%s" "\
deb https://deb.debian.org/debian \
${release} main non-free-firmware contrib non-free
deb https://deb.debian.org/debian \
${release}-backports main non-free-firmware contrib non-free
deb https://deb.debian.org/debian \
${release}-updates main non-free-firmware contrib non-free
deb https://deb.debian.org/debian-security \
${release}-security main non-free-firmware contrib non-free
" >"/etc/apt/sources.list"
# 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-get update
# 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_cache
done
# install packages
set "apt-file" "mosh" "byobu"
for package in "${@}"; do
echo
echo "${package}"
apt-get install --assume-yes \
"${package}"
apt_clean_cache
done
# update catalog
apt-get update
}
rescue_ovh_install() {
local package
local release="bookworm"
@ -127,7 +61,7 @@ rescue_ovh_upload() {
# call setup
# TODO variable
ssh "${user_host}" -- "\
source \"/etc/bash/main.sh\" ; rescue_ovh_configure \"${hostname}\""
source \"/etc/bash/main.sh\" ; rescue_configure \"${hostname}\""
# create session
ssh "${user_host}" -- byobu new-session -d
# send keys

View file

@ -0,0 +1,65 @@
rescue_configure() {
local hostname="${1}"
local release="bookworm"
local package
# 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
printf "%s" "\
deb https://deb.debian.org/debian \
${release} main non-free-firmware contrib non-free
deb https://deb.debian.org/debian \
${release}-backports main non-free-firmware contrib non-free
deb https://deb.debian.org/debian \
${release}-updates main non-free-firmware contrib non-free
deb https://deb.debian.org/debian-security \
${release}-security main non-free-firmware contrib non-free
" >"/etc/apt/sources.list"
# 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-get update
# 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_cache
done
# install packages
set "apt-file" "mosh" "screen" "byobu"
for package in "${@}"; do
echo
echo "${package}"
apt-get install --assume-yes \
"${package}"
apt_clean_cache
done
# update catalog
apt-get update
}