Skip to content

Commit

Permalink
Shrinking magisk.img: only show results, no details
Browse files Browse the repository at this point in the history
  • Loading branch information
Pzqqt committed Feb 17, 2019
1 parent 35c1924 commit b5ec926
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions script/mount-magisk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ mountPath=$2

donescript=/tmp/mmr/script/done-script.sh
skscript=/tmp/mmr/script/shrink-magiskimg.sh
doskscript=/tmp/mmr/script/do-shrink.sh

is_mounted() { mountpoint -q "$1"; }

Expand Down Expand Up @@ -49,37 +50,21 @@ EOF
}

gen_shrink_script() {
cat > $skscript <<EOF
cat > $doskscript <<EOF
#!/sbin/sh
require_new_magisk() {
echo "*******************************"
echo " Please install Magisk v17.0+! "
echo "*******************************"
exit 1
}
if [ -f /data/adb/magisk/util_functions.sh ]; then
. /data/adb/magisk/util_functions.sh
elif [ -f /data/magisk/util_functions.sh ]; then
NVBASE=/data
. /data/magisk/util_functions.sh
else
require_new_magisk
exit 2
fi
unset ui_print
ui_print() { echo "\$1"; }
unset check_filesystem
check_filesystem() {
curSizeM=\`wc -c < \$1\`
curSizeM=\$((curSizeM / 1048576))
local DF=\`df -Pk \$2 | grep \$2\`
curUsedM=\`echo \$DF | awk '{ print int(\$3 / 1024) }'\`
curFreeM=\`echo \$DF | awk '{ print int(\$4 / 1024) }'\`
}
IMG=$IMG
MOUNTPATH=$mountPath
MAGISKLOOP=$loopDevice
Expand All @@ -94,17 +79,38 @@ is_mounted \$MOUNTPATH && {
losetup -d \$loopedB
}
rmdir \$MOUNTPATH || {
rmdir \$MOUNTPATH || exit 1
EOF
cat > $skscript <<EOF
#!/sbin/sh
$doskscript &>/dev/null
exitcode=\$?
if [ \$exitcode -eq 1 ]; then
echo ""
echo "! Failed to unmount magisk.img!"
echo ""
exit 1
}
fi
if [ \$exitcode -eq 2 ]; then
echo "*******************************"
echo " Please install Magisk v17.0+! "
echo "*******************************"
exit 2
fi
curSizeM=\`wc -c < $IMG\`
curSizeM=\$((curSizeM / 1048576))
echo ""
echo "- Shrinking $IMG to \${newSizeM}M"
echo "- Shrinking $IMG to \${curSizeM}M"
echo ""
EOF
chmod 0755 $doskscript
chmod 0755 $skscript
}

Expand Down

0 comments on commit b5ec926

Please sign in to comment.