Magisk/zip_static/roothelper/phh.sh

41 lines
776 B
Bash
Raw Normal View History

2016-10-02 22:34:50 +02:00
#!/system/bin/sh
LOGFILE=/cache/magisk.log
log_print() {
echo $1
echo "phh: $1" >> $LOGFILE
log -p i -t phh "$1"
}
launch_daemonsu() {
export PATH=$OLDPATH
# Switch contexts
echo "u:r:su_daemon:s0" > /proc/self/attr/current
# Start daemon
exec /magisk/phh/bin/su --daemon
}
2016-10-03 05:01:24 +02:00
# Disable the other root
[ -d "/magisk/zzsupersu" ] && touch /magisk/zzsupersu/disable
2016-10-02 22:34:50 +02:00
log_print "Live patching sepolicy"
/magisk/phh/bin/sepolicy-inject --live
# Expose the root path
log_print "Linking supath"
rm -rf /magisk/.core/bin
ln -s /magisk/phh/bin /magisk/.core/bin
# Run su.d
for script in /magisk/phh/su.d/* ; do
if [ -f "$script" ]; then
chmod 755 $script
log_print "su.d: $script"
$script
fi
done
log_print "Starting su daemon"
(launch_daemonsu &)