From bbf19fa155453f9473673349cfc334250fca0467 Mon Sep 17 00:00:00 2001 From: Steven McDonald Date: Sat, 26 Nov 2011 15:49:14 +1100 Subject: [PATCH] add scripts --- README | 5 +++++ android/debian-init | 36 ++++++++++++++++++++++++++++++++++++ android/debian-sh | 7 +++++++ debian/debian-init | 24 ++++++++++++++++++++++++ debian/debian-sh | 14 ++++++++++++++ 5 files changed, 86 insertions(+) create mode 100644 README create mode 100755 android/debian-init create mode 100755 android/debian-sh create mode 100755 debian/debian-init create mode 100755 debian/debian-sh diff --git a/README b/README new file mode 100644 index 0000000..e9402a0 --- /dev/null +++ b/README @@ -0,0 +1,5 @@ +These scripts are intended to ease the process of bootstrapping a Debian +chroot on an Android device. Instructions for installing such a chroot +may be found at: + +http://www.steven-mcdonald.id.au/tutorials/debian_on_samsung_galaxy.shtml diff --git a/android/debian-init b/android/debian-init new file mode 100755 index 0000000..7757597 --- /dev/null +++ b/android/debian-init @@ -0,0 +1,36 @@ +#!/system/bin/sh + +# is /debian already mounted? if so, skip mounts +if ! awk '{print $2}' /proc/mounts | grep -q '^/debian$' +then + # create /debian + mkdir -p /debian + + # mount /debian + mount -t ext3 -o noatime,errors=remount-ro /mnt/sdcard/debian.img /debian + + # bind-mount special file systems from outside + for fs in /dev /proc /sys + do + mount -o bind "$fs" "/debian$fs" + done + + # bind-mount android file systems so we can use them from debian + # busybox find has no -empty option so we have to do it like this + find /debian/android -type d | + while read dir + do + if test -z "$(ls $dir)" + then + echo "$dir" + fi + done | + sed 's,^/debian/android,,' | + while read fs + do + mount -o bind "$fs" "/debian/android$fs" + done +fi + +# now start debian +chroot /debian /usr/local/sbin/debian-init diff --git a/android/debian-sh b/android/debian-sh new file mode 100755 index 0000000..7bea81f --- /dev/null +++ b/android/debian-sh @@ -0,0 +1,7 @@ +#!/system/bin/sh +if whoami | grep -q '^root$' +then + chroot /debian /usr/local/sbin/debian-sh +else + su -c /data/local/bin/debian-sh +fi diff --git a/debian/debian-init b/debian/debian-init new file mode 100755 index 0000000..3f24d25 --- /dev/null +++ b/debian/debian-init @@ -0,0 +1,24 @@ +#!/bin/sh + +# initialise debian system from outside the chroot +# this script gets called from the android init system + +# first, set our PATH correctly +# android uses a retarded PATH +export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' + +# what services do we want to start? +services=' +hostname.sh +rsyslog +ssh +atd +cron +rc.local +' + +# start debian services +for service in $services +do + /usr/sbin/service "$service" start +done diff --git a/debian/debian-sh b/debian/debian-sh new file mode 100755 index 0000000..a853092 --- /dev/null +++ b/debian/debian-sh @@ -0,0 +1,14 @@ +#!/bin/sh + +# get rid of the retarded export PATH terminal emulator inflicts on us +read foo +unset foo + +export HOME='/root' +export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' +export SHELL='/bin/bash' +export TERM='xterm' + +clear +cd +/bin/bash -- 2.30.2