-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(first-boot): install gapps and root device
- Loading branch information
Showing
9 changed files
with
123 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,7 @@ Thumbs.db | |
|
||
# Ignore IDE files | ||
.vscode/ | ||
.idea/ | ||
.idea/ | ||
|
||
# Docker compose data | ||
data/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
services: | ||
dockerify-android: | ||
image: dockerify-android | ||
ports: | ||
- "5555:5555" | ||
volumes: | ||
- ./data:/data | ||
- ./extras:/extras | ||
- ./patch/ramdisk.img:/opt/android-sdk/system-images/android-29/default/x86_64/ramdisk.img | ||
- ./patch/ramdisk.img.backup:/opt/android-sdk/system-images/android-29/default/x86_64/ramdisk.img.backup | ||
environment: | ||
- DNS=1.1.1.1 | ||
- RAM_SIZE=8192 | ||
privileged: true | ||
devices: | ||
- /dev/kvm | ||
container_name: dockerify-android |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# ignore added magisk modules | ||
*.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,84 @@ | ||
#!/bin/bash | ||
|
||
# Wait until the emulator is listed in adb devices | ||
RETRY_COUNT=0 | ||
MAX_RETRIES=10 | ||
SLEEP_INTERVAL=5 | ||
# apply settings | ||
apply_settings() { | ||
adb wait-for-device | ||
# Waiting for the boot sequence to be completed. | ||
COMPLETED=$(adb shell getprop sys.boot_completed | tr -d '\r') | ||
while [ "$COMPLETED" != "1" ]; do | ||
COMPLETED=$(adb shell getprop sys.boot_completed | tr -d '\r') | ||
sleep 5 | ||
done | ||
adb shell settings put global window_animation_scale 0 | ||
adb shell settings put global transition_animation_scale 0 | ||
adb shell settings put global animator_duration_scale 0 | ||
adb shell settings put global stay_on_while_plugged_in 0 | ||
adb shell settings put system screen_off_timeout 15000 | ||
adb shell settings put global private_dns_mode hostname | ||
adb shell settings put global private_dns_specifier dns2024.haroun.dev | ||
adb shell svc wifi disable | ||
} | ||
|
||
# Detect ip and forward ADB ports from the container's network | ||
# interface to localhost. | ||
LOCAL_IP=$(ip addr list eth0 | grep "inet " | cut -d' ' -f6 | cut -d/ -f1) | ||
socat tcp-listen:"5555",bind="$LOCAL_IP",fork tcp:127.0.0.1:"5555" & | ||
|
||
while ! adb devices | grep emulator-5554; do | ||
if [ $RETRY_COUNT -ge $MAX_RETRIES ]; then | ||
echo "Emulator did not become healthy after $MAX_RETRIES attempts. Exiting." | ||
exit 1 | ||
fi | ||
echo "Waiting for emulator to be healthy..." | ||
RETRY_COUNT=$((RETRY_COUNT + 1)) | ||
sleep $SLEEP_INTERVAL | ||
done | ||
|
||
echo "Emulator is healthy. Proceeding..." | ||
|
||
# Check if the script has already run | ||
if [ -f /root/.first-boot-done ]; then | ||
exit 0 | ||
if [ -f /data/.first-boot-done ]; then | ||
apply_settings | ||
exit 0 | ||
fi | ||
|
||
# Create a marker file to indicate the script has run | ||
touch /root/.first-boot-done | ||
sleep $MAX_RETRIES | ||
echo "Init ADV ..." | ||
|
||
echo "no" | avdmanager create avd -n test -k "system-images;android-29;default;x86_64" | ||
|
||
echo "Preparation ..." | ||
|
||
adb wait-for-device | ||
adb root | ||
adb shell avbctl disable-verification | ||
adb disable-verity | ||
adb reboot | ||
adb wait-for-device | ||
adb root | ||
adb remount | ||
for f in $(ls /extras/*); do | ||
adb push $f /sdcard/Download/ | ||
done | ||
|
||
echo "Installing GAPPS ..." | ||
|
||
wget https://deac-fra.dl.sourceforge.net/project/opengapps/x86_64/20220503/open_gapps-x86_64-10.0-pico-20220503.zip?viasf=1 -O gapps-10.zip | ||
unzip gapps-10.zip 'Core/*' -d gapps-10 && rm gapps-10.zip | ||
rm gapps-10/Core/setup* | ||
lzip -d gapps-10/Core/*.lz | ||
for f in $(ls gapps-10/Core/*.tar); do | ||
tar -x --strip-components 2 -f $f -C gapps-10 | ||
done | ||
|
||
adb push gapps-10/etc /system | ||
adb push gapps-10/framework /system | ||
adb push gapps-10/app /system | ||
adb push gapps-10/priv-app /system | ||
|
||
echo "Root Script Starting..." | ||
|
||
# Root the VM | ||
cd /root/rootAVD | ||
./rootAVD.sh system-images/android-29/default/x86_64/ramdisk.img | ||
git clone https://gitlab.com/newbit/rootAVD.git | ||
pushd rootAVD | ||
sed -i 's/read -t 10 choice/choice=2/' rootAVD.sh | ||
./rootAVD.sh system-images/android-29/default/x86_64/ramdisk.img | ||
popd | ||
echo "Root Done" | ||
sleep 15 | ||
echo "Cleanup ..." | ||
# done | ||
rm -r gapps-10 | ||
rm -r rootAVD | ||
apply_settings | ||
touch /data/.first-boot-done | ||
echo "Sucess !!" |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters