Warn and exit if scripts aren't run with sudo

This commit is contained in:
Andreas Zweili 2024-01-29 13:48:30 +01:00
parent 8fac0bf1a3
commit 1151291353
3 changed files with 20 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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