I'm trying to run this part of my code in a magisk module on android so its using android mksh shell.
My goal is to skip the Fontchanger folder in $MODULESPATH since Fontchanger is my module, and if the folder is not fontchanger and it doesn't have a file named disable and it has a system/fonts directory inside $i, only then should the code run. However when I go install my magisk module zip, it runs this code detecting Fontchanger in $MODULESPATH and aborts. This is the opposite of what I need. It needs to skip the Fontchanger folder.
This is the code
imageless_magisk && MODULESPATH=/data/adb/modules || MODULESPATH=/sbin/.core/img
for i in $MODULESPATH/*; do
if [ $i != Fontchanger ]; then
if [ ! -f $i/disable ]; then
if [ -d $i/system/fonts ]; then
NAME=$(get_var $i/module.prop)
ui_print " [!] "
ui_print " [!] Module editing fonts detected [!] "
ui_print " [!] Module - $NAME [!] "
ui_print " [!] "
abort
fi
fi
fi
done
imageless_magisk && MODULESPATH=/data/adb/modules_update || MODULESPATH=/sbin/.core/img
for i in $MODULESPATH/*; do
if [ $i != Fontchanger ]; then
if [ ! -f $i/disable ]; then
if [ -d $i/system/fonts ]; then
NAME=$(get_var $i/module.prop)
ui_print " [!] "
ui_print " [!] Module editing fonts detected [!] "
ui_print " [!] Module - $NAME [!] "
ui_print " [!] "
abort
fi
fi
fi
done
get_var() { sed -n 's/^name=//p' ${1}; }
imageless_magisk() {
[ $MAGISK_VER_CODE -gt 18100 ]
return $?
}
Thanks in advance for any and all help
MODULESPATH=/data/adb/modules
imageless_magisk || MODULESPATH=/sbin/.core/img
for i in $MODULESPATH*/*; do
if [[ $i != *Fontchanger ]] && [ ! -f $i/disable ] && [ -d $i/system/fonts ]; then
NAME=$(get_var $i/module.prop)
ui_print " [!] "
ui_print " [!] Module editing fonts detected [!] "
ui_print " [!] Module - $NAME [!] "
ui_print " [!] "
cancel
fi
done
This is the code we came up with that will work and is set - euxo pipefail compatible as well and works on Android in a magisk environment