KASM-5433 Updates to redroid docs and startup - prevent duplicate scrcpy

launches
This commit is contained in:
Justin Travis 2024-01-11 08:56:57 -05:00
parent c2a43a48af
commit 2280270d89
No known key found for this signature in database
2 changed files with 64 additions and 4 deletions

View File

@ -1,15 +1,48 @@
# About This Image
This Image contains a browser-accessible version of [Redroid](https://github.com/remote-android/redroid-doc).
This experimental image contains a browser-accessible version of [Redroid](https://github.com/remote-android/redroid-doc).
redroid (Remote-Android) is a multi-arch, GPU enabled, Android in Cloud solution.
The image utilizes Docker in Docker (DinD) to automate launching Redroid and [scrcpy docs](https://github.com/Genymobile/scrcpy).
![Screenshot][Image_Screenshot]
[Image_Screenshot]: https://f.hubspotusercontent30.net/hubfs/5856039/dockerhub/image-screenshots/redroid.png "Image Screenshot"
## Important !!
## Host Dependencies
This image requires the "binder_linux" host level kernel modules installed and enabled.
Below is an example for installing binder_linux on Ubuntu 22.04 LTS host
```
sudo apt install linux-modules-extra-`uname -r`
sudo modprobe binder_linux devices="binder,hwbinder,vndbinder"
```
See [Redroid Docs](https://github.com/remote-android/redroid-doc?tab=readme-ov-file#getting-started) for more details.
## Container Permissions
Using this container requires the `--privileged` flag to power both the Docker in Docker processes and the permissions
needed by the redroid containers
```
sudo docker run --rm -it --privileged --shm-size=512m -p 6901:6901 -e VNC_PW=password kasmweb/redroid:develop
```
## Example for installing binder_linux on Ubuntu 22.04 LTS host
```
sudo apt install linux-modules-extra-`uname -r`
sudo modprobe binder_linux devices="binder,hwbinder,vndbinder"
```
The left ALT key is mapped as the hotkey for scrcpy
- Alt+R - rotate the android device
- Alt+F - fullscreen the android device
- Alt+Up/Alt+Down - Increase the volume of the device
See [scrcpy docs](https://github.com/Genymobile/scrcpy) for more details.
This image requires host level kernel modules to be installed and loaded.
See [Redroid Docs](https://github.com/remote-android/redroid-doc?tab=readme-ov-file#getting-started) for more details
# Environment Variables
@ -22,3 +55,4 @@ See [Redroid Docs](https://github.com/remote-android/redroid-doc?tab=readme-ov-f
* `REDROID_SHOW_CONSOLE` - Display the scrcpy console after launching the redroid device.
* `REDROID_DISABLE_AUTOSTART` - If set to "1", the container will not automatically pull and start the redroid container and scrcpy.
* `REDROID_DISABLE_HOST_CHECKS` - If set to "1", the container will not check for the presence of required host level kernel modules.
* `ANDROID_VERSION` - The version of android (redroid) image to automatically load. Options are `14.0.0`, `13.0.0` (Default), `12.0.0`, `11.0.0`, `10.0.0`, `9.0.0`, `8.1.0`.

View File

@ -53,6 +53,7 @@ start_android() {
adb connect localhost:5555
sleep 5
}
start_scrcpy() {
if [ "$REDROID_SHOW_CONSOLE" == "1" ]; then
@ -61,7 +62,32 @@ start_scrcpy() {
scrcpy --audio-codec=aac -s localhost:5555 --shortcut-mod=lalt --print-fps --max-fps=${REDROID_FPS}
fi
wait_for_process $SCRCPY_PGREP
}
wait_for_process() {
process_match=$1
timeout=60
interval=1
elapsed_time=0
echo "Waiting for $process_match..."
while [[ $elapsed_time -lt $timeout ]]; do
if pgrep -x $process_match > /dev/null; then
echo "$process_match is running, continuing..."
break
fi
sleep $interval
elapsed_time=$((elapsed_time + interval))
done
if ! pgrep -x $process_match > /dev/null
then
echo "Did not find process $process_match"
fi
}
kasm_startup() {
if [ -n "$KASM_URL" ] ; then
URL=$KASM_URL