blob: 16d06c310b907207ab8026c414c573f1d84e15b7 (
plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#!/bin/sh
set -x
export ARG=$1
export ROOT=/storage/sdcard1/Linux/jessie
export LOOP_DEVICE=/dev/block/loop1
export SHELL=/bin/bash
function start_services {
HOME=/root chroot $ROOT $SHELL /etc/rc.debroid
}
function enter_chroot {
HOME=/root chroot $ROOT $SHELL -l
}
function mount_chroot {
mountpoint $ROOT
if [ $? -ne 0 ]; then
losetup $LOOP_DEVICE $ROOT.img
busybox mount -t ext4 $LOOP_DEVICE $ROOT
fi
for mountpoint in proc dev sys dev/pts; do
mountpoint $ROOT/$mountpoint
if [ $? -ne 0 ]; then
busybox mount --bind /$mountpoint $ROOT/$mountpoint
fi
done
#busybox mount --bind /mnt/shell/emulated $ROOT/storage/sdcard0
mountpoint $ROOT/storage/sdcard1
if [ $? -ne 0 ]; then
busybox mount --bind /storage/sdcard1 $ROOT/storage/sdcard1
fi
}
function umount_chroot {
#busybox umount -f $ROOT/storage/sdcard0
busybox umount -f $ROOT/storage/sdcard1
for mountpoint in dev/pts proc dev sys; do
busybox umount -f $ROOT/$mountpoint
done
busybox umount -f $ROOT
losetup -d $LOOP_DEVICE
}
case $ARG in
enter)
mount_chroot
enter_chroot
;;
mount)
mount_chroot
;;
umount)
umount_chroot
;;
session)
mount_chroot
enter_chroot
umount_chroot
;;
start_services)
mount_chroot
start_services
;;
*)
echo "Usage: $0 session|mount|umount|enter|start_services"
exit 1
;;
esac
|