From 80f17733bf6b215847ba65e15e57f05e95d2bfff Mon Sep 17 00:00:00 2001 From: bryan Date: Wed, 23 Feb 2022 16:02:51 -0500 Subject: [PATCH] Refactor profiles and loosen requires --- openwrtbuilder | 65 +++++++++++++++++++++++++++++--------------------- profiles | 23 ++++++++++++++++++ 2 files changed, 61 insertions(+), 27 deletions(-) diff --git a/openwrtbuilder b/openwrtbuilder index c505651..1cc8687 100755 --- a/openwrtbuilder +++ b/openwrtbuilder @@ -154,7 +154,7 @@ installHostDependencies() { getImageBuilder() { debug "${FUNCNAME[0]}" - local _url _filename + local _url _filename _dl_tool if [[ "${P_ARR[release]}" == "snapshot" ]]; then _filename="openwrt-imagebuilder-${P_ARR[target]//\//-}.Linux-x86_64.tar.xz" @@ -175,9 +175,20 @@ getImageBuilder() { # Make sources directory if it does not exist [[ ! -d "$BUILDDIR/sources" ]] && mkdir -p "$BUILDDIR/sources" + if hash axel &>/dev/null; then + _dl_tool="axel" + elif hash curl &>/dev/null; then + _dl_tool="curl" + else + echo "Downloading the ImageBuilder requires axel or curl!" + return 1 + fi + echo "Downloading imagebuilder archive" - debug "axel -o ${P_ARR[source_archive]} $_url" - if ! axel -o "${P_ARR[source_archive]}" "$_url" > /dev/null 2>&1; then + + + debug "$_dl_tool -o ${P_ARR[source_archive]} $_url" + if ! "$_dl_tool" -o "${P_ARR[source_archive]}" "$_url" > /dev/null 2>&1; then echo "Could not download imagebuilder archive" exit 1 fi @@ -209,29 +220,6 @@ addRepos() { } -makeImage() { - debug "${FUNCNAME[0]}" - - # Reuse the existing output - if [[ -d "${P_ARR[out_bin_dir]}" ]]; then - if askOk "${P_ARR[out_bin_dir]} exists. Rebuild?"; then - rm -rf "${P_ARR[out_bin_dir]}" - else - return 0 - fi - fi - - [[ ! -d "${P_ARR[out_bin_dir]}" ]] && mkdir -p "${P_ARR[out_bin_dir]}" - - # build image - debug "make -j4 image BIN_DIR=${P_ARR[out_bin_dir]} PROFILE=${P_ARR[profile]} PACKAGES=${P_ARR[packages]} FILES=$FILESDIR --directory=${P_ARR[source_dir]} > make.log" - if ! make image BIN_DIR="${P_ARR[out_bin_dir]}" PROFILE="${P_ARR[profile]}" PACKAGES="${P_ARR[packages]}" FILES="$FILESDIR" --directory="${P_ARR[source_dir]}" > make.log; then - echo "Make image failed!" - exit 1 - fi -} - - sshBackup() { debug "${FUNCNAME[0]}" @@ -268,6 +256,29 @@ sshBackup() { } +makeImage() { + debug "${FUNCNAME[0]}" + + # Reuse the existing output + if [[ -d "${P_ARR[out_bin_dir]}" ]]; then + if askOk "${P_ARR[out_bin_dir]} exists. Rebuild?"; then + rm -rf "${P_ARR[out_bin_dir]}" + else + return 0 + fi + fi + + [[ ! -d "${P_ARR[out_bin_dir]}" ]] && mkdir -p "${P_ARR[out_bin_dir]}" + + # build image + debug "make -j4 image BIN_DIR=${P_ARR[out_bin_dir]} PROFILE=${P_ARR[profile]} PACKAGES=${P_ARR[packages]} FILES=$FILESDIR --directory=${P_ARR[source_dir]} > make.log" + if ! make image BIN_DIR="${P_ARR[out_bin_dir]}" PROFILE="${P_ARR[profile]}" PACKAGES="${P_ARR[packages]}" FILES="$FILESDIR" --directory="${P_ARR[source_dir]}" > make.log; then + echo "Make image failed!" + exit 1 + fi +} + + flashImage() { debug "${FUNCNAME[0]}" @@ -328,7 +339,7 @@ sshUpgrade() { } -debug() { (( DEBUG )) && echo "Running: " "$@" ; } +debug() { (( DEBUG )) && echo "Running: $*"; } askOk() { diff --git a/profiles b/profiles index c0f2d63..3a8c52c 100644 --- a/profiles +++ b/profiles @@ -81,6 +81,7 @@ r4s['profile']="friendlyarm_nanopi-r4s" r4s['target']="rockchip/armv8" r4s['filesystem']="ext4" r4s['repo']="src/gz stangri_repo https://repo.openwrt.melmac.net" +# fw3 + vpn-policy-routing # r4s['packages']="\ # $default_packages \ # luci-app-upnp \ @@ -106,6 +107,8 @@ r4s['repo']="src/gz stangri_repo https://repo.openwrt.melmac.net" # ip6tables \ # iptables \ # kmod-ipt-offload" + +# fw3 + pbr r4s['packages']="\ $default_packages \ luci-app-upnp \ @@ -132,6 +135,26 @@ r4s['packages']="\ iptables \ kmod-ipt-offload" +# fw4 + pbr +# r4s['packages']="\ +# $default_packages \ +# luci-app-upnp \ +# luci-app-wireguard \ +# luci-app-pbr \ +# pbr-netifd \ +# -dnsmasq \ +# dnsmasq-full \ +# luci-app-ddns \ +# luci-app-sqm \ +# luci-app-statistics \ +# collectd-mod-sensors \ +# collectd-mod-thermal \ +# collectd-mod-conntrack \ +# smcroute \ +# curl \ +# ethtool \ +# kmod-nft-nat6" + declare -Ag x5000r x5000r['profile']="totolink_x5000r" x5000r['target']="ramips/mt7621"