shfmt
This commit is contained in:
parent
5776a03fe4
commit
6419243098
1 changed files with 141 additions and 130 deletions
|
@ -1,5 +1,5 @@
|
||||||
rescue_hetzner_configure() {
|
rescue_hetzner_configure() {
|
||||||
local hostname="${1}"
|
local hostname="${1}"
|
||||||
local package
|
local package
|
||||||
local packages=(
|
local packages=(
|
||||||
'mosh'
|
'mosh'
|
||||||
|
@ -17,14 +17,14 @@ APT::Install-Suggests False;
|
||||||
APT::Get::Show-Versions True;
|
APT::Get::Show-Versions True;
|
||||||
Dir::Etc::SourceParts '';
|
Dir::Etc::SourceParts '';
|
||||||
Dpkg::Progress True;
|
Dpkg::Progress True;
|
||||||
" > '/etc/apt/apt.conf'
|
" >'/etc/apt/apt.conf'
|
||||||
# apt / sources
|
# apt / sources
|
||||||
echo -n "\
|
echo -n "\
|
||||||
deb https://deb.debian.org/debian bookworm main non-free-firmware contrib non-free
|
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-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 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
|
deb https://deb.debian.org/debian-security bookworm-security main non-free-firmware contrib non-free
|
||||||
" > '/etc/apt/sources.list'
|
" >'/etc/apt/sources.list'
|
||||||
# bash / rc
|
# bash / rc
|
||||||
main_link_bashrc
|
main_link_bashrc
|
||||||
mv .bashrc .bashrc.old
|
mv .bashrc .bashrc.old
|
||||||
|
@ -34,7 +34,7 @@ deb https://deb.debian.org/debian-security bookworm-security main non-free-firmw
|
||||||
echo -n "\
|
echo -n "\
|
||||||
en_US.UTF-8 UTF-8
|
en_US.UTF-8 UTF-8
|
||||||
fr_FR.UTF-8 UTF-8
|
fr_FR.UTF-8 UTF-8
|
||||||
" > '/etc/locale.gen'
|
" >'/etc/locale.gen'
|
||||||
# generate locales
|
# generate locales
|
||||||
locale-gen
|
locale-gen
|
||||||
# update catalog
|
# update catalog
|
||||||
|
@ -42,8 +42,9 @@ fr_FR.UTF-8 UTF-8
|
||||||
#
|
#
|
||||||
debian_disable_frontend
|
debian_disable_frontend
|
||||||
# install packages
|
# install packages
|
||||||
for package in "${packages[@]}" ; do
|
for package in "${packages[@]}"; do
|
||||||
echo ; echo "${package}"
|
echo
|
||||||
|
echo "${package}"
|
||||||
apt-get install \
|
apt-get install \
|
||||||
--assume-yes \
|
--assume-yes \
|
||||||
"${package}"
|
"${package}"
|
||||||
|
@ -82,16 +83,18 @@ rescue_hetzner_install() {
|
||||||
#
|
#
|
||||||
apt_clean_cache
|
apt_clean_cache
|
||||||
# install packages
|
# install packages
|
||||||
for package in "${packages[@]}" ; do
|
for package in "${packages[@]}"; do
|
||||||
echo ; echo "${package}"
|
echo
|
||||||
|
echo "${package}"
|
||||||
apt-get install \
|
apt-get install \
|
||||||
--assume-yes \
|
--assume-yes \
|
||||||
"${package}"
|
"${package}"
|
||||||
apt_clean_cache
|
apt_clean_cache
|
||||||
done
|
done
|
||||||
# install backports
|
# install backports
|
||||||
for package in "${backports[@]}" ; do
|
for package in "${backports[@]}"; do
|
||||||
echo ; echo "${package}"
|
echo
|
||||||
|
echo "${package}"
|
||||||
apt-get install \
|
apt-get install \
|
||||||
--assume-yes \
|
--assume-yes \
|
||||||
--target-release "${release}-backports" \
|
--target-release "${release}-backports" \
|
||||||
|
@ -103,7 +106,7 @@ rescue_hetzner_install() {
|
||||||
rescue_hetzner_upload() {
|
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}"
|
||||||
|
@ -149,40 +152,46 @@ rescue_hetzner_wipe_8_8_0_init() {
|
||||||
read
|
read
|
||||||
#
|
#
|
||||||
number=0
|
number=0
|
||||||
for device in "${devices[@]}" ; do
|
for device in "${devices[@]}"; do
|
||||||
((number++))
|
((number++))
|
||||||
echo ; echo "#${number}: ${device}"
|
echo
|
||||||
|
echo "#${number}: ${device}"
|
||||||
#
|
#
|
||||||
parted "${device}" --script mktable gpt
|
parted "${device}" --script \
|
||||||
|
mktable gpt
|
||||||
#
|
#
|
||||||
parted "${device}" unit "${unit}" \
|
parted "${device}" \
|
||||||
mkpart "crypt-${number}" 33282 7630885
|
unit "${unit}" mkpart "crypt-${number}" 33282 7630885
|
||||||
#
|
#
|
||||||
parted "${device}" unit "${unit}" \
|
parted "${device}" \
|
||||||
mkpart "boot-${number}" 514 33282
|
unit "${unit}" mkpart "boot-${number}" 514 33282
|
||||||
#
|
#
|
||||||
parted "${device}" unit "${unit}" \
|
parted "${device}" \
|
||||||
mkpart "esp-${number}" 2 514
|
unit "${unit}" mkpart "esp-${number}" 2 514
|
||||||
parted "${device}" set 3 esp on
|
parted "${device}" \
|
||||||
|
set 3 esp on
|
||||||
#
|
#
|
||||||
parted "${device}" unit "${unit}" \
|
parted "${device}" \
|
||||||
mkpart "bios-${number}" 1 2
|
unit "${unit}" mkpart "bios-${number}" 1 2
|
||||||
parted "${device}" set 4 bios_grub on
|
parted "${device}" \
|
||||||
|
set 4 bios_grub on
|
||||||
done
|
done
|
||||||
#
|
#
|
||||||
number=0
|
number=0
|
||||||
for device in "${devices[@]}" ; do
|
for device in "${devices[@]}"; do
|
||||||
((number++))
|
((number++))
|
||||||
echo ; echo "#${number}: ${device}4"
|
echo
|
||||||
|
echo "#${number}: ${device}4"
|
||||||
# wipe bios
|
# wipe bios
|
||||||
dd \
|
dd \
|
||||||
if='/dev/zero' of="${device}4"
|
if='/dev/zero' of="${device}4"
|
||||||
done
|
done
|
||||||
#
|
#
|
||||||
number=0
|
number=0
|
||||||
for device in "${devices[@]}" ; do
|
for device in "${devices[@]}"; do
|
||||||
((number++))
|
((number++))
|
||||||
echo ; echo "#${number}: ${device}3"
|
echo
|
||||||
|
echo "#${number}: ${device}3"
|
||||||
# format esp
|
# format esp
|
||||||
dd \
|
dd \
|
||||||
if='/dev/zero' of="${device}3" bs='1M'
|
if='/dev/zero' of="${device}3" bs='1M'
|
||||||
|
@ -198,16 +207,17 @@ rescue_hetzner_wipe_8_8_0_init() {
|
||||||
done
|
done
|
||||||
#
|
#
|
||||||
number=0
|
number=0
|
||||||
for device in "${devices[@]}" ; do
|
for device in "${devices[@]}"; do
|
||||||
((number++))
|
((number++))
|
||||||
echo ; echo "#${number}: ${device}2"
|
echo
|
||||||
|
echo "#${number}: ${device}2"
|
||||||
# wipe boot
|
# wipe boot
|
||||||
dd status='progress' \
|
dd status='progress' \
|
||||||
if='/dev/zero' of="${device}2" bs='1G' count=1
|
if='/dev/zero' of="${device}2" bs='1G' count=1
|
||||||
done
|
done
|
||||||
#
|
#
|
||||||
members=()
|
members=()
|
||||||
for device in "${devices[@]}" ; do
|
for device in "${devices[@]}"; do
|
||||||
members+=("${device}2")
|
members+=("${device}2")
|
||||||
done
|
done
|
||||||
mdadm \
|
mdadm \
|
||||||
|
@ -231,16 +241,17 @@ rescue_hetzner_wipe_8_8_0_init() {
|
||||||
'/dev/md/boot' '/media/boot'
|
'/dev/md/boot' '/media/boot'
|
||||||
#
|
#
|
||||||
number=0
|
number=0
|
||||||
for device in "${devices[@]}" ; do
|
for device in "${devices[@]}"; do
|
||||||
((number++))
|
((number++))
|
||||||
echo ; echo "#${number}: ${device}1"
|
echo
|
||||||
|
echo "#${number}: ${device}1"
|
||||||
# wipe crypt head
|
# wipe crypt head
|
||||||
dd status='progress' \
|
dd status='progress' \
|
||||||
if='/dev/zero' of="${device}1" bs='1G' count=1
|
if='/dev/zero' of="${device}1" bs='1G' count=1
|
||||||
done
|
done
|
||||||
#
|
#
|
||||||
members=()
|
members=()
|
||||||
for device in "${devices[@]}" ; do
|
for device in "${devices[@]}"; do
|
||||||
members+=("${device}1")
|
members+=("${device}1")
|
||||||
done
|
done
|
||||||
mdadm \
|
mdadm \
|
||||||
|
@ -252,8 +263,8 @@ rescue_hetzner_wipe_8_8_0_init() {
|
||||||
--uuid '00000000:00000000:00000000:00000001' \
|
--uuid '00000000:00000000:00000000:00000001' \
|
||||||
"${members[@]}"
|
"${members[@]}"
|
||||||
# encrypt
|
# encrypt
|
||||||
echo "${passphrase}" \
|
echo "${passphrase}" |
|
||||||
| cryptsetup \
|
cryptsetup \
|
||||||
--verbose \
|
--verbose \
|
||||||
--batch-mode \
|
--batch-mode \
|
||||||
--type 'luks2' \
|
--type 'luks2' \
|
||||||
|
@ -266,8 +277,8 @@ rescue_hetzner_wipe_8_8_0_init() {
|
||||||
luksFormat \
|
luksFormat \
|
||||||
'/dev/md/crypt'
|
'/dev/md/crypt'
|
||||||
# open
|
# open
|
||||||
echo "${passphrase}" \
|
echo "${passphrase}" |
|
||||||
| cryptsetup luksOpen '/dev/md/crypt' 'crypt'
|
cryptsetup luksOpen '/dev/md/crypt' 'crypt'
|
||||||
}
|
}
|
||||||
|
|
||||||
rescue_hetzner_wipe_8_8_1_zero() {
|
rescue_hetzner_wipe_8_8_1_zero() {
|
||||||
|
@ -284,8 +295,8 @@ rescue_hetzner_wipe_8_8_2_make() {
|
||||||
echo -n 'PassPhrase: '
|
echo -n 'PassPhrase: '
|
||||||
read -r -s passphrase
|
read -r -s passphrase
|
||||||
# encrypt
|
# encrypt
|
||||||
echo "${passphrase}" \
|
echo "${passphrase}" |
|
||||||
| cryptsetup \
|
cryptsetup \
|
||||||
--verbose \
|
--verbose \
|
||||||
--batch-mode \
|
--batch-mode \
|
||||||
--type 'luks2' \
|
--type 'luks2' \
|
||||||
|
@ -298,8 +309,8 @@ rescue_hetzner_wipe_8_8_2_make() {
|
||||||
luksFormat \
|
luksFormat \
|
||||||
'/dev/md/crypt'
|
'/dev/md/crypt'
|
||||||
# open
|
# open
|
||||||
echo "${passphrase}" \
|
echo "${passphrase}" |
|
||||||
| cryptsetup luksOpen '/dev/md/crypt' 'crypt'
|
cryptsetup luksOpen '/dev/md/crypt' 'crypt'
|
||||||
# format crypt
|
# format crypt
|
||||||
mkfs.btrfs --force \
|
mkfs.btrfs --force \
|
||||||
--checksum 'sha256' \
|
--checksum 'sha256' \
|
||||||
|
@ -321,6 +332,6 @@ rescue_hetzner_wipe_8_8_2_make() {
|
||||||
rescue_hetzner_wipe_8_8_3_close() {
|
rescue_hetzner_wipe_8_8_3_close() {
|
||||||
umount '/media/boot'
|
umount '/media/boot'
|
||||||
#
|
#
|
||||||
umount '/media/crypt' \
|
umount '/media/crypt' &&
|
||||||
&& cryptsetup luksClose 'crypt'
|
cryptsetup luksClose 'crypt'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue