no need to run as root on macOS, cause we're installing the needed ext2 tools in a user readable path
This commit is contained in:
parent
b4cd7ec07a
commit
afe05729d8
13
pishrink.sh
13
pishrink.sh
|
@ -2,14 +2,6 @@
|
||||||
|
|
||||||
usage() { echo "Usage: $0 imagefile.img [newimagefile.img]"; exit -1; }
|
usage() { echo "Usage: $0 imagefile.img [newimagefile.img]"; exit -1; }
|
||||||
|
|
||||||
while getopts ":s" opt; do
|
|
||||||
case "${opt}" in
|
|
||||||
s) should_skip_autoexpand=true ;;
|
|
||||||
*) usage ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
shift $((OPTIND-1))
|
|
||||||
|
|
||||||
#Args
|
#Args
|
||||||
img="$1"
|
img="$1"
|
||||||
|
|
||||||
|
@ -21,10 +13,6 @@ if [[ ! -f "$img" ]]; then
|
||||||
echo "ERROR: $img is not a file..."
|
echo "ERROR: $img is not a file..."
|
||||||
exit -2
|
exit -2
|
||||||
fi
|
fi
|
||||||
if (( EUID != 0 )); then
|
|
||||||
echo "ERROR: You need to be running as root."
|
|
||||||
exit -3
|
|
||||||
fi
|
|
||||||
|
|
||||||
#Check that what we need is installed
|
#Check that what we need is installed
|
||||||
for command in parted losetup tune2fs md5sum e2fsck resize2fs; do
|
for command in parted losetup tune2fs md5sum e2fsck resize2fs; do
|
||||||
|
@ -58,7 +46,6 @@ tune2fs_output=$(tune2fs -l "$loopback")
|
||||||
currentsize=$(echo "$tune2fs_output" | grep '^Block count:' | tr -d ' ' | cut -d ':' -f 2)
|
currentsize=$(echo "$tune2fs_output" | grep '^Block count:' | tr -d ' ' | cut -d ':' -f 2)
|
||||||
blocksize=$(echo "$tune2fs_output" | grep '^Block size:' | tr -d ' ' | cut -d ':' -f 2)
|
blocksize=$(echo "$tune2fs_output" | grep '^Block size:' | tr -d ' ' | cut -d ':' -f 2)
|
||||||
|
|
||||||
|
|
||||||
#Make sure filesystem is ok
|
#Make sure filesystem is ok
|
||||||
e2fsck -p -f "$loopback"
|
e2fsck -p -f "$loopback"
|
||||||
minsize=$(resize2fs -P "$loopback" | cut -d ':' -f 2 | tr -d ' ')
|
minsize=$(resize2fs -P "$loopback" | cut -d ':' -f 2 | tr -d ' ')
|
||||||
|
|
Loading…
Reference in New Issue