From: Duje Mihanović Date: Tue, 28 Jun 2022 13:24:52 +0000 (+0200) Subject: nameless2disk: Check for root privileges X-Git-Url: https://git.dujemihanovic.xyz/%7B%7B?a=commitdiff_plain;h=d90a72853a84da09c139592fe04dd440291dbf9f;p=nameless-os.git nameless2disk: Check for root privileges --- diff --git a/nameless2disk b/nameless2disk index ddd8960..116c41f 100755 --- a/nameless2disk +++ b/nameless2disk @@ -3,6 +3,14 @@ BINARIES=( boot/x86/mbr boot/x86/vbr-fat32 boot/x86/stage3/LOADER.BIN kernel/kernel.elf ) +check_root() { + local user=$(whoami) + if [ $user != "root" ]; then + echo nameless2disk needs to be run as root! + exit 1 + fi +} + check_binaries() { for i in "${BINARIES[@]}"; do if ! [ -e $i ]; then @@ -92,6 +100,9 @@ install_blkdev() { [ -z $(command -v fdisk) ] && echo fdisk not found, is util-linux installed? && exit 127 [ -z $(command -v mkfs.fat) ] && echo mkfs.fat not found, is dosfstools installed? && exit 127 +# Check for root privileges. +check_root + # Make sure that Nameless has been compiled. check_binaries