Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

Commit

Permalink
Merge pull request #10 from AkihiroSuda/b
Browse files Browse the repository at this point in the history
misc fixes + install F-Droid
  • Loading branch information
AkihiroSuda authored Apr 10, 2020
2 parents f659966 + 0f9de0a commit 0bbd3d4
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 34 deletions.
12 changes: 8 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand All @@ -104,10 +104,14 @@ COPY --from=anbox /anbox/build/src/anbox /usr/local/bin/anbox
COPY --from=anbox /anbox/scripts/anbox-bridge.sh /usr/local/share/anbox/anbox-bridge.sh
COPY --from=anbox /anbox/data/ui /usr/local/share/anbox/ui
RUN ldconfig
ADD anbox-container-manager.service /lib/systemd/system/anbox-container-manager.service
ADD src/anbox-container-manager.service /lib/systemd/system/anbox-container-manager.service
RUN systemctl enable anbox-container-manager
ADD unsudo /usr/local/bin
ADD docker-2ndboot.sh /home/user
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
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 0 additions & 22 deletions docker-2ndboot.sh

This file was deleted.

Binary file modified docs/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Wants=network.target
[Service]
ExecStartPre=/sbin/modprobe ashmem_linux
ExecStartPre=/sbin/modprobe binder_linux
ExecStartPre=mkdir -p /dev/binderfs
ExecStartPre=mount -t binder none /dev/binderfs
# newer kernel uses /dev/binderfs directory instead of /dev/binder file
ExecStartPre=sh -exc "[ -f /dev/binder ] || (mkdir -p /dev/binderfs && mount -t binder none /dev/binderfs)"
ExecStartPre=/usr/local/share/anbox/anbox-bridge.sh start
ExecStart=/usr/local/bin/anbox container-manager --daemon --data-path=/var/lib/anbox --android-image=/android.img --use-rootfs-overlay
ExecStopPost=/usr/local/share/anbox/anbox-bridge.sh stop
Expand Down
43 changes: 43 additions & 0 deletions src/docker-2ndboot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +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

until [ -e /tmp/.X11-unix/X0 ]; do sleep 1; done
: FIXME: remove this sleep
sleep 1
x11vnc &
: FIXME: remove this sleep
sleep 1
fvwm &
systemctl is-system-running --wait
systemctl status anbox-container-manager --no-pager

anbox session-manager &
until anbox wait-ready; do sleep 1; done
anbox launch --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity

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
File renamed without changes.

0 comments on commit 0bbd3d4

Please sign in to comment.