setup variables for commands
echo -e "\n
export image=redroid/redroid:11.0.0-amd64
export image_tar=${HOME}/redroid:11.0.0-amd64" >> ${HOME}/.bashrc
source ${HOME}/.bashrc
1 is recommended
preserve original redroid image
sudo docker pull $image
sudo docker save --output redroidBak.tar $image
backup or install original redroid image
# remove the changed image if exist
sudo docker image rmi -f $image
# install the original image
sudo docker load -i redroidBak.tar
preserve original redroid image
wget -q "https://raw.githubusercontent.com/moby/moby/master/contrib/download-frozen-image-v2.sh" -P ~ ; chmod u+x ~/download-frozen-image-v2.sh
~/download-frozen-image-v2.sh "$image_tar" redroid/redroid:11.0.0-amd64
backup or install original redroid image
# remove the changed image if exist
sudo docker image rmi -f $image
# install the original image
tar -cC "$image_tar" . | sudo docker load
mkdir ~/MagiskOnRedroid
cd ~/MagiskOnRedroid
download+extract magisk
find -maxdepth 1 -iname "magisk*" -not -name "*.apk" -exec rm -r {} \;
magisk_file="app-debug.apk"
# download Magisk 9b61bdfc(25201) debug as you did i guess
if [ ! -f $magisk_file ]; then
wget "https://cdn.jsdelivr.net/gh/topjohnwu/magisk-files@1cea72840fbf690f9a95512d03721f6a710fe02e/app-debug.apk"
fi
# because my machine x64 i will choose x86_64
unzip -j $magisk_file "lib/x86_64/libmagisk64.so" -d magisk
unzip -j $magisk_file "lib/x86_64/libbusybox.so" -d magisk
mv -v magisk/libmagisk64.so magisk/magisk
mv -v magisk/libbusybox.so magisk/busybox
# $ tree ~/MagiskOnRedroid
# .
# ├── app-debug.apk
# └── magisk
# ├── busybox
# └── magisk
compress magisk
tar --transform 's/.*\///g' -cf ~/magisk.tar --absolute-names $( find ~/MagiskOnRedroid | grep -E "magisk/|app-debug.apk$" )
remove.rc
cat <<\EOF > ~/remove.rc
on early-init
export PATH /sbin:/product/bin:/apex/com.android.runtime/bin:/apex/com.android.art/bin:/system_ext/bin:/system/bin:/system/xbin:/odm/bin:/vendor/bin:/vendor/xbin
chmod 0700 /magisk.tar
chown root root /magisk.tar
chmod 0700 /setup.sh
chown root root /setup.sh
exec root root -- /setup.sh
service magisk-d /sbin/magisk --daemon
user root
oneshot
on boot
start magisk-d
on post-fs-data
start logd
rm /dev/.magisk-unblock
start s1
wait /dev/.magisk-unblock 5
rm /dev/.magisk-unblock
service s1 /sbin/magisk --post-fs-data
user root
oneshot
service s2 /sbin/magisk --service
class late_start
user root
oneshot
on property:sys.boot_completed=1
exec /sbin/magisk --boot-complete
on property:init.svc.zygote=restarting
exec /sbin/magisk --zygote-restart
on property:init.svc.zygote=stopped
exec /sbin/magisk --zygote-restart
EOF
sudo chmod 644 ~/remove.rc
sudo chown root:root ~/remove.rc
setup.sh
cat <<\EOF > ~/setup.sh
#!/system/bin/sh
# rm /system/fonts/NotoColorEmoji.ttf
tmpPushed=/magisk
rm -rf $tmpPushed
mkdir $tmpPushed
tar -xvf /magisk.tar --no-same-owner -C $tmpPushed
umount /magisk.tar ; rm -v /magisk.tar
mkdir /sbin
chown root:root /sbin
# chmod 0700 /sbin
chmod 0751 /sbin
cp $tmpPushed/magisk /sbin/
cp $tmpPushed/app-debug.apk /sbin/stub.apk
find /sbin -type f -exec chmod 0755 {} \;
find /sbin -type f -exec chown root:root {} \;
# add /sbin
# /sbin/
# ├── magisk
# └── stub.apk
ln -f -s /sbin/magisk /system/xbin/su
mkdir /product/bin
chmod 751 /product/bin
ln -f -s /sbin/magisk /product/bin/su
# add su (override `/system/xbin/su`)
# /product/bin/
# └── su -> /sbin/magisk
mkdir -p /data/adb/magisk
chmod 700 /data/adb
mv $tmpPushed/busybox /data/adb/magisk/
chmod -R 755 /data/adb/magisk
chmod -R root:root /data/adb/magisk
# /data/adb/
# ├── magisk
# │ └── busybox
# rm -rf $tmpPushed
EOF
sudo chmod 700 ~/setup.sh
sudo chown root:root ~/setup.sh
- phase
- boot with magisk support
( sudo docker stop a11 clear sudo docker run -itd --rm --privileged \ --name a11 \ -v ~/data:/data \ -v ~/remove.rc:/vendor/etc/init/remove.rc \ -v ~/setup.sh:/setup.sh \ -v ~/magisk.tar:/magisk.tar \ -p 5555:5555 \ redroid/redroid:11.0.0-amd64 \ ro.secure=0 )
Dear author of the teaching article, when I tried to integrate Magisk according to your method, there were some problems. What scripts and files are there in the system after the container is run, but there is no Magisk application.
This is my build script.
The directory where I am running the script is the/root directory
Hope to get your advice and help.