[Miscellaneous Android Development] diplomatic:
Up-to-date bootless root for Magisk 20+!

Get full root on a locked device with the current Magisk!​

This script uses mtk-su to launch Magisk on compatible devices, including locked down ones! It runs entirely from the data partition--no need to modify the firmware. Root is available for any app that wants it.

NEW FEATURES

MagiskHide & SafetyNet pass now work under Android 9

Modules pass minimum version check

Faster and more efficient loading

Logging works properly

General warnings: Read this whole post before starting. Only use this on devices on which you can recover the firmware outside of Android such as recovery mode, download tool, etc. While precautions have been taken to block flashing of the boot partition, not everything has or can be accounted for. You must anticipate when a superuser action might alter your boot or system partitions and avoid doing that command.

Do not try to update Magisk through Magisk Manager's Direct Install.

Even though testing has shown that that feature will fail, it might succeed in some cases.

REQUIREMENTS

Mastery and comfort with using the Thanks button

A device compatible with mtk-su in app mode

Recent mtk-su from OP

Magisk v19.4 to v21.4 only (not compatible with 22.0+)

Magisk not installed on device

LIMITATIONS

Cannot modify boot partition unless bootloader is unlocked

Cannot modify system/vendor partitions unless boot partition is altered

Your mileage may vary with modules

INSTRUCTIONS

Make sure you meet all the requirements, including the first one.

Download and install the init.d scripts support app. Make sure this app gets installed on the internal storage, not the external SD. (Support the developer.)

Make a folder named 'init.d' on your internal storage. Also make a 'bin' folder inside 'init.d'. Set up the init.d app up like this:

Try to acquire root privileges: unchecked

Run scripts at boot time: checked

Execution delay: No delay

Selected folder: /storage/emulated/0/init.d

Execute all files: unchecked

Remember that the folder structure has to be exactly as described, unless you manually edit the path in the script. You can also, in principle, use a different app if you want, but in that case you have to edit the package name path in the script as well.

Download and install the latest Magisk Manager apk. Make sure this app is installed on the internal storage, not external SD.

Download the current magisk-boot script, unzip it, and put magisk-boot.sh inside your /sdcard/init.d folder.

Download the current mtk-su zip and put your appropriate mtk-su file in your /sdcard/init.d/bin folder.

Download a Magisk zip package (19.4 to 21.4). Extract either arm/magiskinit64 or arm/magiskinit file and move/rename it to /sdcard/init.d/bin/magiskinit. (i.e. magiskinit64 should be renamed to magiskinit.) Pick one of 64-bit or 32-bit builds that corresponds to your kernel architecture. That is the only file you will need from that zip. (Support the developer.)

Now you should be ready to launch the Magisk core. Either reboot or tap 'Run scripts now'. The process will take a few seconds before telling you that 1 script has finished. If it ran successfully, last execution result will show something like this:

Temporary root by diplomatic@XDA
Home URL:
https://xdaforums.com/android/development/amazing-temp-root-mediatek-armv8-t3922213
--------------------------------------------------
/data/data/com.ryosoftware.initd/files/bin

UID: 0 cap: 3fffffffff selinux: permissive
Load policy from: /sys/fs/selinux/policy
20.3:MAGISK (20300)
client: launching new main daemon process

On Android 9, you may see a 'Segmentation fault' if using v20.3+. This crash does not affect functionality. You can install v20.2 to avoid it.

If you get a different result, then something may have gone wrong. Report problems here, except for errors about incompatible or unsupported platform.

At this point, you should be able to call 'su' or do a root request from an app and get a prompt.

When you open Magisk Manager, it will prompt you with Requires Additional Setup. On this window, you can tap Yes. This is safe.

Never try to do a direct-install Magisk Update on a locked device. To update Magisk, do so manually. Simply download the latest Magisk package and extract its magiskinit(64) file to the init.d/bin directory.

If upgrading from the old Magisk 18.x suboot method, you may need to clear your /data/adb directory in temp root shell before modules will work.

DOWNLOAD (UPDATED 2020-04-02)

magisk-boot.zip

FAQ

My init.d app does not start at boot time

It may be that your OS is not allowing the app to run in the background. Some OSs are too aggressive in managing background apps. Look in Settings for any background management or battery optimization or similar features, and disable them for the init.d app. The same tweak could benefit Magisk Manager.

My Magisk modules will not load properly. What is going on?

This method can only launch root after the init.d app starts up and runs the script. This is late in the boot cycle. Up to that point, root is not available. Unfortunately, many Magisk modules need to be loaded early in the boot process to work properly. I don't think there is much that can be done about that. (Perhaps a warm reboot would help, but that would cause problems of its own.)

Can I modify or reimplement the magisk-boot script and distribute it?

Yes, absolutely. You may do whatever you want with magisk-boot.sh. However, you may not distribute the mtk-su zip or binary. Instead, please ask your users to download the latest release from this thread.