Compare commits

..

7 Commits

  1. 4
      Dockerfile
  2. 15
      README.md
  3. 20
      reinstall-magisk-on-lineageos

4
Dockerfile

@ -1,11 +1,9 @@
FROM debian:stable-slim
FROM python:3.9.15-buster
RUN apt-get update
RUN apt-get install -y \
android-tools-adb \
android-tools-fastboot \
python3 \
python3-pip
RUN pip3 install protobuf
COPY . /magisk
WORKDIR /magisk

15
README.md

@ -1,5 +1,7 @@
# Reinstall Magisk on Lineageos
This is a fork.
This little bash script is used to reinstall magisk, which gets uninstalled after each LineageOS update.
Before I had to patch once more the boot using the Magisk app doing all the steps manually, making some mistakes along the way. Now it takes less than 3 minutes to reinstall magisk (virtually all the time is taken by the download), and without any intervention on my part.
@ -15,11 +17,22 @@ Moreover it needs root privileges on your phone to run.
So it may screw up both your computer and your phone, so I invite you to check its source code before running it and using it at your own risks!
## Docker
We use docker to make it fastly reproducible.
Steps:
1. Build <br>
```docker build -t magiskupdate .```
2. Run <br>
```docker run --env ADB_DEVICE=<PUT YOUR ADB ADDR HERE> magiskupdate```
## Bash
Bash is one of the standard shells on Linux and MacOS systems.
If on Windows, you can use the [Windows Subsystem for Linux](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux) to run it. See [this guide](https://docs.microsoft.com/en-us/windows/wsl/install) to install it.
If on Windows, you should run linux.
## Installation

20
reinstall-magisk-on-lineageos

@ -42,6 +42,15 @@ get_build_url() {
head -1
}
check_exists_latest_lineageos_build() {
# The --location lets curl follow the redirection.
curl --location "$(get_build_url)?sha256" --output /tmp/lineageos.sha256
hash1=$( awk '{print $1}' lineageos.sha256 )
hash2=$( sha256sum lineageos.zip | awk '{print $1}' )
[[ "$hash1" =~ "$hash2" ]]
return
}
download_latest_lineageos_build() {
# The --location lets curl follow the redirection.
curl --location "$(get_build_url)" --output /tmp/lineageos.zip
@ -63,10 +72,6 @@ extract_boot_image_from_file_based_ota() {
exit 1
}
install_python_protobuf() {
sudo python3 -m pip install protobuf
}
extract_payload_from_payload_based_ota() {
unzip -od /tmp /tmp/lineageos.zip payload.bin
}
@ -76,11 +81,10 @@ generate_random_alnum_string_of_length_6() {
}
extract_boot_image_from_payload_file() {
install_python_protobuf
# For cases in which the repo has already been cloned, I prefer to create a random directory name to clone into, instead of deleting any file or directory on the user's machine.
scripts_directory_name="scripts_$(generate_random_alnum_string_of_length_6)"
git clone https://github.com/LineageOS/scripts /tmp/$scripts_directory_name
python /tmp/$scripts_directory_name/update-payload-extractor/extract.py --partitions boot --output_dir /tmp/ /tmp/payload.bin
python3 /tmp/$scripts_directory_name/update-payload-extractor/extract.py --partitions boot --output_dir /tmp/ /tmp/payload.bin
}
extract_boot_image_from_payload_based_ota() {
@ -168,8 +172,12 @@ main() {
is_rooted_debugging_enabled
print_message "Checking on phone if Magisk is installed"
check_magisk_app
if check_exists_latest_lineageos_build; then
print_message "Build archive already exists, skipping download"
else
print_message "Downloading build archive from $(get_build_url)"
download_latest_lineageos_build
fi
print_message "Extracting 'boot.img' from build archive in /tmp/boot.img"
extract_boot_image
print_message "Copying from PC to phone the boot image in /sdcard/Download/boot.img"

Loading…
Cancel
Save