configure
This commit is contained in:
parent
ef87d4d410
commit
d11ab01afe
3 changed files with 74 additions and 129 deletions
|
@ -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() {
|
rescue_hetzner_install() {
|
||||||
local package
|
local package
|
||||||
local release='bookworm'
|
local release='bookworm'
|
||||||
|
@ -107,28 +51,30 @@ rescue_hetzner_upload() {
|
||||||
local host="${1}"
|
local host="${1}"
|
||||||
local hostname="${2}"
|
local hostname="${2}"
|
||||||
if [ "${hostname}" ]; then
|
if [ "${hostname}" ]; then
|
||||||
local user='root'
|
local user="root"
|
||||||
#
|
#
|
||||||
local user_host="${user}@${host}"
|
local user_host="${user}@${host}"
|
||||||
# remove fingerprints
|
# remove fingerprints
|
||||||
ssh-keygen -R "${host}"
|
ssh-keygen -R "${host}"
|
||||||
# copy ssh id
|
# copy ssh id
|
||||||
ssh-copy-id \
|
ssh-copy-id \
|
||||||
-o 'StrictHostKeyChecking=accept-new' \
|
-o "StrictHostKeyChecking=accept-new" \
|
||||||
"${user_host}"
|
"${user_host}"
|
||||||
# upload root
|
# upload root
|
||||||
rsync --delete --recursive "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/"
|
rsync --delete --recursive \
|
||||||
|
"${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/"
|
||||||
# call setup
|
# call setup
|
||||||
# TODO variable
|
# 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
|
# create session
|
||||||
ssh "${user_host}" -- byobu new-session -d
|
ssh "${user_host}" -- byobu new-session -d
|
||||||
# send keys
|
# 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
|
# attach session
|
||||||
mosh "${user_host}" -- byobu attach-session
|
mosh "${user_host}" -- byobu attach-session
|
||||||
else
|
else
|
||||||
echo 'Host?'
|
echo "Host?"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,71 +1,5 @@
|
||||||
#! /usr/bin/env sh
|
#! /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() {
|
rescue_ovh_install() {
|
||||||
local package
|
local package
|
||||||
local release="bookworm"
|
local release="bookworm"
|
||||||
|
@ -127,7 +61,7 @@ rescue_ovh_upload() {
|
||||||
# call setup
|
# call setup
|
||||||
# TODO variable
|
# TODO variable
|
||||||
ssh "${user_host}" -- "\
|
ssh "${user_host}" -- "\
|
||||||
source \"/etc/bash/main.sh\" ; rescue_ovh_configure \"${hostname}\""
|
source \"/etc/bash/main.sh\" ; rescue_configure \"${hostname}\""
|
||||||
# create session
|
# create session
|
||||||
ssh "${user_host}" -- byobu new-session -d
|
ssh "${user_host}" -- byobu new-session -d
|
||||||
# send keys
|
# send keys
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
Loading…
Reference in a new issue