diff --git a/scripts/create-uefi.sh b/scripts/create-uefi.sh index 64a433f..328b4fb 100755 --- a/scripts/create-uefi.sh +++ b/scripts/create-uefi.sh @@ -1,6 +1,12 @@ #! /usr/bin/env nix-shell #! nix-shell -i bash -p parted +# Fail if $SUDO_USER is empty. +if [ -z "$SUDO_USER" ]; then + printf "This script must be run with sudo.\n" + exit 1 +fi + DISK=/dev/mmcblk0 set -e diff --git a/scripts/format-disk.sh b/scripts/format-disk.sh index bc2d618..1800c6f 100755 --- a/scripts/format-disk.sh +++ b/scripts/format-disk.sh @@ -1,9 +1,16 @@ #! /usr/bin/env nix-shell #! nix-shell -i bash -p parted -DISK=/dev/sdb set -e +# Fail if $SUDO_USER is empty. +if [ -z "$SUDO_USER" ]; then + printf "This script must be run with sudo.\n" + exit 1 +fi + +DISK=/dev/sdb + BOOT_PARTITION="$DISK"1 ROOT_PARTITION="$DISK"2 ROOT_DIR=/mnt/nixos diff --git a/scripts/rename-partitions.sh b/scripts/rename-partitions.sh index c7cd10d..83c1885 100755 --- a/scripts/rename-partitions.sh +++ b/scripts/rename-partitions.sh @@ -3,6 +3,12 @@ set -e +# Fail if $SUDO_USER is empty. +if [ -z "$SUDO_USER" ]; then + printf "This script must be run with sudo.\n" + exit 1 +fi + rename_boot_partition() { echo "Rename boot partition." fatlabel /dev/disk/by-label/BOOTTOFRMT BOOT