From b8838b305dee6f62a5218bf94df5db547672362b Mon Sep 17 00:00:00 2001 From: Zhymabek Roman <61125068+ZhymabekRoman@users.noreply.github.com> Date: Sun, 19 May 2024 13:35:22 +0500 Subject: [PATCH] Adding root user check to ExtendPersistentImg (as in CreatePersistentImg) (#2633) * Adding root user check & Enhance help info * Update root user check --- INSTALL/ExtendPersistentImg.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/INSTALL/ExtendPersistentImg.sh b/INSTALL/ExtendPersistentImg.sh index 87afd081..5f8b852f 100644 --- a/INSTALL/ExtendPersistentImg.sh +++ b/INSTALL/ExtendPersistentImg.sh @@ -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