Last active
December 21, 2023 17:59
-
-
Save sr229/e07d47131b98ab1f3fabe3df48cd24b8 to your computer and use it in GitHub Desktop.
Automated Script to Install Anbox Ashmem and Binder to WSL2 Linux Kernel
This file contains hidden or 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
#!/bin/bash | |
set -o pipefail | |
KERNEL_WORKING_DIRECTORY="/usr/src" | |
KERNEL_VERSION=$(uname -r) | |
REQUIRED_DEPENDENCIES="git bison flex elfutils-libelf-devel openssl-devel" | |
KERNEL_SRC_DIR="$KERNEL_WORKING_DIRECTORY/WSL2-Linux-Kernel-$(uname -r)" | |
echo "Warning: This script has to be run on sudo permissions. If you encounter issues please report it immediately." | |
sleep 3 | |
# Check if we have this installed first things first. | |
# We need this to install our Anbox stuff later | |
dnf install $REQUIRED_DEPENDENCIES -y | |
if [ ! -d "$KERNEL_SRC_DIR" ]; then | |
git clone --branch "$KERNEL_VERSION" --depth=30 https://github.com/microsoft/WSL2-Linux-Kernel "$KERNEL_SRC_DIR" | |
fi | |
cd "$KERNEL_SRC_DIR" && \ | |
cp /proc/config.gz $(pwd) && \ | |
gzip -d config.gz && \ | |
mv config .config && \ | |
make prepare && \ | |
make modules_prepare && \ | |
make modules && \ | |
make scripts; | |
if [ ! -d /lib/modules/$KERNEL_VERSION/ ]; then | |
mkdir -p /lib/modules/$KERNEL_VERSION | |
ln $KERNEL_SRC_DIR -s /lib/modules/$KERNEL_VERSION/build | |
fi | |
git clone https://github.com/anbox/anbox-modules.git $HOME/anbox-modules && \ | |
cd $HOME/anbox-modules && \ | |
bash INSTALL.sh | |
rm -rf $HOME/anbox-modules | |
(source /etc/os-release && sudo dnf copr enable yanqiyu/anbox ${ID_LIKE}-${VERSION_ID}-$(uname -m)) && \ | |
dnf install anbox -y | |
wget -O - https://build.anbox.io/android-images/2018/07/19/android_amd64.img > /var/lib/anbox/android.img | |
bash /usr/share/anbox/anbox-bridge.sh start && \ | |
daemonize /usr/bin/anbox container-manager --daemon --privileged --data-path=/var/lib/anbox |
This file contains hidden or 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
#!/bin/bash | |
set -eo pipefail | |
KERNEL_WORKING_DIRECTORY="/usr/src" | |
KERNEL_VERSION=$(uname -r) | |
REQUIRED_DEPENDENCIES="git bison flex libelf-dev elfutils libssl-dev dkms" | |
KERNEL_SRC_DIR="$KERNEL_WORKING_DIRECTORY/WSL2-Linux-Kernel-$(uname -r)" | |
echo "Warning: This script has to be run on sudo permissions. If you encounter issues please report it immediately." | |
sleep 3 | |
# Check if we have this installed first things first. | |
# We need this to install our Anbox stuff later | |
apt install $REQUIRED_DEPENDENCIES -y | |
if [ ! -d "$KERNEL_SRC_DIR" ]; then | |
git clone --branch "$KERNEL_VERSION" --depth=30 https://github.com/microsoft/WSL2-Linux-Kernel "$KERNEL_SRC_DIR" | |
fi | |
cd "$KERNEL_SRC_DIR" && \ | |
cp /proc/config.gz $(pwd) && \ | |
gzip -d config.gz && \ | |
mv config .config && \ | |
make prepare && \ | |
make modules_prepare && \ | |
make modules && \ | |
make scripts; | |
if [ ! -d /lib/modules/$KERNEL_VERSION/ ]; then | |
mkdir -p /lib/modules/$KERNEL_VERSION | |
ln $KERNEL_SRC_DIR -s /lib/modules/$KERNEL_VERSION/build | |
fi | |
git clone https://github.com/anbox/anbox-modules.git $HOME/anbox-modules && \ | |
cd $HOME/anbox-modules && \ | |
bash INSTALL.sh | |
rm -rf $HOME/anbox-modules |
This file contains hidden or 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
#!/bin/bash | |
set -eo pipefail | |
KERNEL_WORKING_DIRECTORY="/usr/src" | |
KERNEL_VERSION=$(uname -r) | |
REQUIRED_DEPENDENCIES="git bison flex libelf-dev elfutils libssl-dev dkms" | |
KERNEL_SRC_DIR="$KERNEL_WORKING_DIRECTORY/WSL2-Linux-Kernel-$(uname -r)" | |
echo "Warning: This script has to be run on sudo permissions. If you encounter issues please report it immediately." | |
sleep 3 | |
# Check if we have this installed first things first. | |
# We need this to install our Anbox stuff later | |
apt install $REQUIRED_DEPENDENCIES -y | |
if [ ! -d "$KERNEL_SRC_DIR" ]; then | |
git clone --branch "$KERNEL_VERSION" --depth=30 https://github.com/microsoft/WSL2-Linux-Kernel "$KERNEL_SRC_DIR" | |
fi | |
cd "$KERNEL_SRC_DIR" && \ | |
cp /proc/config.gz $(pwd) && \ | |
gzip -d config.gz && \ | |
mv config .config && \ | |
make prepare && \ | |
make modules_prepare && \ | |
make modules && \ | |
make scripts; | |
if [ ! -d /lib/modules/$KERNEL_VERSION/ ]; then | |
mkdir -p /lib/modules/$KERNEL_VERSION | |
ln $KERNEL_SRC_DIR -s /lib/modules/$KERNEL_VERSION/build | |
fi |
Error Encountered:
fatal: Remote branch 5.10.16.3-microsoft-standard-WSL2 not found in upstream origin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am facing some issues when i run this script on my wsl2 machine in windows 11
