给甲骨文云免费ARM实例安装带magisk的Redroid

初始设置

apt update & apt upgrade -y  #更新
apt install docker.io #安装docker
apt install unzip #后续用到的指令
apt install linux-modules-extra-`uname -r`
modprobe binder_linux devices="binder,hwbinder,vndbinder" #进程通信模块
modprobe ashmem_linux #内存共享模块
#后两条命令不提示错误 / Enter后没有任何反应说明启动成功

设置命令变量

echo -e "\n
export image=redroid/redroid:11.0.0-arm64
export image_tar=${HOME}/redroid:11.0.0-arm64" >> ${HOME}/.bashrc
source ${HOME}/.bashrc

## 使用docker拉取镜像 保存redroid图像
sudo docker pull $image
sudo docker save --output redroidBak.tar $image
导入redroid映像
# 删除已存在更改过的镜像
sudo docker image rmi -f $image
# 导入redroid镜像
sudo docker load -i redroidBak.tar

设置

#创建一个文件夹,进入文件夹下载+提取magisk
mkdir ~/MagiskOnRedroid
cd ~/MagiskOnRedroid
下载+提取 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
# 我的机器arm平台 我选arm-v8a
unzip -j $magisk_file "lib/arm64-v8a/libmagisk64.so" -d magisk
unzip -j $magisk_file "lib/arm64-v8a/libbusybox.so" -d magisk
mv -v magisk/libmagisk64.so magisk/magisk
mv -v magisk/libbusybox.so magisk/busybox

# $  ~/MagiskOnRedroid文件夹內文件目录
# .
# ├── app-debug.apk
# └── magisk
#     ├── busybox
#     └── magisk
magisk.tar
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

让magisk 运行还需以下步骤:

1.启动

ufw allow 5555 #开放端口

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 55555:5555 \
  redroid/redroid:11.0.0-arm64 \
  redroid.gpu.mode=guest \
  ro.secure=0

开始enjoy
给甲骨文云免费ARM实例安装带magisk的Redroid_第1张图片
给甲骨文云免费ARM实例安装带magisk的Redroid_第2张图片

你可能感兴趣的:(linux,docker)