-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdeploy.sh
executable file
·52 lines (47 loc) · 1.51 KB
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
set -e
# Config
TARGET_DEVICE="yggdrasil"
TARGET_PROP="ro.build.product"
# Script
if [ -e backup.sh ]; then
read -p ">> Would you like to backup the current kernel & modules on the device (y/N)? " ans
[[ "${ans:0:1}" = "Y" || "${ans:0:1}" = "y" ]] && source backup.sh
fi
cd "$(dirname "$0")"
if [[ ! -e boot.img || ! -e kernel-modules.tar.gz ]]; then
echo ">> ERROR: Please place a 'boot.img' along with 'kernel-modules.tar.gz' in the"
echo " directory of this deployment script!"
exit 1
fi
device=""
echo ">> Waiting for a device in recovery mode..."
while true; do
if adb devices | grep -q recovery; then
device="$(adb shell getprop $TARGET_PROP)"
break
fi
sleep 1
done
if [ "$device" != "$TARGET_DEVICE" ]; then
echo ">> Detected device '$device' does not match deploy target '$TARGET_DEVICE';"
echo " please disconnect any other potentially conflicting devices and try again!"
exit 1
fi
echo ">> Detected your '$device' in recovery mode; pushing & flashing kernel build artifacts..."
adb push boot.img kernel-modules.tar.gz /tmp
adb shell << EOF
dd bs=4M if=/tmp/boot.img of=/dev/block/bootdevice/by-name/boot
if [ -e /system/var/lib/lxc/android/android-rootfs.img ]; then
mkdir /a
mount /system/var/lib/lxc/android/android-rootfs.img /a
tar -xvf /tmp/kernel-modules.tar.gz -C /a/system/lib/modules/
chown root:root /a/system/lib/modules/*
umount /a
else
tar -xvf /tmp/kernel-modules.tar.gz -C /system/lib/modules/
chown root:root /system/lib/modules/*
fi
sync && reboot
EOF
echo ">> Done!"