From d11ab01afe392b952f4e7cee08fcf1e4461ce271 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 17:33:55 +0100 Subject: [PATCH] configure --- bash/rescue-hetzner.sh | 70 +++++------------------------------------- bash/rescue-ovh.sh | 68 +--------------------------------------- bash/rescue.sh | 65 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 129 deletions(-) diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index ab7d379..5b123ab 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -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 } diff --git a/bash/rescue-ovh.sh b/bash/rescue-ovh.sh index a88b9af..cd91e87 100644 --- a/bash/rescue-ovh.sh +++ b/bash/rescue-ovh.sh @@ -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 diff --git a/bash/rescue.sh b/bash/rescue.sh index e69de29..8b1bc32 100644 --- a/bash/rescue.sh +++ b/bash/rescue.sh @@ -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 +}