X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/Ventoy.git/blobdiff_plain/8cecdae8f9d7e1b77917e172c37cfd07907aeb71..966ed21de7dfd77dddfa26bab5c8b4af8a73c99e:/INSTALL/ExtendPersistentImg.sh diff --git a/INSTALL/ExtendPersistentImg.sh b/INSTALL/ExtendPersistentImg.sh index bd51912..5f8b852 100644 --- a/INSTALL/ExtendPersistentImg.sh +++ b/INSTALL/ExtendPersistentImg.sh @@ -1,11 +1,12 @@ -#!/bin/sh +#!/bin/bash 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,23 @@ 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 +else + if readlink /bin/sh | grep -q bash; then + : + else + exec /bin/bash $0 "__vbash__" "$@" + fi +fi + + file=$1 size=$2