Remove bc dependency by replacing with expr
This commit is contained in:
parent
f4282842da
commit
e3b321a9d7
11
pishrink.sh
11
pishrink.sh
|
@ -22,11 +22,6 @@ if (( $? != 0 )); then
|
||||||
echo "ERROR: parted is not installed."
|
echo "ERROR: parted is not installed."
|
||||||
exit -4
|
exit -4
|
||||||
fi
|
fi
|
||||||
A=`which bc 2>&1`
|
|
||||||
if (( $? != 0 )); then
|
|
||||||
echo "ERROR: bc is not installed."
|
|
||||||
exit -5
|
|
||||||
fi
|
|
||||||
|
|
||||||
#Gather info
|
#Gather info
|
||||||
beforesize=`ls -lah $img | cut -d ' ' -f 5`
|
beforesize=`ls -lah $img | cut -d ' ' -f 5`
|
||||||
|
@ -53,7 +48,7 @@ umount $mountdir
|
||||||
#Shrink filesystem
|
#Shrink filesystem
|
||||||
e2fsck -f $loopback
|
e2fsck -f $loopback
|
||||||
minsize=`resize2fs -P $loopback | cut -d ':' -f 2 | tr -d ' '`
|
minsize=`resize2fs -P $loopback | cut -d ':' -f 2 | tr -d ' '`
|
||||||
minsize=`echo $minsize+20000 | bc`
|
minsize=`expr $minsize + 20000 | tr -d '\n'`
|
||||||
resize2fs -p $loopback $minsize
|
resize2fs -p $loopback $minsize
|
||||||
if [[ $? != 0 ]]; then
|
if [[ $? != 0 ]]; then
|
||||||
echo ERROR: resize2fs failed...
|
echo ERROR: resize2fs failed...
|
||||||
|
@ -67,8 +62,8 @@ sleep 1
|
||||||
|
|
||||||
#Shrink partition
|
#Shrink partition
|
||||||
losetup -d $loopback
|
losetup -d $loopback
|
||||||
partnewsize=`echo "$minsize * 4096" | bc`
|
partnewsize=`expr $minsize \* 4096 | tr -d '\n'`
|
||||||
newpartend=`echo "$partstart + $partnewsize" | bc`
|
newpartend=`expr $partstart + $partnewsize | tr -d '\n'`
|
||||||
part1=`parted $img rm 2`
|
part1=`parted $img rm 2`
|
||||||
part2=`parted $img unit B mkpart primary $partstart $newpartend`
|
part2=`parted $img unit B mkpart primary $partstart $newpartend`
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue