-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathcore.sh
More file actions
65 lines (53 loc) · 1.9 KB
/
core.sh
File metadata and controls
65 lines (53 loc) · 1.9 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
#
# Copyright (C) 2017 JBBgameich
# Copyright (C) 2017 TheWiseNerd
#
# License: GPLv3
function convert_rootfs() {
image_size=$1
qemu-img create -f raw $IMAGE_DIR/rootfs.img $image_size
sudo mkfs.ext4 -O ^metadata_csum -O ^64bit -F $IMAGE_DIR/rootfs.img
sudo mount $IMAGE_DIR/rootfs.img $ROOTFS_DIR
sudo tar -xf $ROOTFS_TAR -C $ROOTFS_DIR
}
function convert_androidimage() {
if file $AND_IMAGE | grep "ext4 filesystem"; then
cp system.img $IMAGE_DIR
else
simg2img $AND_IMAGE $IMAGE_DIR/system.img
fi
}
function shrink_images() {
[ -f system.img ] && sudo e2fsck -fy $IMAGE_DIR/system.img >/dev/null
[ -f system.img ] && sudo resize2fs -p -M $IMAGE_DIR/system.img
}
function unmount() {
sudo umount $ROOTFS_DIR
}
function flash_adb() {
adb push $IMAGE_DIR/rootfs.img /data/
adb push $IMAGE_DIR/system.img /data/
}
function flash_rsync() {
# Download prebuilt rsync
echo "[install] Installing rsync on the device ..."
! [ -f $IMAGE_DIR/rsync.bin ] && wget -O $IMAGE_DIR/rsync.bin --continue -q "https://github.com/JBBgameich/rsync-static/releases/download/continuous/rsync-arm"
! [ -f $IMAGE_DIR/rsyncd.conf ] && wget -O $IMAGE_DIR/rsyncd.conf --continue -q "https://raw.githubusercontent.com/JBBgameich/rsync-static/master/rsyncd.conf"
# Push rsync
adb push $IMAGE_DIR/rsync.bin /data/rsync >/dev/null
adb push $IMAGE_DIR/rsyncd.conf /data/rsyncd.conf >/dev/null
adb shell chmod +x /data/rsync
# Start rsync daemon on the device
adb shell '/data/rsync --daemon --config=/data/rsyncd.conf &'
adb forward tcp:6010 tcp:1873
echo "[install] Transferring files ..."
rsync -avz --progress $IMAGE_DIR/rootfs.img rsync://localhost:6010/root/data/rootfs.img
rsync -avz --progress $IMAGE_DIR/system.img rsync://localhost:6010/root/data/system.img
# Kill running rsync instances
adb shell killall rsync
}
function clean() {
# Delete created files from last install
sudo rm $ROOTFS_DIR $IMAGE_DIR -rf
}