From 71b170e46fe2e6422ef469e599829f431bfca632 Mon Sep 17 00:00:00 2001 From: Wallun Date: Thu, 9 Dec 2021 14:10:02 +0100 Subject: [PATCH] ci(pre-commit): add shellcheck hook --- .pre-commit-config.yaml | 6 ++++++ deploy.sh | 19 +++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e2901f9..9076f1b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,6 +16,12 @@ repos: - id: end-of-file-fixer - id: fix-byte-order-marker + - repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.8.0.1 + hooks: + - id: shellcheck + args: [ -x ] + - repo: https://github.com/jorisroovers/gitlint rev: v0.16.0 hooks: diff --git a/deploy.sh b/deploy.sh index 38a9775..72dd459 100644 --- a/deploy.sh +++ b/deploy.sh @@ -51,6 +51,7 @@ if [[ ! -f "${CONFIG_FILE}" ]]; then echo "${CONFIG_FILE} does not exist" exit 10; else + # shellcheck source=config source "${CONFIG_FILE}"; if [[ -z "${PASSPHRASE}" ]]; then echo "PASSPHRASE is not defined"; @@ -129,7 +130,7 @@ lvcreate -l 100%FREE vgos -n root # Create filesystems mkfs.ext4 -F /dev/vgos/root; -if [[ "{MODE}" == "bios" ]]; then +if [[ "${MODE}" == "bios" ]]; then mkfs.ext2 -F "${BOOT_PARTITION}"; else mkfs.fat -F32 "${BOOT_PARTITION}" @@ -164,7 +165,7 @@ nano git man-db man-pages texinfo lvm2 genfstab -U /mnt >> /mnt/etc/fstab # Configure system-resolved -cd /mnt/etc; +cd /mnt/etc || exit; rm -f resolv.conf; ln -sf ../run/systemd/resolve/resolv.conf resolv.conf @@ -258,9 +259,13 @@ fi; arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg; # /etc/default/grub -CRYPTDEVICE=$(ls -lh /dev/disk/by-uuid/ \ - | grep $(basename "${ENCRYPTED_PARTITION}") \ - | awk '{print "cryptdevice=UUID="$9":cryptlvm"}') +CRYPTDEVICE="" +DISK_UUID_LIST=$(find /dev/disk/by-uuid -type l) +for DISK_UUID in ${DISK_UUID_LIST}; do + if [[ "$(realpath "$DISK_UUID")" == "${ENCRYPTED_PARTITION}" ]]; then + CRYPTDEVICE="cryptdevice=UUID=$(basename "${DISK_UUID}"):cryplvm" + fi; +done IP="ip=::::${HOSTNAME}:eth0:dhcp netconf_timeout=10" ROOT="root=/dev/vgos/root" PRELOAD_MODULES="part_gpt part_msdos lvm" @@ -295,10 +300,8 @@ arch-chroot /mnt dropbearkey -t ecdsa -f /etc/dropbear/dropbear_ecdsa_host_key arch-chroot /mnt dropbearkey -t ed25519 -f /etc/dropbear/dropbear_ed25519_host_key arch-chroot /mnt sed -i "s/-E -s -j -k/-E -s -j -k -p 222/g" /usr/lib/initcpio/hooks/dropbear -NET_MODULE=$(ls -l /sys/class/net/eth0/device/driver | awk -F"/" '{print $NF}') +NET_MODULE=$(realpath /sys/class/net/eth0/device/driver | awk -F"/" '{print $NF}') arch-chroot /mnt sed -i "s/^MODULES=()/MODULES=(${NET_MODULE})/g" /etc/mkinitcpio.conf arch-chroot /mnt mkinitcpio -P; arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg; - -exit;