Skip to content
This repository has been archived by the owner on Dec 31, 2020. It is now read-only.

Commit

Permalink
6.1.5 - update
Browse files Browse the repository at this point in the history
Changelog:
- Magisk version detecting moved into runtime script instead of one-time check during install.
- Live loading sepolicy rules for legacy Magisk version from sepolicy.rule file
    Rewritten post-fs-data.sh and scripts.sh
- Added missing paths in uninstall.sh
- Upgrade to the latest module installer format
- Fixed some bugs.
  • Loading branch information
kam821 committed Jan 11, 2020
1 parent 1d3fb22 commit 86f183b
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 235 deletions.
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Declare files that will always have LF line endings on checkout.
META-INF/** text eol=lf
*.prop text eol=lf
*.sh text eol=lf
*.md text eol=lf

# Denote all files that are truly binary and should not be modified.
system/** binary
taichi binary
6 changes: 3 additions & 3 deletions META-INF/com/google/android/update-binary
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ if is_legacy_script; then
ui_print "- Setting permissions"
set_permissions
else
print_modname

unzip -o "$ZIPFILE" customize.sh -d $MODPATH >&2

if ! grep -q '^SKIPUNZIP=1$' $MODPATH/customize.sh 2>/dev/null; then
print_modname

ui_print "- Extracting module files"
unzip -o "$ZIPFILE" -x 'META-INF/*' -d $MODPATH >&2

Expand Down Expand Up @@ -170,4 +170,4 @@ $BOOTMODE || recovery_cleanup
rm -rf $TMPDIR

ui_print "- Done"
exit 0
exit 0
47 changes: 29 additions & 18 deletions common/post-fs-data.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
#!/system/bin/sh

# Do NOT assume where your module will be located.
# ALWAYS use $MODDIR if you need to know where this script
# and module is placed.
# This will make sure your module will still work
# if Magisk change its mount point in the future
MODDIR=${0%/*}

rm /data/misc/taichi
# This script will be executed in post-fs-data mode

WATCH_FILE="/data/misc/taichi"
ENFORCE_FILE="/data/misc/taichi_enforce"
LOG_FILE="/data/local/tmp/taichi.log"
SEPOLICY_FILE="${MODDIR}/sepolicy.rule"

rm -f "{WATCH_FILE}"
rm -f "{ENFORCE_FILE}"
rm -f "{LOG_FILE}"

[[ -f ${MODDIR}/sepolicy.rule ]] && exit 0
# Load utility functions
[ -f "/data/adb/magisk/util_functions.sh" ] && . /data/adb/magisk/util_functions.sh
[ "${MAGISK_VER_CODE}" -ge 20110 ] && exit 0

if [[ $(getprop ro.build.version.sdk) -ge 29 ]]; then
AB_UPDATE=$(getprop ro.build.ab_update)
SAR=$(getprop ro.build.system_root_image)
if [[ ${AB_UPDATE} != "true" ]] || ([[ ${AB_UPDATE} == "true" ]] && [[ ${SAR} == "false" ]]); then
touch /data/misc/taichi_enforce
setenforce 0
exit 0
fi
fi
AB_UPDATE=$(getprop ro.build.ab_update)
grep ' / ' /proc/mounts | grep -qv 'rootfs' && SAR="true" || SAR="false"
[ "${AB_UPDATE}" != "true" ] || ([ "${AB_UPDATE}" == "true" ] && [ "${SAR}" == "false" ]) && ENFORCE="true" || ENFORCE="false"

magiskpolicy --live "allow system_server system_server process { execmem }"\
"allow system_server apk_data_file file *"\
"allow system_server app_data_file file *"\
"allow system_server dalvikcache_data_file file { execute }"\
"allow system_server system_file file { execute_no_trans }"
if ([ $(getprop ro.build.version.sdk) -ge 29 ] && [ "${ENFORCE}" == "true" ]) || [ ! -f "${SEPOLICY_FILE}" ]; then
touch "${ENFORCE_FILE}" >&2
setenforce 0
else
grep -v '^#' < "${SEPOLICY_FILE}" | while read RULE; do
magiskpolicy --live "${RULE}"
done
fi
2 changes: 1 addition & 1 deletion common/sepolicy.rule
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ allow system_server system_server process { execmem }
allow system_server apk_data_file file *
allow system_server app_data_file file *
allow system_server dalvikcache_data_file file { execute }
allow system_server system_file file { execute_no_trans }
allow system_server system_file file { execute_no_trans }
52 changes: 17 additions & 35 deletions common/service.sh
Original file line number Diff line number Diff line change
@@ -1,52 +1,34 @@
#!/system/bin/sh
# Please don't hardcode /magisk/modname/... ; instead, please use $MODDIR/...
# This will make your scripts compatible even if Magisk change its mount point in the future
# Do NOT assume where your module will be located.
# ALWAYS use $MODDIR if you need to know where this script
# and module is placed.
# This will make sure your module will still work
# if Magisk change its mount point in the future
MODDIR=${0%/*}

# This script will be executed in late_start service mode
# More info in the main Magisk thread

TAICHI_LOG=/data/local/tmp/taichi.log
logcat > ${TAICHI_LOG} &
LOGCAT_PID=$!

log() {
echo "[$(date +"%H:%M:%S:%3N %d-%m-%Y")] $1" | tee -a ${TAICHI_LOG}
}
WATCH_FILE="/data/misc/taichi"
ENFORCE_FILE="/data/misc/taichi_enforce"

timeout=10
WATCH_FILE=/data/misc/taichi
while ((timeout > 0)) && [[ ! -f ${WATCH_FILE} ]];
do
while [ ! -f "${WATCH_FILE}" ] && [ "$timeout" -gt 0 ]; do
timeout=$((timeout-1))
sleep 1
((timeout -= 1))
done

if [[ ! -f ${WATCH_FILE} ]]; then
setprop ctl.restart zygote_secondary
if [ ! -f "${WATCH_FILE}" ]; then
setprop ctl.restart zygote_secondary >&2
else
rm ${WATCH_FILE}
rm -f "${WATCH_FILE}"
fi

max_wait=300
interval=1
BOOT_COMPLETED=false
while [[ "$max_wait" -gt 0 ]]; do
if [[ "$(getprop sys.boot_completed)" = "1" ]];then
BOOT_COMPLETED=true
log "BOOT_COMPLETED"
break
fi
sleep ${interval}
log "WAIT FOR BOOT_COMPLETE"
max_wait=$((max_wait-1))
until [ $(getprop sys.boot_completed) -eq 1 ]; do
sleep 1
done

ENFORCE_FILE=/data/misc/taichi_enforce
if [[ -f ${ENFORCE_FILE} ]] && [[ "${BOOT_COMPLETED}" = "true" ]];then
log "RESTORE SELinux"
rm ${ENFORCE_FILE}
if [ -f "${ENFORCE_FILE}" ]; then
rm -f "${ENFORCE_FILE}"
setenforce 1
fi

kill ${LOGCAT_PID}
fi
34 changes: 34 additions & 0 deletions customize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Set what you want to display when installing your module
print_modname() {
ui_print "*******************************"
ui_print " TaiChi - Magisk "
ui_print " "
ui_print " by @weishu "
ui_print " "
ui_print " https://taichi.cool "
ui_print "*******************************"
}

on_install() {
ui_print "- Extracting module files"
unzip -oj "$ZIPFILE" taichi module.prop uninstall.sh 'common/*' -d $MODPATH >&2
unzip -o "$ZIPFILE" 'system/*' -d $MODPATH >&2

chmod 0100 $MODPATH/taichi
$MODPATH/taichi $MODPATH $MODPATH
rm -f $MODPATH/taichi 2>&1 >/dev/null

[ $? -eq 0 ] && ui_print "Installed." || abort "Install error: $?"
}

set_permissions() {
ui_print "- Setting permissions"
# The following is the default rule, DO NOT remove
set_perm_recursive $MODPATH 0 0 0755 0644
# set_perm $MODPATH/system/lib/libmedia_legacy.so 0 0 0644 u:object_r:system_lib_file:s0
}

SKIPUNZIP=1
print_modname
on_install
set_permissions
171 changes: 0 additions & 171 deletions install.sh

This file was deleted.

7 changes: 3 additions & 4 deletions module.prop
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
id=taichi
name=Taichi
version=v6.1.4
versionCode=614
version=v6.1.5
versionCode=615
author=weishu
description=Use Xposed modules with Taichi in Magisk.
minMagisk=17000
description=Use Xposed modules with Taichi in Magisk.
Loading

0 comments on commit 86f183b

Please sign in to comment.