Compare commits

..

No commits in common. 'dev-ivo' and 'main' have entirely different histories.

  1. 12
      Dockerfile
  2. 41
      reinstall-magisk-on-lineageos

12
Dockerfile

@ -1,14 +1,10 @@
FROM python:3.9.15-slim-buster
FROM python:3.9.15-buster
RUN apt-get update
RUN apt-get install -y \
android-tools-adb \
android-tools-fastboot \
unzip \
curl \
git
RUN pip3 install protobuf \
six
android-tools-adb \
android-tools-fastboot
RUN pip3 install protobuf
COPY . /magisk
WORKDIR /magisk
CMD bash reinstall-magisk-on-lineageos

41
reinstall-magisk-on-lineageos

@ -2,19 +2,15 @@
set -e
print_message() {
printf "$1\n"
}
PHONE_ADB_SERIAL_NUMBER=${ADB_DEVICE} # The adb serial number can be found by running `adb devices`.
if [$PHONE_ADB_SERIAL_NUMBER = '']; then
PHONE_ADB_SERIAL_NUMBER=$(echo $(adb devices) | sed -rn 's/(^|(.* ))([^ ]*) device(( .*)|$)/\3/; T; p; q')
if [[ -z $PHONE_ADB_SERIAL_NUMBER ]]; then
print_message "ERROR: no phone connected or connection unauthorized"
exit 1
fi
fi
print_message() {
printf "$1\n"
}
check_phone_is_connected() {
if ! adb devices | grep --silent "$PHONE_ADB_SERIAL_NUMBER"; then
print_message "ERROR: phone '$PHONE_ADB_SERIAL_NUMBER' is not connected"
@ -42,7 +38,7 @@ get_device_downloads_page() {
}
get_build_url() {
curl --silent "$(get_device_downloads_page)" |
curl --no-progress-meter "$(get_device_downloads_page)" |
grep --only-matching --ignore-case \
"https://mirrorbits.lineageos.org/[^\"]*"$(
)"$(get_lineage_version)-signed.zip" |
@ -50,15 +46,12 @@ get_build_url() {
}
check_exists_latest_lineageos_build() {
if [[ -f "/tmp/lineageos.zip" ]]; then
# The --location lets curl follow the redirection.
curl --silent --location "$(get_build_url)?sha256" --output /tmp/lineageos.sha256
hash1=$( awk '{print $1}' /tmp/lineageos.sha256 )
hash2=$( sha256sum /tmp/lineageos.zip | awk '{print $1}' )
[[ -n $hash1 && -n $hash2 && $hash1 == $hash2 ]]
return
fi
false
# 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() {
@ -158,14 +151,15 @@ check_magisk_app() {
magisk_package_name_count=$(adb -s "$PHONE_ADB_SERIAL_NUMBER" shell pm list packages "$magisk_package_name" | wc -l)
if [ "${magisk_package_name_count}" -eq 1 ]
then
print_message "Magisk app seems to be installed on selected phone"
print_message " [OK] Magisk app seems to be installed on selected phone"
elif [ "${magisk_package_name_count}" -eq 0 ]
then
print_message "ERROR: Magisk app seems not installed on selected phone."
print_message " [ERROR] Magisk app seems not installed on selected phone. Exiting."
exit -1
else
print_message "ERROR: More than one Magisk app entry is present:"
print_message " [ERROR] More than one Magisk app entry is present:"
adb -s "$PHONE_ADB_SERIAL_NUMBER" shell pm list packages "$magisk_package_name"
print_message "Exiting."
exit -1
fi
}
@ -181,11 +175,10 @@ main() {
is_rooted_debugging_enabled
print_message "Checking on phone if Magisk is installed"
check_magisk_app
print_message "Checking if build archive already exists"
if check_exists_latest_lineageos_build; then
print_message "Build archive found, skipping download"
print_message "Build archive already exists, skipping download"
else
print_message "Build archive not found or hash mismatch, downloading from $(get_build_url)"
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"

Loading…
Cancel
Save