Warn and exit if scripts aren't run with sudo
This commit is contained in:
parent
8fac0bf1a3
commit
1151291353
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue