From ceb3b3ce56a511880bbd4e24de86a4f302814896 Mon Sep 17 00:00:00 2001 From: "Paul Buetow (europa)" Date: Sat, 20 Jun 2015 10:06:36 +0100 Subject: add Debroid to Android userinit --- README.md | 35 +++++++++++++++++--- data/local/userinit.sh | 4 +++ jessie.sh | 64 ------------------------------------ storage/sdcard1/Linux/jessie.sh | 72 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 107 insertions(+), 68 deletions(-) create mode 100644 data/local/userinit.sh delete mode 100644 jessie.sh create mode 100644 storage/sdcard1/Linux/jessie.sh diff --git a/README.md b/README.md index cf367a8..f86bbff 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -DEBRIOD +Debroid ======= Install a full blown Debian GNU/Linux Chroot on a LG G3 D855 CyanogenMod 12. Needs root and needs developer mode activated. @@ -68,13 +68,11 @@ exit Last setup steps ``` +sh jessie.sh enter cat <~/.bashrc export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH export EDITOR=vim hostname $(cat /etc/hostname) -# Example how to start single services -# service uptimed status &>/dev/null || service uptimed start - # Fixing an error messages while loading the profile sed -i s#id#/usr/bin/id# /etc/profile @@ -89,14 +87,43 @@ deb http://ftp.uk.debian.org/debian/ jessie main contrib non-free deb-src http://ftp.uk.debian.org/debian/ jessie main contrib non-free END apt-get update +exit +``` + +Debroid services startup +``` +sh jessie.sh enter +cat < /etc/rc.debroid +export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH +service uptimed status &>/dev/null || service uptimed start +exit 0 +END +chmod 0755 /etc/rc.debroid +exit ``` Enter chroot script (as root): ``` +sh jessie.sh enter cp jessie.sh /storage/sdcard1/Linux/jessie.sh cd /storage/sdcard1/Linux +sh jessie.sh start_services sh jessie.sh enter +exit +``` + +Include to Android startup + +``` +# This script is called from /etc/init.d/*userinit, but +# does not exist yet, so create it now +cat </data/local/userinit.sh +#!/system/bin/sh + +cd /storage/sdcard1/Linux +sh jessie.sh start_services +END ``` Enjoy! diff --git a/data/local/userinit.sh b/data/local/userinit.sh new file mode 100644 index 0000000..7872455 --- /dev/null +++ b/data/local/userinit.sh @@ -0,0 +1,4 @@ +#!/system/bin/sh + +cd /storage/sdcard1/Linux +sh jessie.sh start_services diff --git a/jessie.sh b/jessie.sh deleted file mode 100644 index 5e9826c..0000000 --- a/jessie.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/sh - -set -x - -export ARG=$1 -export ROOT=$(pwd)/jessie -export LOOP_DEVICE=/dev/block/loop1 -export SHELL=/bin/bash - -function enter_chroot { - HOME=/root LD_PRELOAD='' 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 - ;; - *) - echo "Usage: $0 session|mount|umount|enter" - exit 1 - ;; -esac - diff --git a/storage/sdcard1/Linux/jessie.sh b/storage/sdcard1/Linux/jessie.sh new file mode 100644 index 0000000..0e5efe0 --- /dev/null +++ b/storage/sdcard1/Linux/jessie.sh @@ -0,0 +1,72 @@ +#!/bin/sh + +set -x + +export ARG=$1 +export ROOT=$(pwd)/jessie +export LOOP_DEVICE=/dev/block/loop1 +export SHELL=/bin/bash + +function start_services { + HOME=/root LD_PRELOAD='' chroot $ROOT $SHELL /etc/rc.debroid +} + +function enter_chroot { + HOME=/root LD_PRELOAD='' 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 + -- cgit v1.2.3