From 3ab0d04b34ffdb4b4a7dbc1a091148ee4cfae361 Mon Sep 17 00:00:00 2001 From: JBBgameich Date: Sun, 9 Jul 2017 13:31:43 +0200 Subject: [PATCH 1/9] Preconfigure SSH on device --- halium-install | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/halium-install b/halium-install index 6dd67cb..138ea6d 100755 --- a/halium-install +++ b/halium-install @@ -38,6 +38,11 @@ do_shell() adb shell "$@" } +do_chroot() +{ + do_shell "chroot /cache/system $@" +} + convert_android_img() { if file $SYSIMG | grep -v ": Linux rev 1.0 ext4" >/dev/null; then @@ -190,6 +195,13 @@ do_shell "cd /cache/system && zcat /recovery/$TARBALL | tar xf -" do_shell "[ -e /cache/system/SWAP.swap ] && mv /cache/system/SWAP.swap /data/SWAP.img" echo "[done]" +echo "Generating SSH host keys on the device" +do_chroot "rm /etc/dropbear/dropbear_rsa_host_key" +do_chroot "dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key" + +echo "Changing password needed for root ssh login" +do_chroot passwd root + echo -n "adding android system image to installation ... " convert_android_img ANDROID_DIR="/data" From b9cb07e8bc18652907467a62121ffda096b7463f Mon Sep 17 00:00:00 2001 From: JBBgameich Date: Mon, 10 Jul 2017 15:19:56 +0200 Subject: [PATCH 2/9] Check if busybox exists and install it when needed --- halium-install | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/halium-install b/halium-install index 138ea6d..97e5654 100755 --- a/halium-install +++ b/halium-install @@ -43,6 +43,30 @@ do_chroot() do_shell "chroot /cache/system $@" } +check_busybox() +{ + export device_architecture=$(do_shell "uname -m") + export busybox_exists=$(do_shell "if [ -d /sbin/busybox ]; then echo true; else echo false; fi") + mkdir busybox + + if [ $busybox_exists = "true" ]; then + echo 'Using already installed busybox' + else + if [ $device_architecture = x86_64 ]; then + wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/intel/static/bin/busybox -O busybox/busybox + elif [ $device_architecture = armv7l ]; then + wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/arm/static/bin/busybox -O busybox/busybox + elif [ $device_architecture = arm64 ]; then + wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/arm/static/bin/busybox -O busybox/busybox + fi + + adb push busybox/busybox /sbin/busybox + do_shell "/sbin/busybox --install" + fi + + rm busybox -r +} + convert_android_img() { if file $SYSIMG | grep -v ": Linux rev 1.0 ext4" >/dev/null; then @@ -170,6 +194,7 @@ if ! adb devices | grep -q recovery; then exit 1 fi +check_busybox check_mounts WORKDIR=$(mktemp -d /tmp/halium-install.XXXXX) From 5eb5be427dda122771cfe6b762cb38dd3954d7dd Mon Sep 17 00:00:00 2001 From: JBBgameich Date: Mon, 10 Jul 2017 18:30:20 +0200 Subject: [PATCH 3/9] Mark busybox executable --- halium-install | 1 + 1 file changed, 1 insertion(+) diff --git a/halium-install b/halium-install index 97e5654..9ed1c32 100755 --- a/halium-install +++ b/halium-install @@ -61,6 +61,7 @@ check_busybox() fi adb push busybox/busybox /sbin/busybox + do_shell "chmod +x /sbin/busybox" do_shell "/sbin/busybox --install" fi From 3d01ae7177fae6c41f548912580586a7d8de6f87 Mon Sep 17 00:00:00 2001 From: JBBgameich Date: Mon, 10 Jul 2017 18:49:53 +0200 Subject: [PATCH 4/9] Don't create an unnecessary new folder --- halium-install | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/halium-install b/halium-install index 9ed1c32..809a45c 100755 --- a/halium-install +++ b/halium-install @@ -47,25 +47,24 @@ check_busybox() { export device_architecture=$(do_shell "uname -m") export busybox_exists=$(do_shell "if [ -d /sbin/busybox ]; then echo true; else echo false; fi") - mkdir busybox if [ $busybox_exists = "true" ]; then echo 'Using already installed busybox' else if [ $device_architecture = x86_64 ]; then - wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/intel/static/bin/busybox -O busybox/busybox + wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/intel/static/bin/busybox elif [ $device_architecture = armv7l ]; then - wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/arm/static/bin/busybox -O busybox/busybox + wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/arm/static/bin/busybox elif [ $device_architecture = arm64 ]; then - wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/arm/static/bin/busybox -O busybox/busybox + wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/arm/static/bin/busybox fi - adb push busybox/busybox /sbin/busybox + adb push busybox /sbin/busybox do_shell "chmod +x /sbin/busybox" do_shell "/sbin/busybox --install" fi - rm busybox -r + rm busybox } convert_android_img() From 5c0be56f415b3628db86825cbd130a25dbee648c Mon Sep 17 00:00:00 2001 From: JBBgameich Date: Tue, 11 Jul 2017 17:16:31 +0200 Subject: [PATCH 5/9] Install busybox applets to /sbin --- halium-install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/halium-install b/halium-install index 809a45c..a7b7af6 100755 --- a/halium-install +++ b/halium-install @@ -61,7 +61,7 @@ check_busybox() adb push busybox /sbin/busybox do_shell "chmod +x /sbin/busybox" - do_shell "/sbin/busybox --install" + do_shell "/sbin/busybox --install /sbin/" fi rm busybox From a03965b8c5420eb15eefde4902bb6fe241ad2654 Mon Sep 17 00:00:00 2001 From: JBBgameich Date: Tue, 11 Jul 2017 17:20:43 +0200 Subject: [PATCH 6/9] Use tabs to match coding style --- halium-install | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/halium-install b/halium-install index a7b7af6..cf4c9e6 100755 --- a/halium-install +++ b/halium-install @@ -45,26 +45,26 @@ do_chroot() check_busybox() { - export device_architecture=$(do_shell "uname -m") - export busybox_exists=$(do_shell "if [ -d /sbin/busybox ]; then echo true; else echo false; fi") - - if [ $busybox_exists = "true" ]; then - echo 'Using already installed busybox' - else - if [ $device_architecture = x86_64 ]; then - wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/intel/static/bin/busybox - elif [ $device_architecture = armv7l ]; then - wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/arm/static/bin/busybox - elif [ $device_architecture = arm64 ]; then - wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/arm/static/bin/busybox - fi - - adb push busybox /sbin/busybox - do_shell "chmod +x /sbin/busybox" - do_shell "/sbin/busybox --install /sbin/" - fi - - rm busybox + export device_architecture=$(do_shell "uname -m") + export busybox_exists=$(do_shell "if [ -d /sbin/busybox ]; then echo true; else echo false; fi") + + if [ $busybox_exists = "true" ]; then + echo 'Using already installed busybox' + else + if [ $device_architecture = x86_64 ]; then + wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/intel/static/bin/busybox + elif [ $device_architecture = armv7l ]; then + wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/arm/static/bin/busybox + elif [ $device_architecture = arm64 ]; then + wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/arm/static/bin/busybox + fi + + adb push busybox /sbin/busybox + do_shell "chmod +x /sbin/busybox" + do_shell "/sbin/busybox --install /sbin/" + fi + + rm busybox } convert_android_img() From fd76886fc73cee954c15da5cdd65364c7f884e7b Mon Sep 17 00:00:00 2001 From: JBBgameich Date: Tue, 11 Jul 2017 19:26:52 +0200 Subject: [PATCH 7/9] Correct architecture names --- halium-install | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/halium-install b/halium-install index cf4c9e6..2419c4a 100755 --- a/halium-install +++ b/halium-install @@ -48,14 +48,16 @@ check_busybox() export device_architecture=$(do_shell "uname -m") export busybox_exists=$(do_shell "if [ -d /sbin/busybox ]; then echo true; else echo false; fi") - if [ $busybox_exists = "true" ]; then + if [ $busybox_exists = true ]; then echo 'Using already installed busybox' else if [ $device_architecture = x86_64 ]; then wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/intel/static/bin/busybox elif [ $device_architecture = armv7l ]; then wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/arm/static/bin/busybox - elif [ $device_architecture = arm64 ]; then + elif [ $device_architecture = aarch64 ]; then + wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/arm/static/bin/busybox + elif [ $device_architecture = armv8l ]; then wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/arm/static/bin/busybox fi From 890a9daf1869f295fa88d9d527ceddce4ae134bf Mon Sep 17 00:00:00 2001 From: JBBgameich Date: Tue, 11 Jul 2017 20:43:42 +0200 Subject: [PATCH 8/9] Make if a little more efficient --- halium-install | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/halium-install b/halium-install index 2419c4a..3ad2b09 100755 --- a/halium-install +++ b/halium-install @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Copyright (c) 2014 Canonical # @@ -53,11 +53,7 @@ check_busybox() else if [ $device_architecture = x86_64 ]; then wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/intel/static/bin/busybox - elif [ $device_architecture = armv7l ]; then - wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/arm/static/bin/busybox - elif [ $device_architecture = aarch64 ]; then - wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/arm/static/bin/busybox - elif [ $device_architecture = armv8l ]; then + elif [ $device_architecture = "armv7l" ] || [ $device_architecture = "aarch64" ] || [ $device_architecture = "armv8l" ]; then wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/arm/static/bin/busybox fi From c2f6c2e91e973fec930fe7ac41aef8ba62123cf2 Mon Sep 17 00:00:00 2001 From: JBBgameich Date: Sat, 15 Jul 2017 10:33:31 +0200 Subject: [PATCH 9/9] Correct test parameter --- halium-install | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/halium-install b/halium-install index 3ad2b09..80669ce 100755 --- a/halium-install +++ b/halium-install @@ -46,7 +46,7 @@ do_chroot() check_busybox() { export device_architecture=$(do_shell "uname -m") - export busybox_exists=$(do_shell "if [ -d /sbin/busybox ]; then echo true; else echo false; fi") + export busybox_exists=$(do_shell "if [ -f /sbin/busybox ]; then echo true; else echo false; fi") if [ $busybox_exists = true ]; then echo 'Using already installed busybox' @@ -56,13 +56,13 @@ check_busybox() elif [ $device_architecture = "armv7l" ] || [ $device_architecture = "aarch64" ] || [ $device_architecture = "armv8l" ]; then wget https://github.com/meefik/busybox/raw/master/app/src/main/assets/arm/static/bin/busybox fi - + adb push busybox /sbin/busybox do_shell "chmod +x /sbin/busybox" do_shell "/sbin/busybox --install /sbin/" + + rm busybox fi - - rm busybox } convert_android_img()