Skip to content

Commit

Permalink
update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
j-hc committed Mar 24, 2024
1 parent 1ab080b commit 818e99a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
29 changes: 25 additions & 4 deletions scripts/customize.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# shellcheck disable=SC2148,SC2086
ui_print ""
${MODPATH:?}

if [ $ARCH = "arm" ]; then
#arm
Expand All @@ -20,11 +21,17 @@ else
fi
set_perm_recursive $MODPATH/bin 0 0 0755 0777

su -M -c "grep __PKGNAME /proc/mounts" | while read -r line; do
if su -M -c true >/dev/null 2>/dev/null; then
alias mm='su -M -c'
else
alias mm='nsenter -t1 -m'
fi

mm grep __PKGNAME /proc/mounts | while read -r line; do
ui_print "* Un-mount"
mp=${line#* }
mp=${mp%% *}
su -M -c "umount -l ${mp%%\\*}"
mm umount -l ${mp%%\\*}
done
am force-stop __PKGNAME

Expand Down Expand Up @@ -55,7 +62,8 @@ if BASEPATH=$(pm path __PKGNAME); then
INS=false
fi
fi
if [ $INS = true ]; then

install() {
if [ ! -f $MODPATH/__PKGNAME.apk ]; then
abort "ERROR: Stock __PKGNAME apk was not found"
fi
Expand All @@ -74,6 +82,11 @@ if [ $INS = true ]; then
abort "$op"
fi
if ! op=$(pm install-commit "$SES" 2>&1); then
if echo "$op" | grep INSTALL_FAILED_VERSION_DOWNGRADE; then
ui_print "* INSTALL_FAILED_VERSION_DOWNGRADE. Uninstalling..."
pm uninstall -k --user 0 __PKGNAME
return 1
fi
ui_print "ERROR: install-commit failed"
abort "$op"
fi
Expand All @@ -84,7 +97,15 @@ if [ $INS = true ]; then
else
abort "ERROR: install __PKGNAME manually and reflash the module"
fi
}
if [ $INS = true ]; then
if ! install; then
if ! install; then
abort
fi
fi
fi

BASEPATHLIB=${BASEPATH}/lib/${ARCH}
if [ -z "$(ls -A1 ${BASEPATHLIB})" ]; then
ui_print "* Extracting native libs"
Expand All @@ -103,7 +124,7 @@ mkdir -p $NVBASE/rvhc
RVPATH=$NVBASE/rvhc/${MODPATH##*/}.apk
mv -f $MODPATH/base.apk $RVPATH

if ! op=$(su -M -c "mount -o bind $RVPATH $BASEPATH/base.apk" 2>&1); then
if ! op=$(mm mount -o bind $RVPATH $BASEPATH/base.apk 2>&1); then
ui_print "ERROR: Mount failed!"
ui_print "$op"
fi
Expand Down
4 changes: 2 additions & 2 deletions scripts/service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sleep 5

err() {
[ ! -f $MODDIR/err ] && cp $MODDIR/module.prop $MODDIR/err
sed -i "s/^des.*/description=⚠️ Module is inactive: '${1}'/g" $MODDIR/module.prop
sed -i "s/^des.*/description=⚠️ Needs reflash: '${1}'/g" $MODDIR/module.prop
}

if [ $svcl = 0 ]; then
Expand All @@ -40,7 +40,7 @@ if [ $svcl = 0 ]; then
err "version mismatch (installed:${VERSION}, module:__PKGVER)"
fi
else
err "invalid installation"
err "zygote crashed"
fi
else
err "app not installed"
Expand Down

0 comments on commit 818e99a

Please sign in to comment.