diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index f2e6d34..6991368 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -1,18 +1,18 @@ rescue_wipe_0_init_hetzner_8_8() { local device local devices=( - '/dev/sda' - '/dev/sdb' + "/dev/sda" + "/dev/sdb" ) local members local number local passphrase - local unit='mib' + local unit="mib" # read passphrase passphrase="$(read_passphrase)" # lsblk - echo -n 'WIPE' "${devices[@]}" '/?\ OR CANCEL /!\' + echo -n "WIPE" "${devices[@]}" "/?\\ OR CANCEL /!\\" read # number=0 @@ -53,7 +53,7 @@ rescue_wipe_0_init_hetzner_8_8() { echo "#${number}: ${device}4" # wipe bios dd \ - if='/dev/zero' of="${device}4" + if="/dev/zero" of="${device}4" done # number=0 @@ -63,7 +63,7 @@ rescue_wipe_0_init_hetzner_8_8() { echo "#${number}: ${device}3" # format esp dd \ - if='/dev/zero' of="${device}3" bs='1M' + if="/dev/zero" of="${device}3" bs="1M" mkfs.vfat \ -F 32 \ -S 4096 \ @@ -81,8 +81,8 @@ rescue_wipe_0_init_hetzner_8_8() { echo echo "#${number}: ${device}2" # wipe boot - dd status='progress' \ - if='/dev/zero' of="${device}2" bs='1G' count=1 + dd status="progress" \ + if="/dev/zero" of="${device}2" bs="1G" count=1 done # members=() @@ -90,24 +90,24 @@ rescue_wipe_0_init_hetzner_8_8() { members+=("${device}2") done mdadm \ - --create '/dev/md/boot' \ + --create "/dev/md/boot" \ --level 0 \ --metadata 1 \ - --name 'md:boot' \ + --name "md:boot" \ --raid-devices ${#devices[@]} \ - --uuid '00000000:00000000:00000000:00000002' \ + --uuid "00000000:00000000:00000000:00000002" \ "${members[@]}" # mkfs.btrfs --force \ - --checksum 'sha256' \ - --label 'boot' \ - --uuid '00000000-0000-0000-0000-00000000000b' \ - '/dev/md/boot' + --checksum "sha256" \ + --label "boot" \ + --uuid "00000000-0000-0000-0000-00000000000b" \ + "/dev/md/boot" # mount boot - mkdir --parents '/media/boot' + mkdir --parents "/media/boot" mount \ - --options 'autodefrag,compress-force=zstd' \ - '/dev/md/boot' '/media/boot' + --options "autodefrag,compress-force=zstd" \ + "/dev/md/boot" "/media/boot" # number=0 for device in "${devices[@]}"; do @@ -115,8 +115,8 @@ rescue_wipe_0_init_hetzner_8_8() { echo echo "#${number}: ${device}1" # wipe crypt head - dd status='progress' \ - if='/dev/zero' of="${device}1" bs='1G' count=1 + dd status="progress" \ + if="/dev/zero" of="${device}1" bs="1G" count=1 done # members=() @@ -124,30 +124,30 @@ rescue_wipe_0_init_hetzner_8_8() { members+=("${device}1") done mdadm \ - --create '/dev/md/crypt' \ + --create "/dev/md/crypt" \ --level 0 \ --metadata 1 \ - --name 'md:crypt' \ + --name "md:crypt" \ --raid-devices ${#devices[@]} \ - --uuid '00000000:00000000:00000000:00000001' \ + --uuid "00000000:00000000:00000000:00000001" \ "${members[@]}" # encrypt echo "${passphrase}" | cryptsetup \ --verbose \ --batch-mode \ - --type 'luks2' \ - --pbkdf 'argon2id' \ - --cipher 'aes-xts-plain64' \ + --type "luks2" \ + --pbkdf "argon2id" \ + --cipher "aes-xts-plain64" \ --iter-time 8192 \ --key-size 512 \ - --hash 'sha512' \ + --hash "sha512" \ --use-random \ luksFormat \ - '/dev/md/crypt' + "/dev/md/crypt" # open echo "${passphrase}" | - cryptsetup luksOpen '/dev/md/crypt' 'crypt' + cryptsetup luksOpen "/dev/md/crypt" "crypt" # passphrase unset passphrase } @@ -155,7 +155,7 @@ rescue_wipe_0_init_hetzner_8_8() { rescue_wipe_2_make_hetzner_8_8() { local passphrase # close - cryptsetup luksClose 'crypt' + cryptsetup luksClose "crypt" # read passphrase passphrase="$(read_passphrase)" # encrypt @@ -163,34 +163,34 @@ rescue_wipe_2_make_hetzner_8_8() { cryptsetup \ --verbose \ --batch-mode \ - --type 'luks2' \ - --pbkdf 'argon2id' \ - --cipher 'aes-xts-plain64' \ + --type "luks2" \ + --pbkdf "argon2id" \ + --cipher "aes-xts-plain64" \ --iter-time 8192 \ --key-size 512 \ - --hash 'sha512' \ + --hash "sha512" \ --use-random \ luksFormat \ - '/dev/md/crypt' + "/dev/md/crypt" # open echo "${passphrase}" | - cryptsetup luksOpen '/dev/md/crypt' 'crypt' + cryptsetup luksOpen "/dev/md/crypt" "crypt" # passphrase unset passphrase # format crypt mkfs.btrfs --force \ - --checksum 'sha256' \ - --label 'crypt' \ - --uuid '00000000-0000-0000-0000-00000000000c' \ - '/dev/mapper/crypt' + --checksum "sha256" \ + --label "crypt" \ + --uuid "00000000-0000-0000-0000-00000000000c" \ + "/dev/mapper/crypt" # mount crypt - mkdir --parents '/media/crypt' + mkdir --parents "/media/crypt" mount \ - --options 'autodefrag,compress-force=zstd' \ - '/dev/mapper/crypt' '/media/crypt' + --options "autodefrag,compress-force=zstd" \ + "/dev/mapper/crypt" "/media/crypt" # make swap file btrfs filesystem mkswapfile \ - --size '64g' \ - --uuid '00000000-0000-0000-0000-000000000005' \ - '/media/crypt/swap' + --size "64g" \ + --uuid "00000000-0000-0000-0000-000000000005" \ + "/media/crypt/swap" }