#!/bin/sh
if [ ! -z "$1" ]; then
curl
https://downloads.openwrt.org/snapshots/targets/bcm27xx/bcm2711/openwrt-imagebuilder-bcm27xx-bcm2711.Linux-x86_64.tar.xz -o imagebuilder-bcm27xx-bcm2711.tar.xz
tar -xvJf imagebuilder-bcm27xx-bcm2711.tar.xz
fi
cd openwrt-imagebuilder-bcm27xx-bcm2711.Linux-x86_64
sed -i 's/\(^CONFIG_TARGET_ROOTFS_PARTSIZE=\).*/\1256/' .config
make image PROFILE=rpi-4 PACKAGES="-ppp -ppp-mod-pppoe -luci-proto-ppp -dnsmasq -odhcpd -odhcpd-ipv6only \
kmod-wireguard wireguard-tools luci-proto-wireguard ip6tables-mod-nat kmod-ipt-nat6 iptables-mod-extra kmod-ipt-extra kmod-ipt-raw kmod-ipt-raw6 tcpdump \
bcm27xx-userland firewall ipset ss \
nginx-all-module luci-mod-admin-full luci-theme-bootstrap luci-app-firewall libiwinfo-lua luci-proto-ipv6 rpcd-mod-rrdns openssl-util uwsgi uwsgi-luci-support \
nginx-mod-luci-ssl nginx-util nginx-ssl-util \
kmod-gpio-dev kmod-hwmon-core kmod-fs-ext4 kmod-nls-utf8 block-mount kmod-usb-storage kmod-usb2 kmod-usb3 usbutils e2fsprogs \
bind-dig bind-dnssec bind-rndc bind-server bind-client \
mc jshn ca-bundle ca-certificates mtr curl wget cifsmount nano iperf iperf3 lsof htop iftop stress luasql-sqlite3 sqlite3-cli python3 python3-cryptography python3-pip \
luci-app-statistics collectd-mod-cpu collectd-mod-interface collectd-mod-load collectd-mod-memory collectd-mod-rrdtool collectd-mod-thermal collectd-mod-uptime collectd-mod-exec" \
FILES=../files/ CONFIG_TARGET_ROOTFS_PARTSIZE=256