Skip to content

Check if busybox exists #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
37 changes: 36 additions & 1 deletion halium-install
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work with /bin/sh, so I switched to bash. If you know any reason why we should only use the sh, please report :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends what's symlinked to /bin/sh. On Arch it's bash by default but I don't know about other distros. /bin/bash ensures we get bash.

#
# Copyright (c) 2014 Canonical
#
Expand Down Expand Up @@ -38,6 +38,33 @@ do_shell()
adb shell "$@"
}

do_chroot()
{
do_shell "chroot /cache/system $@"
}

check_busybox()
{
export device_architecture=$(do_shell "uname -m")
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'
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" ] || [ $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
}

convert_android_img()
{
if file $SYSIMG | grep -v ": Linux rev 1.0 ext4" >/dev/null; then
Expand Down Expand Up @@ -165,6 +192,7 @@ if ! adb devices | grep -q recovery; then
exit 1
fi

check_busybox
check_mounts

WORKDIR=$(mktemp -d /tmp/halium-install.XXXXX)
Expand All @@ -190,6 +218,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"
Expand Down