-
Notifications
You must be signed in to change notification settings - Fork 30
/
patch.sh
51 lines (49 loc) · 1.27 KB
/
patch.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
#!/bin/sh
echo $1
cd "$1"
rm etc/banner.failsafe
rm etc/board.d/01_leds
rm -rf etc/capabilities
rm etc/init.d/gpio_switch
rm etc/init.d/led
rm etc/openwrt_release
rm etc/openwrt_version
rm etc/os-release
rm etc/rc.d/K10gpio_switch
rm etc/rc.d/S94gpio_switch
rm etc/rc.d/S96led
rm etc/sysupgrade.conf
rm -rf etc/rc.button
rm -rf etc/opkg
rm -rf lib/upgrade
rm -rf usr/lib/opkg
rm -rf usr/lib/os-release
rm sbin/firstboot
rm sbin/sysupgrade
rm sbin/wifi
rm -rf usr/lib/share/acl.d
rm -rf usr/lib/share/libubox
cd lib/preinit
rm 10_indicate_failsafe
rm 30_failsafe_wait
rm 40_run_failsafe_hook
rm 99_10_failsafe_dropbear
rm 99_10_failsafe_login
if [ -f /src/iso/root.7z ]; then
rm /src/iso/root.7z
fi
rootfs="$(dirname "$1""/*")"
bootdir="$(dirname "$2""/*")"
echo "exec /sbin/init" > "$rootfs"/init
echo "echo" > "$rootfs"/sbin/wifi
chmod +x "$rootfs"/init
chmod +x "$rootfs"/sbin/wifi
cd $rootfs || exit
mkdir -p /tmp/cdrom
find . | cpio -H newc -o | gzip -9 >/tmp/cdrom/initrd.gz
cp "$bootdir"/boot/vmlinuz /tmp/cdrom/
packroot="/tmp/ppgwroot.tar"
tar -cf "$packroot" -C "/tmp/cdrom/" ./
rootsha=$(sha256sum $packroot | cut -d ' ' -f 1)
echo "$rootsha" >/src/iso/rootsha.txt
7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -mhe=on -bsp1 -bso1 -bse1 -y -p"$rootsha" "/src/iso/root.7z" "$packroot"