From 4c28c03629d8485da3f54c2b511a3186b923458c Mon Sep 17 00:00:00 2001 From: Eric Sauvageau Date: Mon, 27 Jan 2020 11:48:38 -0500 Subject: [PATCH 1/4] other: make get_webui_page() handle existing mounts, and use a global for returning its result; rename function to match namespace --- release/src/router/others/helper.sh | 33 +++++++++++++++-------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/release/src/router/others/helper.sh b/release/src/router/others/helper.sh index 080a98cad03..ba621f30867 100755 --- a/release/src/router/others/helper.sh +++ b/release/src/router/others/helper.sh @@ -1,7 +1,7 @@ #!/bin/sh # Asuswrt-Merlin helper functions -# For use with Postconf scripts (and others) +# For use with Postconf or addon scripts _quote() { printf "%s\n" "$1" | sed 's/[]\/$*.^&[]/\\&/g' @@ -36,21 +36,23 @@ pc_delete() { sed -i "/$PATTERN/d" $2 } -# This function will return the first available custom webui page, allowing you -# to use it within your script. "none" is returned if all 5 pages are already -# in use. - -get_webui_page() { - for i in 1 2 3 4 5 6 7 8 9 10 - do - page=/www/ext/user$i.asp - if [ ! -f $page ] - then - echo user$i.asp +# This function is used to find either the first available mount point for a +# new custom webui page, or return the mount point currently used if your page +# is already mounted on the webui. +# +# This will take the full path to the new page as argument. +# On return, the am_webui_page variable with will contain either the filename +# of the first available mount point, the filename your page is already using, +# or "none" if there are no available mount points. +am_get_webui_page() { + for i in 1 2 3 4 5 6 7 8 9 10; do + page="/www/user/user$i.asp" + if [ ! -f "$page" ] || [ "$(md5sum < "$1")" = "$(md5sum < "$page")" ]; then + am_webui_page="user$i.asp" return fi done - echo "none" + am_webui_page="none" } @@ -58,7 +60,7 @@ _am_settings_path=/jffs/addons/custom_settings.txt # This function will return the value associated to a specific variable. # Example: VERSION=$(am_settings_get addon_version) -am_settings_get () { +am_settings_get() { if [ ! -f $_am_settings_path ]; then touch $_am_settings_path fi @@ -67,8 +69,7 @@ am_settings_get () { # This function will set a variable to the desired value. # Example: am_settings_set addon_title Cool Addon 1.0 - -am_settings_set () { +am_settings_set() { if [ ! -f $_am_settings_path ]; then touch $_am_settings_path fi From bf76428346836032a0bacaa3ad15e9fa7ad4d67d Mon Sep 17 00:00:00 2001 From: Eric Sauvageau Date: Wed, 29 Jan 2020 12:42:30 -0500 Subject: [PATCH 2/4] amtm: further streamlined the main script, some functions moved to external component --- release/src/router/others/amtm | 209 ++++++--------------------------- 1 file changed, 37 insertions(+), 172 deletions(-) diff --git a/release/src/router/others/amtm b/release/src/router/others/amtm index 144333b8132..2e5dfff37e8 100755 --- a/release/src/router/others/amtm +++ b/release/src/router/others/amtm @@ -1,5 +1,4 @@ #!/bin/sh -#bof # amtm is free to use under the GNU General Public License version 3 (GPL-3.0) # https://opensource.org/licenses/GPL-3.0 @@ -11,62 +10,15 @@ add=/jffs/addons/amtm amtmURL=https://fwupdate.asuswrt-merlin.net/amtm_fw - -ascii_logo(){ - echo " _" - echo " ____ ____ | |_ ____" - echo " / _ | \| _)| \ " - echo " ( ( | | | | | |__| | | |" - echo " \_||_|_|_|_|\___)_|_|_|" - echo - echo " $1" -} - -about_amtm(){ - p_e_l - echo " amtm, the $title - Version $version FW, released on $release - (Built-in firmware version) - - amtm is a front end that manages popular scripts - for wireless routers running Asuswrt-Merlin firmware. - - For updates and discussion visit this thread: - https://www.snbforums.com/threads/amtm-the-snbforums-asuswrt-merlin-terminal-menu.42415 - - Proudly coded by thelonelycoder: - Copyright (c) 2016-2066 thelonelycoder - All Rights Reserved - https://www.snbforums.com/members/thelonelycoder.25480 - https://diversion.ch/amtm.html - - $contributors - - amtm License: - amtm is free to use under the GNU General - Public License, version 3 (GPL-3.0). - https://opensource.org/licenses/GPL-3.0 - - Follow amtm on Twitter or Reddit: - https://twitter.com/DiversionBlock - https://www.reddit.com/r/diversion" - p_r_l - p_e_t "return to menu" - show_amtm menu -} +amtmRev=0 a_m(){ [ -z "$am" ] && am=$1 || am="$am\\n$1";} -c_e(){ [ ! -f /opt/bin/opkg ] && show_amtm " $1 requires the Entware repository\\n installed. Enter ${GN_BG}ep${NC} to install Entware now.";} c_nl(){ [ -n "$(tail -c2 "$1")" ] && echo >> "$1";} -c_j_s(){ if [ ! -f "$1" ]; then echo "#!/bin/sh" >"$1"; echo >>"$1"; elif [ -f "$1" ] && ! head -1 "$1" | grep -qE "^#!/bin/sh"; then c_nl "$1"; echo >>"$1"; sed -i '1s~^~#!/bin/sh\n~' "$1";fi; d_t_u "$1"; c_nl "$1"; [ ! -x "$1" ] && chmod 0755 "$1";} -c_d(){ p_e_l;while true;do printf " Continue? [1=Yes e=Exit] ";read -r continue;case "$continue" in 1)echo;break;;[Ee])am=;show_amtm menu;break;;*)printf "\\n input is not an option\\n\\n";;esac done;} c_url(){ /usr/sbin/curl -fsNL --retry 2 --connect-timeout 3 -m 8 "$@";} d_t_u(){ dos2unix < $1 | cmp -s - $1;[ "$?" = 1 ] && dos2unix $1;} -p_e_t(){ printf "\\n Press Enter to $1 ";read -r;echo;} p_r_l(){ echo "${R}_____________________________________________${NC}";} p_e_l(){ p_r_l;echo;} r_w_e(){ [ "$(sed '/^[[:space:]]*$/d; /#!\/bin\/sh/d' "$1" | wc -c)" = 0 ] && rm "$1";} -r_m(){ [ -f "${add}/$1" ] && rm -f "${add}/$1";} -s_p(){ for i in "$1"/*; do if [ -d "$i" ]; then s_p "$i";elif [ -f "$i" ]; then [ ! -w "$i" ] && chmod 666 "$i";d_t_u "$i";fi;done;} theme_standard(){ R='';R_BG='';E_BG='';GN='';GN_BG='';B='';GY='';NC='';COR=20;} theme_green(){ R='';R_BG='';E_BG='';GN='';GN_BG='';B='';GY='';NC='';COR=20;} theme_blue(){ R='';R_BG='';E_BG='';GN='';GN_BG='';B='';GY='';NC='';COR=21;} @@ -81,13 +33,13 @@ theme_basic(){ R='';R_BG=;E_BG=;GN=;GN_BG=;B=;GY='';NC='';COR=15;} f_b_url(){ a_m " ! using ${R}fallback server${NC} diversion.ch\\n";amtmURL=https://diversion.ch/amtm_fw;} c_t(){ - [ -f "${add}"/.amtm_theme ] && . "${add}"/.amtm_theme divconf=/opt/share/diversion/.conf/diversion.conf - if [ -s "$divconf" ]; then - [ ! -f "${add}"/.amtm_theme ] && theme="$(grep "THEME=" "$divconf" | sed -e 's/THEME=//')" + if [ -f "${add}"/.amtm_theme ]; then + . "${add}"/.amtm_theme + else + [ -s "$divconf" ] && theme="$(grep "THEME=" "$divconf" | sed -e 's/THEME=//')" fi - [ "$theme" ] || theme_amtm new - theme_$theme + [ "$theme" ] && theme_$theme || theme_amtm new } g_m(){ @@ -128,41 +80,10 @@ g_m(){ fi } -reset_amtm(){ - p_e_l - echo " Do you want to reset amtm settings now?" - echo - echo " Note that resetting amtm will not remove or" - echo " uninstall any installed SNBForum scripts." - echo - echo " However, it will remove the Disk check" - echo " script and log, the Format disk log and the" - echo " reboot scheduler when found." - c_d - if [ -f /jffs/scripts/disk-check ]; then - sed -i '\~/jffs/scripts/disk-check ~d' /jffs/scripts/pre-mount - r_w_e /jffs/scripts/pre-mount - rm -f /jffs/scripts/disk-check - fi - if [ -f /jffs/scripts/init-start ] && grep -qE "amtm_RebootScheduler" /jffs/scripts/init-start; then - sed -i '\~amtm_RebootScheduler~d' /jffs/scripts/init-start - r_w_e /jffs/scripts/init-start - cru d amtm_RebootScheduler - fi - rm -rf "${add}" - clear - ascii_logo " amtm settings reset" - echo - echo " Goodbye!" - echo - exit 0 -} - theme_amtm(){ p_e_l if [ -z "$1" ]; then - printf " This changes the amtm theme. All used colors\\n are shown in the themes below.\\n" - printf "\\n Your current theme is: ${R_BG} $theme ${NC}\\n\\n" + printf " All colors in use are shown.\\n Your current theme is: ${R_BG} $theme ${NC}\\n\\n" else printf " Select a theme that works best in your\\n SSH client. All colors in use are shown.\\n\\n" fi @@ -195,8 +116,7 @@ theme_amtm(){ p_r_l ton=12;noad=12 fi - printf "\\n The basic and reduced themes use no or fewer\\n" - printf " colors, service states may not be visible.\\n" + printf "\\n The basic and reduced themes use no or fewer\\n colors, service states may not be visible.\\n" theme_standard while true; do if [ -z "$1" ]; then @@ -228,98 +148,44 @@ theme_amtm(){ [ "$1" ] || show_amtm " changed theme to $theme" } -update_amtm(){ - urlNOK= - if ! c_url "$amtmURL/amtm.mod" | grep -q "^version="; then - urlNOK=1 - f_b_url +init_amtm(){ + [ -d "${add}" ] && fmd= || fmd=1 + mkdir -p "${add}/a_fw" + if [ ! -d "${add}" ]; then + printf "\\n amtm failed to create the directory\\n ${add}\\n Please investigate. Aborting amtm now.\\n\\n";exit 1 fi - if [ "$urlNOK" ] && ! c_url "$amtmURL/amtm.mod" | grep -q "^version="; then - if [ "$su" = 1 ]; then - updErr=1 - thisrem=" ${E_BG}upd err${NC}" - amtmUpd=0 - else - a_m " Update aborted, could not retrieve version" - show_amtm menu + mv /jffs/amtm-* "${add}" 2> /dev/null;mv /jffs/.amtm_* "${add}" 2> /dev/null + c_t + if [ -f /jffs/scripts/amtm ] || [ -f /opt/bin/amtm ]; then + rm -f /jffs/scripts/amtm;rm -f /opt/bin/amtm + if [ -f "/jffs/configs/profile.add" ]; then + sed -i '/alias amtm=/d' /jffs/configs/profile.add >/dev/null + r_w_e /jffs/configs/profile.add + unalias amtm 2> /dev/null fi + a_m " amtm migrated to integrated firmware version" else - urlNOK= + a_m " Initializing amtm for first run" fi - if [ -z "$urlNOK" ]; then - amtmRemotever="$(c_url "$amtmURL/amtm.mod" | grep "^version=" | sed -e 's/version=//')" - localmd5="$(md5sum "${add}"/a_fw/amtm.mod | awk '{print $1}')" - remotemd5="$(c_url "$amtmURL/amtm.mod" | md5sum | awk '{print $1}')" - - if [ "$su" = 1 ]; then - if [ "$version" != "$amtmRemotever" ]; then - thisrem="${E_BG}-> v$amtmRemotever${NC}" - amtmUpd=1 - elif [ "$localmd5" != "$remotemd5" ]; then - thisrem="${E_BG}-> min upd${NC}" - amtmUpd=2 - else - thisrem="${GN_BG}v$version${NC}" - amtmUpd=0 - fi - else - if [ "$version" != "$amtmRemotever" ]; then - a_m " amtm updated from v$version to v$amtmRemotever" - elif [ "$localmd5" != "$remotemd5" ]; then - a_m " amtm minor version update applied" - else - a_m " amtm force updated to v$amtmRemotever" - fi - get_i_modules "${add}" - exec "$0" "$am" - fi + [ "$fmd" ] && a_m " - Created ${GN}${add}${NC} directory" + if [ "$(nvram get jffs2_scripts)" != 1 ]; then + a_m " - JFFS custom scripts and configs enabled" + nvram set jffs2_scripts=1 + nvram commit fi + g_m amtm.mod new + if [ ! -f "${add}"/a_fw/amtm.mod ]; then + p_e_l + printf "$am\\n\\n Exiting amtm now\\n" + p_e_l + exit 1 + fi + exec "$0" "$am" } run_amtm(){ if [ ! -f "${add}"/a_fw/amtm.mod ] || [ -f /jffs/scripts/amtm ]; then - mkdir -p /jffs/scripts - [ -d "${add}" ] && fmd= || fmd=1 - mkdir -p "${add}/a_fw" - - if [ ! -d "${add}" ]; then - printf "\\n amtm failed to create the directory\\n ${add}\\n Please investigate. Aborting amtm now.\\n\\n" - exit 1 - fi - - [ -f /jffs/.amtm_theme ] && mv /jffs/.amtm_theme "${add}" - [ -f /jffs/amtm-format-disk.log ] && mv /jffs/amtm-format-disk.log "${add}" - [ -f /jffs/amtm-disk-check.log ] && mv /jffs/amtm-disk-check.log "${add}" - - c_t - - if [ -f /jffs/scripts/amtm ] || [ -f /opt/bin/amtm ]; then - rm -f /jffs/scripts/amtm - rm -f /opt/bin/amtm - if [ -f "/jffs/configs/profile.add" ]; then - sed -i '/alias amtm=/d' /jffs/configs/profile.add >/dev/null - r_w_e /jffs/configs/profile.add - fi - a_m " amtm migrated to integrated firmware version" - else - a_m " Initializing amtm for first run" - fi - - [ "$fmd" ] && a_m " - Created ${GN}${add}${NC} directory" - - if [ "$(nvram get jffs2_scripts)" != 1 ]; then - a_m " - JFFS custom scripts and configs enabled" - nvram set jffs2_scripts=1 - nvram commit - fi - g_m amtm.mod new - if [ ! -f "${add}"/a_fw/amtm.mod ]; then - p_e_l - printf "$am\\n\\n Exiting amtm now\\n" - p_e_l - exit 1 - fi - exec "$0" "$am" + init_amtm elif [ -z "$1" ]; then [ "$am" ] && show_amtm "$am" || show_amtm menu elif [ "$1" = tpu ]; then @@ -332,4 +198,3 @@ run_amtm(){ } [ -f "${add}"/a_fw/amtm.mod ] && . "${add}"/a_fw/amtm.mod run_amtm "$@" -#eof From 1b24d4b82633c61c2a7309e5b33990eb4a268dd1 Mon Sep 17 00:00:00 2001 From: dave14305 <44532942+dave14305@users.noreply.github.com> Date: Thu, 30 Jan 2020 10:55:49 -0500 Subject: [PATCH 3/4] rc: fix dnsfilter IPv6 additions to dnsmasq.conf (#416) Make the max index automatically adjust to the size of the dnsfilter server array. --- release/src/router/rc/dnsfilter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/src/router/rc/dnsfilter.c b/release/src/router/rc/dnsfilter.c index 77e9e20d087..2ac7e6f4c3b 100644 --- a/release/src/router/rc/dnsfilter.c +++ b/release/src/router/rc/dnsfilter.c @@ -256,7 +256,7 @@ void dnsfilter_setup_dnsmasq(FILE *fp) { defmode = nvram_get_int("dnsfilter_mode"); - for (dnsmode = 1; dnsmode < 13; dnsmode++) { + for (dnsmode = 1; dnsmode < (sizeof(server6_table)/sizeof(server6_table[0])); dnsmode++) { if (dnsmode == defmode) continue; count = get_dns_filter(AF_INET6, dnsmode, server); From 9c5c1584d5235f1c32d5803b402f91b9ec4bb2f3 Mon Sep 17 00:00:00 2001 From: Eric Sauvageau Date: Fri, 31 Jan 2020 12:17:10 -0500 Subject: [PATCH 4/4] Bumped revision to beta 1 --- Changelog-NG.txt | 42 ++++++++++++++++++++++++++++++------- release/src-rt/version.conf | 2 +- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/Changelog-NG.txt b/Changelog-NG.txt index 8bcd1304ddf..6778de4d37f 100644 --- a/Changelog-NG.txt +++ b/Changelog-NG.txt @@ -1,7 +1,10 @@ Asuswrt-Merlin 384/NG Changelog =============================== -384.15 (xx-xxx-xxxx) +384.15 (xx-xxx-2020) + The RT-AC87U and RT-AC3200 are not supported by this release, see + the 384.13_3 release released separately for these two models. + - NEW: wan-event script. The first parameter will be the WAN unit (0 for first WAN, 1 for secondary). The second parameter will be a string describing the type of event (init, @@ -14,7 +17,8 @@ Asuswrt-Merlin 384/NG Changelog to ten different pages that can be added anywhere within the webui, and a dedicated storage repository for your settings, which can be interacted with through your - custom web page. See the Wiki for more information: + custom web page or through a shell script. + See the Wiki for more information: https://github.com/RMerl/asuswrt-merlin/wiki/Addons-API @@ -22,11 +26,14 @@ Asuswrt-Merlin 384/NG Changelog been added to the firmware. Running "amtm" over SSH will give you a menu allowing you to select and install various addons, such as Diversion (ad blocker) or SKynet (an - advanced firewall extension). + advanced firewall extension). The plugins for amtm are + still maintained by its original author (thelonelycoder). - UPDATED: Backported some fixes from 384_81981, mostly related to WAN, port bonding and mdns. - - UPDATED: Merged with GPL 385_10002 (from RT-AC68U) + - UPDATED: Merged GPK 384_7756 for RT-AX88U, which adds OFDMA and + WPA3 support to that model. + - UPDATED: Merged with GPL 385_10002 for other models (from RT-AC68U) - UPDATED: odhcp6c to 1.1-97-ge199804 (themiron) - UPDATED: curl to 7.67.0. - UPDATED: openssl-1.0 to 1.0.2u @@ -34,9 +41,13 @@ Asuswrt-Merlin 384/NG Changelog - CHANGED: Replaced entware-setup.sh script with link to amtm, as using the amtm Entware installer is now the supported method. + - FIXED: Some of the newest DNSFilter servers weren't properly set + up with IPv6 (dave14305) + +384.13_3 (xx-xxx-2020) + This release is only available for the RT-AC87U and RT-AC3200. -384.14_3 (xx-xx-xxxx) (RT-AC87U and RT-AC3200) - NEW: wan-event script. The first parameter will be the WAN unit (0 for first WAN, 1 for secondary). The second parameter will be a string describing the type of event (init, @@ -49,11 +60,28 @@ Asuswrt-Merlin 384/NG Changelog to ten different pages that can be added anywhere within the webui, and a dedicated storage repository for your settings, which can be interacted with through your - custom web page. See the Wiki for more information: + custom web page or through a shell script. + See the Wiki for more information: - (first draft of the documentation, need to be reorganized) https://github.com/RMerl/asuswrt-merlin/wiki/Addons-API + + - NEW: amtm (Asuswrt-Merlin Terminal Menu) by thelonelycoder has + been added to the firmware. Running "amtm" over SSH will + give you a menu allowing you to select and install various + addons, such as Diversion (ad blocker) or SKynet (an + advanced firewall extension). The plugins for amtm are + still maintained by its original author (thelonelycoder). + + - UPDATED: odhcp6c to 1.1-97-ge199804 (themiron) + - UPDATED: openssl-1.0 to 1.0.2u - UPDATED: curl to 7.67.0. + - UPDATED: OpenVPN to 2.4.8. + - UPDATED: dnsmasq to 2.80-114-ge40d8be (themiron) + - CHANGED: Replaced entware-setup.sh script with link to amtm, as + using the amtm Entware installer is now the supported + method. + - FIXED: Some of the newest DNSFilter servers weren't properly set + up with IPv6 (dave14305) 384.14_2 (1-1-2020) diff --git a/release/src-rt/version.conf b/release/src-rt/version.conf index 9121d3f897c..a6ed709ae62 100644 --- a/release/src-rt/version.conf +++ b/release/src-rt/version.conf @@ -1,5 +1,5 @@ KERNEL_VER=3.0 FS_VER=0.4 SERIALNO=384.15 -EXTENDNO=alpha2 +EXTENDNO=beta1 RCNO=0