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

Commit

Permalink
refactor scripts + install F-Droid
Browse files Browse the repository at this point in the history
Signed-off-by: Akihiro Suda <[email protected]>
  • Loading branch information
AkihiroSuda committed Apr 10, 2020
1 parent f6de7de commit 0f9de0a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 16 deletions.
6 changes: 5 additions & 1 deletion 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 @@ -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
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
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.
39 changes: 30 additions & 9 deletions src/docker-2ndboot.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0f9de0a

Please sign in to comment.