add scripts
[android-debian.git] / android / debian-init
1 #!/system/bin/sh
2
3 # is /debian already mounted? if so, skip mounts
4 if ! awk '{print $2}' /proc/mounts | grep -q '^/debian$'
5 then
6         # create /debian
7         mkdir -p /debian
8
9         # mount /debian
10         mount -t ext3 -o noatime,errors=remount-ro /mnt/sdcard/debian.img /debian
11
12         # bind-mount special file systems from outside
13         for fs in /dev /proc /sys
14         do
15                 mount -o bind "$fs" "/debian$fs"
16         done
17
18         # bind-mount android file systems so we can use them from debian
19         # busybox find has no -empty option so we have to do it like this
20         find /debian/android -type d |
21         while read dir
22         do
23                 if test -z "$(ls $dir)"
24                 then
25                         echo "$dir"
26                 fi
27         done |
28         sed 's,^/debian/android,,' |
29         while read fs
30         do
31                 mount -o bind "$fs" "/debian/android$fs"
32         done
33 fi
34
35 # now start debian
36 chroot /debian /usr/local/sbin/debian-init