#!/usr/bin/env bash # Stage 3 booster to prepare router for first real boot # Log to the system log and echo if needed log_say() { SCRIPT_NAME=$(basename "$0") echo "${SCRIPT_NAME}: ${1}" logger "${SCRIPT_NAME}: ${1}" } log_say " " log_say " ███████████ ███ █████ " log_say "░░███░░░░░███ ░░░ ░░███ " log_say " ░███ ░███ ████████ ████ █████ █████ ██████ ███████ ██████ " log_say " ░██████████ ░░███░░███░░███ ░░███ ░░███ ░░░░░███ ░░░███░ ███░░███" log_say " ░███░░░░░░ ░███ ░░░ ░███ ░███ ░███ ███████ ░███ ░███████ " log_say " ░███ ░███ ░███ ░░███ ███ ███░░███ ░███ ███░███░░░ " log_say " █████ █████ █████ ░░█████ ░░████████ ░░█████ ░░██████ " log_say "░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░░░░ ░░░░░ ░░░░░░ " log_say " " log_say " " log_say " ███████████ █████ " log_say "░░███░░░░░███ ░░███ " log_say " ░███ ░███ ██████ █████ ████ ███████ ██████ ████████ " log_say " ░██████████ ███░░███░░███ ░███ ░░░███░ ███░░███░░███░░███ " log_say " ░███░░░░░███ ░███ ░███ ░███ ░███ ░███ ░███████ ░███ ░░░ " log_say " ░███ ░███ ░███ ░███ ░███ ░███ ░███ ███░███░░░ ░███ " log_say " █████ █████░░██████ ░░████████ ░░█████ ░░██████ █████ " log_say "░░░░░ ░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░ ░░░░░░ ░░░░░ " # Command to wait for Internet connection wait_for_internet() { while ! ping -q -c3 1.1.1.1 >/dev/null 2>&1; do log_say "Waiting for Internet connection..." sleep 1 done log_say "Internet connection established" } # Wait for Internet connection wait_for_internet # Command to wait for opkg to finish wait_for_opkg() { while pgrep -x opkg >/dev/null; do log_say "Waiting for opkg to finish..." sleep 1 done log_say "opkg is released, our turn!" } # Wait for opkg to finish wait_for_opkg # install some more packages that don't need any extra steps log_say "updating all packages!" log_say " " log_say " ███████████ ███ █████ " log_say "░░███░░░░░███ ░░░ ░░███ " log_say " ░███ ░███ ████████ ████ █████ █████ ██████ ███████ ██████ " log_say " ░██████████ ░░███░░███░░███ ░░███ ░░███ ░░░░░███ ░░░███░ ███░░███" log_say " ░███░░░░░░ ░███ ░░░ ░███ ░███ ░███ ███████ ░███ ░███████ " log_say " ░███ ░███ ░███ ░░███ ███ ███░░███ ░███ ███░███░░░ " log_say " █████ █████ █████ ░░█████ ░░████████ ░░█████ ░░██████ " log_say "░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░░░░ ░░░░░ ░░░░░░ " log_say " " log_say " " log_say " ███████████ █████ " log_say "░░███░░░░░███ ░░███ " log_say " ░███ ░███ ██████ █████ ████ ███████ ██████ ████████ " log_say " ░██████████ ███░░███░░███ ░███ ░░░███░ ███░░███░░███░░███ " log_say " ░███░░░░░███ ░███ ░███ ░███ ░███ ░███ ░███████ ░███ ░░░ " log_say " ░███ ░███ ░███ ░███ ░███ ░███ ░███ ███░███░░░ ░███ " log_say " █████ █████░░██████ ░░████████ ░░█████ ░░██████ █████ " log_say "░░░░░ ░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░ ░░░░░░ ░░░░░ " opkg update ## INSTALL MESH ## log_say "Installing Mesh Packages..." opkg install tgrouterappstore luci-app-shortcutmenu luci-app-poweroff luci-app-wizard opkg remove wpad wpad-mbedtls wpad-basic wpad-basic-openssl wpad-basic-wolfssl wpad-wolfssl opkg install wpad-mesh-openssl kmod-batman-adv batctl avahi-autoipd batctl-full luci-app-dawn opkg install luci-app-easymesh opkg install luci-proto-batman-adv #Go Go Packages opkg install base-files busybox cgi-io dropbear firewall fstools fwtool getrandom hostapd-common ip6tables iptables iw iwinfo jshn jsonfilter kernel opkg install kmod-ath kmod-ath9k kmod-ath9k-common kmod-cfg80211 kmod-gpio-button-hotplug kmod-ip6tables kmod-ipt-conntrack kmod-ipt-core kmod-ipt-nat kmod-ipt-offload opkg install kmod-lib-crc-ccitt kmod-mac80211 kmod-nf-conntrack kmod-nf-conntrack6 kmod-nf-flow kmod-nf-ipt kmod-nf-ipt6 kmod-nf-nat kmod-nf-reject kmod-nf-reject6 kmod-nls-base opkg install kmod-ppp kmod-pppoe kmod-pppox kmod-slhc kmod-usb-core kmod-usb-ehci libblobmsg-json20210516 libc libgcc1 libip4tc2 libip6tc2 libiwinfo-data libiwinfo-lua libiwinfo20210430 opkg install libjson-c5 libjson-script20210516 liblua5.1.5 liblucihttp-lua liblucihttp0 libnl-tiny1 libpthread libubox20210516 libubus-lua libubus20210630 libuci20130104 opkg install libuclient20201210 libustream-wolfssl20201210 libxtables12 logd lua luci luci-app-firewall luci-app-opkg luci-base luci-lib-base luci-lib-ip luci-lib-jsonc luci-lib-nixio opkg install luci-mod-admin-full luci-mod-network luci-mod-status luci-mod-system opkg install luci-proto-ipv6 luci-proto-ppp luci-ssl luci-theme-bootstrap luci-app-statistics luci-mod-dashboard luci-app-vnstat opkg install mtd netifd odhcp6c odhcpd-ipv6only openwrt-keyring opkg ppp ppp-mod-pppoe procd px5g-wolfssl opkg install openwrt-keyring ppp ppp-mod-pppoe procd px5g-wolfssl kmod-usb-storage block-mount kmod-fs-ext4 kmod-fs-exfat luci-compat luci-lib-ipkg opkg install kmod-rt2800-usb rt2800-usb-firmware kmod-cfg80211 kmod-lib80211 kmod-mac80211 kmod-rtl8192cu luci-base luci-ssl opkg install luci-theme-bootstrap kmod-usb-storage kmod-usb-ohci kmod-usb-uhci e2fsprogs fdisk resize2fs htop debootstrap luci-compat luci-lib-ipkg opkg install bash wget kmod-usb-net-rndis luci-app-commands rpcd-mod-luci kmod-usb-net-cdc-eem opkg install kmod-usb-net-cdc-ether kmod-usb-net-cdc-subset kmod-nls-base kmod-usb-core kmod-usb-net kmod-usb-net-cdc-ether kmod-usb2 kmod-usb-net-ipheth libimobiledevice luci-app-nlbwmon luci-app-adblock opkg install nano ## Remove DNSMasq opkg remove dnsmasq rm /etc/config/dhcp opkg install dnsmasq-full log_say "PrivateRouter update complete!" # Cleanup our auto-provision and prepare for first real boot [ -d /etc/auto-provision ] && rm -rf /etc/auto-provision [ -f /etc/rc.local ] && echo "# Empty by design" > /etc/rc.local # Download our startup.tar.gz with our startup scripts and load them in log_say "Downloading startup.tar.gz" wget -q -O /tmp/startup.tar.gz https://github.com/PrivateRouter-LLC/script-repo/raw/main/startup-scripts/startup.tar.gz log_say "Extracting startup.tar.gz" tar -xzf /tmp/startup.tar.gz -C /etc log_say "Removing our script before reboot" rm -- "$0" log_say "Reboot to uptake our rc.custom boot script" #reboot