A simple bash automation script for re-rooting /e/OS, Lineage, or similar using Magisk.
When using a custom Android ROM, updating your ROM will lose root privileges. You can patch your ROM with Magisk, but following the steps every time there's an update gets tedious and confusing.
Using a "wizard" to streamline the update process makes it go faster and less error-prone - just run the script after your phone has updated to the new ROM, and you'll download, patch, and flash the update to regain root.
Since I use /e/OS, it is currently hardcoded for that. If you want to use LineageOS, you'll need to change the download URL or manually download your update .zips.
It is also configured to look for OnePlus 9 firmware specifically, codename "lemonade". That will also need to be changed if you want to use this for a different device.
- Downloads the .zip from the appropriate source. Can be skipped with a flag. (for my purposes, it downloads /e/OS for the OnePlus 9 aka Lemonade device.)
- Checks whether you have a device visible to the Android Debug Bridge (adb). 2b. If device is not found, the script has a fallback called "manual" mode which will guide the user through the process without automating via adb.
- Uploads the .zip from the current working directory to your device's Download folder (adb push).
- Instructs the user to patch the .zip with the Magisk app and waits for confirmation before continuing.
- Downloads the patched .zip that Magisk created. Waits for the user to enter fastboot mode.
- Flashes the patched zip to the device (on the alternate slot so you can fallback if needed).
Then, reboot your device and you'll have root again.
-h | --help Show the help menu. Also the default option if no argument is given.
-r | --release Specify OS Release Number.
-s | --skip-download Skip downloading the .zip from e/OS/'s website - useful for testing or if you downloaded it already.
- a flag for specifying the name of your device (not just lemonade)
- a flag for specifying whether to use /e/OS or LineageOS (or others? Branch off?)
- Some sort of config file where someone could specify arbitrary API layout for their ROM provider's website
- a safety feature where the script reverts to the unchanged boot slot for you if the update fails for some reason
Ok bye