File: mount-android.sh

package info (click to toggle)
anbox 0.0~git20190124-1
  • links: PTS, VCS
  • area: contrib
  • in suites: buster
  • size: 22,000 kB
  • sloc: cpp: 76,190; ansic: 7,434; sh: 1,350; xml: 818; java: 780; python: 390; makefile: 35; lisp: 7
file content (37 lines) | stat: -rwxr-xr-x 804 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash

DATA_PATH=/var/lib/anbox
ROOTFS_PATH=$DATA_PATH/rootfs
ANDROID_IMG=$1
CONTAINER_BASE_UID=100000
DIR="$(dirname $0)"

if [[ $EUID -ne 0 ]]; then
   echo "This script must be run as root" 1>&2
   exit 1
fi

if [ -z "$1" ]; then
    echo "Usage:"
    echo "./mount-android.sh [Android image]"
    exit 1
fi

if [ ! -f $ANDROID_IMG ]; then
    echo "Android image not found"
    exit 1
fi

# Setup the read-only rootfs
mkdir -p $ROOTFS_PATH
mount -o loop,ro $ANDROID_IMG $ROOTFS_PATH

# but certain top-level directories need to be in a writable space
for dir in cache data; do
  mkdir -p $DATA_PATH/android-$dir
  chown $CONTAINER_BASE_UID:$CONTAINER_BASE_UID $DATA_PATH/android-$dir
  mount -o bind $DATA_PATH/android-$dir $ROOTFS_PATH/$dir
done

$DIR/anbox-bridge.sh start
$DIR/load-kmods.sh