-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-files.sh
executable file
·42 lines (33 loc) · 1.08 KB
/
init-files.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
#!/bin/sh
IMGHOME="/opt/Android/"
dd if=/dev/zero of=$IMGHOME/cache.img bs=1M count=2048 && mkfs.ext4 -F $IMGHOME/cache.img || exit 1
mount -t tmpfs tmpfs /Android/ || exit 1
cd /Android/
zcat ${IMGHOME}/ramdisk.img | cpio -id > /dev/null
mount ${IMGHOME}/system.img system -o loop
mount ${IMGHOME}/userdata.img data -o loop
mkdir cache && mount ${IMGHOME}/cache.img cache -o loop
cd -
# Add startup ssh
WHAT="start sshd"
WHERE="/Android/system/etc/init.x86_platform.sh"
grep "^${WHAT}" ${WHERE} >> /dev/null
if [ $? -ne 0 ]; then
echo "${WHAT}" >> ${WHERE}
fi
# Change ssh port to 2222
WHERE="/Android/system/etc/ssh/sshd_config"
FROM="^#Port 22"
TO="Port 2222"
sed -E "s/${FROM}/${TO}/" -i ${WHERE}
# copy authorized_keys
mkdir -p /Android/data/ssh/empty
chmod 700 /Android/data/ssh/empty
cp $IMGHOME/authorized_keys /Android/data/ssh/
chmod 600 /Android/data/ssh/authorized_keys
mkdir /Android/data/data/
chown 1000.1000 /Android/data/data/
chmod 771 /Android/data/data/
mkdir /Android/data/tmp
cat $IMGHOME/dhcpcd.conf > /Android/system/etc/dhcpcd/dhcpcd.conf
echo > /proc/sys/kernel/hotplug