]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
Adding root user check to ExtendPersistentImg (as in CreatePersistentImg) (#2633)
authorZhymabek Roman <61125068+ZhymabekRoman@users.noreply.github.com>
Sun, 19 May 2024 08:35:22 +0000 (13:35 +0500)
committerGitHub <noreply@github.com>
Sun, 19 May 2024 08:35:22 +0000 (16:35 +0800)
* Adding root user check & Enhance help info

* Update root user check

INSTALL/ExtendPersistentImg.sh

index 87afd08126cabf3ec2df79dd32b2c314689fcf80..5f8b852f5f6330e2cfe6eac232573bb8affdcbc9 100644 (file)
@@ -4,8 +4,9 @@ print_usage() {
     echo 'Usage:  ExtendPersistentImg.sh file size'
     echo '   file   persistent dat file'
     echo '   size   extend size in MB'
-    echo 'Example:'
-    echo '   sh ExtendPersistentImg.sh ubuntu.dat 2048'
+    echo 'Examples:'
+    echo '   sh ExtendPersistentImg.sh ubuntu.dat 2048 - This command would extend ubuntu.dat by 2048MB (2GB)'
+    echo '   sh ExtendPersistentImg.sh ubuntu.dat -2048 - This command reduces ubuntu.dat by 2048MB (-2GB)'
     echo ''
 }
 
@@ -19,6 +20,11 @@ if [ -z "$2" ]; then
     exit 1
 fi
 
+uid=$(id -u)
+if [ $uid -ne 0 ]; then
+    print_err "Please use sudo or run the script as root."
+    exit 1
+fi
 
 if [ "$1" = "__vbash__" ]; then
     shift