Compare commits

..

19 Commits

Author SHA1 Message Date
Ivo Oliveira Capanema 4d4b1b6cfa better error message 2 years ago
Ivo Oliveira Capanema 716ed4adbe remove debug print message; added curl silent 2 years ago
Ivo Oliveira Capanema 56980bd12e trying to fix six module dependency - 2nd try 2 years ago
Ivo Oliveira Capanema f51bf593da trying to fix six module dependency 2 years ago
Ivo Oliveira Capanema 7a002b3f4d dockerfile: add git package 2 years ago
Ivo Oliveira Capanema ee7dd09709 fix curl wrong option 2 years ago
Ivo Oliveira Capanema a6b24ea0b6 dockerfile: add curl and unzip packages 2 years ago
Ivo Oliveira Capanema d5e49e686c fix check build archive exists logic 2 years ago
Ivo Oliveira Capanema 3d15d5369b added quotes to if check 2 years ago
Ivo Oliveira Capanema 5ab69f335f changed print_messagem position 2 years ago
Ivo Oliveira Capanema 7336ccb08a fix wrong option on checking empty variable 2 years ago
Ivo Oliveira Capanema e179876da7 fix syntax error 2 years ago
Ivo Oliveira Capanema b789b9aef8 standardized messages 2 years ago
Ivo Oliveira Capanema f1f33ae197 added adb serial found check 2 years ago
Ivo Oliveira Capanema c9e2104e30 dockerfile: remove -q option 2 years ago
Ivo Oliveira Capanema 66c9ae339b Merge branch 'main' of https://git.lgoon.xyz/gabriel/magisk-update into dev-ivo 2 years ago
Ivo Oliveira Capanema d43498db87 improved build archive existance verification 2 years ago
Ivo Oliveira Capanema 451684b8df dockerfile: changed image to slim version; added suppress warnings on pip install 2 years ago
gabriel 9952a3cf20 Merge branch 'main' into dev-ivo 2 years ago
  1. 10
      Dockerfile
  2. 37
      reinstall-magisk-on-lineageos

10
Dockerfile

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

37
reinstall-magisk-on-lineageos

@ -2,15 +2,19 @@
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"
@ -38,7 +42,7 @@ get_device_downloads_page() {
}
get_build_url() {
curl --no-progress-meter "$(get_device_downloads_page)" |
curl --silent "$(get_device_downloads_page)" |
grep --only-matching --ignore-case \
"https://mirrorbits.lineageos.org/[^\"]*"$(
)"$(get_lineage_version)-signed.zip" |
@ -46,12 +50,15 @@ get_build_url() {
}
check_exists_latest_lineageos_build() {
if [[ -f "/tmp/lineageos.zip" ]]; then
# 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" ]]
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
}
download_latest_lineageos_build() {
@ -151,15 +158,14 @@ 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 " [OK] Magisk app seems to be installed on selected phone"
print_message "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. Exiting."
print_message "ERROR: Magisk app seems not installed on selected phone."
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
}
@ -175,10 +181,11 @@ 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 already exists, skipping download"
print_message "Build archive found, skipping download"
else
print_message "Downloading build archive from $(get_build_url)"
print_message "Build archive not found or hash mismatch, downloading from $(get_build_url)"
download_latest_lineageos_build
fi
print_message "Extracting 'boot.img' from build archive in /tmp/boot.img"

Loading…
Cancel
Save