diff --git a/Dockerfile b/Dockerfile index caadde3..4334aa4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -93,7 +93,7 @@ RUN apt-get update && \ # WM fvwm xterm \ # debug utilities - busybox file strace less && \ + busybox figlet file strace less && \ # ... useradd --create-home --home-dir /home/user --uid 1000 -G systemd-journal user && \ curl -L -o /docker-entrypoint.sh https://raw.githubusercontent.com/AkihiroSuda/containerized-systemd/6ced78a9df65c13399ef1ce41c0bedc194d7cff6/docker-entrypoint.sh && \ @@ -108,6 +108,10 @@ ADD src/anbox-container-manager.service /lib/systemd/system/anbox-container-mana RUN systemctl enable anbox-container-manager ADD src/unsudo /usr/local/bin ADD src/docker-2ndboot.sh /home/user +# apk-pre.d is for pre-installed apks, /apk.d for the mountpoint for user-specific apks +RUN mkdir -p /apk-pre.d /apk.d +ADD https://f-droid.org/FDroid.apk /apk-pre.d +RUN chmod 444 /apk-pre.d/* VOLUME /var/lib/anbox ENTRYPOINT ["/docker-entrypoint.sh", "unsudo"] EXPOSE 5900 diff --git a/README.md b/README.md index 72ee68b..97446f5 100644 --- a/README.md +++ b/README.md @@ -60,18 +60,18 @@ docker run -td --name aind --privileged -p 5900:5900 -v /lib/modules:/lib/module > NOTE: `--privileged` is required for nesting an Anbox (LXC) inside Docker. But you don't need to worry too much because Anbox launches "unprivileged" LXC using user namespaces. You can confirm that all Android process are running as non-root users, by executing `docker exec aind ps -ef`. -Connect to `5900` via `vncviewer`. +Wait for 10-20 seconds until Android processes are shown up in `docker exec aind ps -ef`, and then connect to `5900` via `vncviewer`. -Future version will support connection from Web browsers without VNC. +If the application manager doesn't shown up on the VNC screen, try `docker run ...` several times (FIXME). Also make sure to check `docker logs aind`. + +Future version will support connection from Web browsers (of phones and tablets) without VNC. ### Installing apk packages -Use `adb install` (To be documented). +APK files mounted as `/apk.d/*.apk` are automatically installed on start up. You can also use [F-Droid](https://f-droid.org/). - -F-Droid will be installed by default soon. - +To use F-Droid, enable "Settings" -> "Security" -> "Allow installation of apps from unknown sources". ## TODOs * Map different UID range per containers diff --git a/docs/screenshot.png b/docs/screenshot.png index c9b6298..8ef5b19 100644 Binary files a/docs/screenshot.png and b/docs/screenshot.png differ diff --git a/src/docker-2ndboot.sh b/src/docker-2ndboot.sh index feabff7..e876725 100755 --- a/src/docker-2ndboot.sh +++ b/src/docker-2ndboot.sh @@ -1,22 +1,43 @@ #!/bin/bash # docker-2ndboot.sh is executed as a non-root user via `unsudo`. +function finish { + figlet ERROR + echo "ERROR: failed!" + : FIXME: the container should shutdown automatically here +} +trap finish EXIT + cd $(realpath $(dirname $0)/..) set -eux Xvfb & export DISPLAY=:0 -: FIXME -sleep 5 +until [ -e /tmp/.X11-unix/X0 ]; do sleep 1; done +: FIXME: remove this sleep +sleep 1 x11vnc & - -: FIXME -sleep 5 +: FIXME: remove this sleep +sleep 1 fvwm & -anbox session-manager & +systemctl is-system-running --wait +systemctl status anbox-container-manager --no-pager -: FIXME -sleep 5 +anbox session-manager & +until anbox wait-ready; do sleep 1; done anbox launch --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity -sleep infinity +adb wait-for-device + +# install apk (pre-installed apps such as F-Droid) +for f in /apk-pre.d/*.apk; do adb install $f; done + +# install apk +if ls /apk.d/*.apk; then + for f in /apk.d/*.apk; do adb install $f; done +fi + +# done +figlet "Ready" +ps -ef +exec sleep infinity