What's new

amtm amtm - the Asuswrt-Merlin Terminal Menu

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

That's up to the firmware, not the script which partition gets mounted first.
In that case, I will disable full checks on the non-Entware partition and manually run full checks from time to time.
Code:
# tune2fs -c 0 -i 0 /dev/sda2
tune2fs 1.42.13 (17-May-2015)
Setting maximal mount count to -1
Setting interval between checks to 0 seconds
Unmount
Code:
# umount /tmp/mnt/smb
Full check
Code:
# e2fsck -p -f -v /dev/sda2

         143 inodes used (0.00%, out of 26214400)
           0 non-contiguous files (0.0%)
           0 non-contiguous directories (0.0%)
             # of inodes with ind/dind/tind blocks: 0/0/0
             Extent depth histogram: 133
     1652106 blocks used (6.30%, out of 26214400)
           0 bad blocks
           0 large files

         111 regular files
          23 directories
           0 character device files
           0 block device files
           0 fifos
           0 links
           0 symbolic links (0 fast symbolic links)
           0 sockets
------------
         134 files
Mount
Code:
# mount /dev/sda2 /tmp/mnt/smb
 
Hello,

I just installed this swap file you refer to and the free memory on the AC86U dropped from about 150MB to 30 MB. Is this to be expected by using the swap file?

The exact same thing happened on my router. I ignored it as I've read the many posts on this site about ram usage in linux. Fast forward about three or four days and I notice that my ram is back to the normal free amount. At first I figured it just took care of itself then I noticed my uptime had went from two plus weeks to one day. I've never had my router self reboot like that. I couldn't find any clues in the log.
 
@thelonelycoder

Update:

I am still working on finishing my script.

I do plan on still submitting the two code blocks to amtm after I done
Just let me know when you're ready, I'll do the coding in amtm.
 
Do you need an exit code or terminal output representing that an update available?

Eg.

/jffs/scripts/myscript -isupdate

-->

Exit code 0 --> no
Exit code 1 --> yes

No, that should be handled by the script directly. Altough it sounds like a food idea. I‘ll think about it.
 
Hi.

Why is there an option to update Entware in the main menu when it is recommended to update it in Diversion anyway?
 
Hi.

Why is there an option to update Entware in the main menu when it is recommended to update it in Diversion anyway?

Not everyone might want to install Diversion. Entware is needed by other scripts though.
 
Ok, I think I squased all the bugs. Feel free to finally include it with amtm.

I have implemented exit codes that will check if the script is currently able to be launched or updated.

Code:
Script Integration:
------CORRECT USUAGE-----------
if [ -e /jffs/scripts/FreshJR_QOS ]  ; then
    if /jffs/scripts/FreshJR_QOS -isinstalled ; then
      #script on disk and installed
      sh /jffs/scripts/FreshJR_QOS -menu
    else
      #script on disk and not installed (uncommon)
      sh /jffs/scripts/FreshJR_QOS -install
    fi
else
    #script not on disk
    curl "https://raw.githubusercontent.com/FreshJR07/FreshJR_QOS/master/FreshJR_QOS.sh" -o /jffs/scripts/FreshJR_QOS --create-dirs && curl "https://raw.githubusercontent.com/FreshJR07/FreshJR_QOS/master/FreshJR_QoS_Stats.asp" -o /jffs/scripts/www_FreshJR_QoS_Stats.asp && sh /jffs/scripts/FreshJR_QOS -install
fi

----INCORRECT USUAGE-----------
if [ /jffs/scripts/FreshJR_QOS -isinstalled ] ; then
  sh /jffs/scripts/FreshJR_QOS -menu
else
  sh /jffs/scripts/FreshJR_QOS -install
fi

Be careful when using exit codes in if statements. Do not nest the exist code with [ ] or it will always return true.

Code:
Exit Code:  Implementation pitfall
------CORRECT USUAGE-----------
./exitcode_0 && echo "TRUE" || echo "FALSE" ; TRUE
./exitcode_1 && echo "TRUE" || echo "FALSE" ; FALSE


----INCORRECT USUAGE-----------
[ ./exitcode_0 ] && echo "TRUE" || echo "FALSE" ; TRUE
[ ./exitcode_1 ] && echo "TRUE" || echo "FALSE" ; TRUE


---

Here are the raw code blocks for the relavent portions if you don't want to use exit codes.

Code:
  'isinstalled')
        if grep -q -x '/jffs/scripts/FreshJR_QOS -start $1 & ' /jffs/scripts/firewall-start ; then
            exit 0        #script IS installed
        else
            exit 1        #script in NOT installed
        fi
    ;;
  'isuptodate')
        url="https://raw.githubusercontent.com/FreshJR07/FreshJR_QOS/master/FreshJR_QOS.sh"
        remotever=$(curl -fsN --retry 3 ${url} | grep "^version=" | sed -e s/version=//)
        if [ "$version" == "$remotever" ]; then
            exit 0         #script IS current
        else
            exit 1        #script is NOT up to date
        fi
    ;;

Obviously you need to only install at user request. Was just meant as a template so you don't have to go digging through my code for relevant portions.

Let me know if you need something!
 
Last edited:
Ok, I think I squased all the bugs. Feel free to finally include it with amtm.

I have implemented exit codes that will check if the script is currently able to be launched or updated.

Code:
Script Integration:
------CORRECT USUAGE-----------
if [ -e /jffs/scripts/FreshJR_QOS ]  ; then
    if /jffs/scripts/FreshJR_QOS -isinstalled ; then
      #script on disk and installed
      sh /jffs/scripts/FreshJR_QOS -menu
    else
      #script on disk and not installed (uncommon)
      sh /jffs/scripts/FreshJR_QOS -install
    fi
else
    #script not on disk
    curl "https://raw.githubusercontent.com/FreshJR07/FreshJR_QOS/master/FreshJR_QOS.sh" -o /jffs/scripts/FreshJR_QOS --create-dirs && curl "https://raw.githubusercontent.com/FreshJR07/FreshJR_QOS/master/FreshJR_QoS_Stats.asp" -o /jffs/scripts/www_FreshJR_QoS_Stats.asp && sh /jffs/scripts/FreshJR_QOS -install
fi

----INCORRECT USUAGE-----------
if [ /jffs/scripts/FreshJR_QOS -isinstalled ] ; then
  sh /jffs/scripts/FreshJR_QOS -menu
else
  sh /jffs/scripts/FreshJR_QOS -install
fi

Be careful when using exit codes in if statements. Do not nest the exist code with [ ] or it will always return true.

Code:
Exit Code:  Implementation pitfall
------CORRECT USUAGE-----------
./exitcode_0 && echo "TRUE" || echo "FALSE" ; TRUE
./exitcode_1 && echo "TRUE" || echo "FALSE" ; FALSE


----INCORRECT USUAGE-----------
[ ./exitcode_0 ] && echo "TRUE" || echo "FALSE" ; TRUE
[ ./exitcode_1 ] && echo "TRUE" || echo "FALSE" ; TRUE


---

Here are the raw code blocks for the relavent portions if you don't want to use exit codes.

Code:
  'isinstalled')
        if grep -q -x '/jffs/scripts/FreshJR_QOS -start $1 & ' /jffs/scripts/firewall-start ; then
            exit 0        #script IS installed
        else
            exit 1        #script in NOT installed
        fi
    ;;
  'isuptodate')
        url="https://raw.githubusercontent.com/FreshJR07/FreshJR_QOS/master/FreshJR_QOS.sh"
        remotever=$(curl -fsN --retry 3 ${url} | grep "^version=" | sed -e s/version=//)
        if [ "$version" == "$remotever" ]; then
            exit 0         #script IS current
        else
            exit 1        #script is NOT up to date
        fi
    ;;

Obviously you need to only install at user request. Was just meant as a template so you don't have to go digging through my code for relevant portions.

Let me know if you need something!
Another worthy script, included in AMTM, it just gets better and better all the time. Talk about added value!!!:D:D:cool::cool:
 
I'm not sure what the standard approach is, but perhaps it'd be worth running 'chmod a+x' to make /jffs/scripts/FreshJR_QOS executable. That way you could run it directly without needing to use sh first (the if installed statement might fail due to permission denied). You could also use -x instead of -e to check if it exists and is executable.
 
I'm not sure what the standard approach is, but perhaps it'd be worth running 'chmod a+x' to make /jffs/scripts/FreshJR_QOS executable. That way you could run it directly without needing to use sh first (the if installed statement might fail due to permission denied). You could also use -x instead of -e to check if it exists and is executable.

The -install command WILL set the permissions of FreshJR_QOS to executable during the install process.

Running sh /path/to/script has always reliably executed the script, even if it wasn’t marked as executable, and that is why I have omitted a chmod command from the one-line install or as a requirement when following manual instructions.

Correct, if not marked as executable (who knows how it got to this state) it would mean the following line

Code:
if /jffs/scripts/FreshJR_QOS -isinstalled ; then

will return FALSE simply due permissions since FreshJR_QOS is not even able to even launch and check if it’s installed.

But in that scenario (which should not happen since the script is always installed immediately after file transfer) the logic would still correctly default to “not installed” since a proper installation should have set permissions of the script. If the script managed to get into a non-executable state then it should likely be reinstalled.

I do agree setting permissions and checking executability sounds like a proper approach as to not make any assumptions, but I think it would work either way!

I’m sure @thelonelycoder will let me know if I have to change something.
 
Last edited:
Ok, I think I squased all the bugs. Feel free to finally include it with amtm.

I have implemented exit codes that will check if the script is currently able to be launched or updated.

Code:
Script Integration:
------CORRECT USUAGE-----------
if [ -e /jffs/scripts/FreshJR_QOS ]  ; then
    if /jffs/scripts/FreshJR_QOS -isinstalled ; then
      #script on disk and installed
      sh /jffs/scripts/FreshJR_QOS -menu
    else
      #script on disk and not installed (uncommon)
      sh /jffs/scripts/FreshJR_QOS -install
    fi
else
    #script not on disk
    curl "https://raw.githubusercontent.com/FreshJR07/FreshJR_QOS/master/FreshJR_QOS.sh" -o /jffs/scripts/FreshJR_QOS --create-dirs && curl "https://raw.githubusercontent.com/FreshJR07/FreshJR_QOS/master/FreshJR_QoS_Stats.asp" -o /jffs/scripts/www_FreshJR_QoS_Stats.asp && sh /jffs/scripts/FreshJR_QOS -install
fi

----INCORRECT USUAGE-----------
if [ /jffs/scripts/FreshJR_QOS -isinstalled ] ; then
  sh /jffs/scripts/FreshJR_QOS -menu
else
  sh /jffs/scripts/FreshJR_QOS -install
fi

Be careful when using exit codes in if statements. Do not nest the exist code with [ ] or it will always return true.

Code:
Exit Code:  Implementation pitfall
------CORRECT USUAGE-----------
./exitcode_0 && echo "TRUE" || echo "FALSE" ; TRUE
./exitcode_1 && echo "TRUE" || echo "FALSE" ; FALSE


----INCORRECT USUAGE-----------
[ ./exitcode_0 ] && echo "TRUE" || echo "FALSE" ; TRUE
[ ./exitcode_1 ] && echo "TRUE" || echo "FALSE" ; TRUE


---

Here are the raw code blocks for the relavent portions if you don't want to use exit codes.

Code:
  'isinstalled')
        if grep -q -x '/jffs/scripts/FreshJR_QOS -start $1 & ' /jffs/scripts/firewall-start ; then
            exit 0        #script IS installed
        else
            exit 1        #script in NOT installed
        fi
    ;;
  'isuptodate')
        url="https://raw.githubusercontent.com/FreshJR07/FreshJR_QOS/master/FreshJR_QOS.sh"
        remotever=$(curl -fsN --retry 3 ${url} | grep "^version=" | sed -e s/version=//)
        if [ "$version" == "$remotever" ]; then
            exit 0         #script IS current
        else
            exit 1        #script is NOT up to date
        fi
    ;;

Obviously you need to only install at user request. Was just meant as a template so you don't have to go digging through my code for relevant portions.

Let me know if you need something!
Lets see.
- Does not check if QOS is enabled during install. Let user know to enable it after install.
- Modifies /jffs/scripts/init-start for no reason during install (timestamp changes). Why?
- Does not return to an interactive menu after install and has no wording to the effect that customization has to continue in WebUI. I am unsure if some customization has to be done in ShellUI and some in WebUI, though the "about" section has some explanation but not for the current version.
- I would suggest to uniformly use "e" to exit from all (sub) menus, not just the main menu.
- A confirm action before uninstalling, this prevents accidentally uninstalling.

Can you fix these? Thanks.
I will use my own code in amtm to detect installation status and not use the return codes at the moment.
 
Lets see.
1) Does not check if QOS is enabled during install. Let user know to enable it after install.
2) Modifies /jffs/scripts/init-start for no reason during install (timestamp changes). Why?
3) Does not return to an interactive menu after install and has no wording to the effect that customization has to continue in WebUI. I am unsure if some customization has to be done in ShellUI and some in WebUI, though the "about" section has some explanation but not for the current version.
4) I would suggest to uniformly use "e" to exit from all (sub) menus, not just the main menu.
5) A confirm action before uninstalling, this prevents accidentally uninstalling.

Can you fix these? Thanks.
I will use my own code in amtm to detect installation status and not use the return codes at the moment.

Sure, I am open to anything but

1) Installer DOES check if QOS is enabled.
Ideally QOS should be disabled during install as script as modifications are only triggered when QOS is initially enabled.

The logic was that if QoS was enabled during install, a prompt will then appear allowing the user to enter "1" to RestartQoS for convenience sake. This gives users a choice since sometimes people don't want a QoS restart right away.

If they enter anything else a reminder shows up that a QoS restart will have to be done manually at some point in the future.

(Do we need to change this?) I can make the prompt loop endlessly until a "1" or "2" is received, since admittedly sometimes I do press enter twice.
The current logic is to assume "2" for any non "1" input.

2) The init-start timestamp was due to this command
Code:
    sed -i '/FreshJR_QOS/d' /jffs/scripts/init-start 2>/dev/null
That command is a relic to remove very old script entries if they still exist.
It causes no harm (besides the timestamp).

I will change the logic and check for entries exist before applying sed to the file to preserve the time-stamp. Consider this issue closed.

3) It doesn't matter if modifications are done from terminal or WebUI (same fields are present in both).
Many people perfer WebUI so I don't force them into the interactive menu right away.

Should I make a prompt
"Would you like to enter FreshJR [Interactive Mode]? [1=Yes 2=No] : 2
-->
Remember: Modifications can be done from [ WebUI ] or [ /jffs/scripts/FreshJR_QOS -menu ]

or simply for AMTM purposes do you think we should always call "/jffs/scripts/FreshJR_QOS -menu" from your end after install?

4) sure no problem. Consider this issue closed.

5) great it idea. Consider this issue closed.

--

I'll change verbiage in the about command to mention the (-menu) interactive mode.
 
Last edited:
Sure, I am open to anything but

1) Installer DOES check if QOS is enabled.
Ideally QOS should be disabled during install as script as modifications are only triggered when QOS is initially enabled.

The logic was that if QoS was enabled during install, a prompt will then appear allowing the user to enter "1" to automatically RestartQoS for convenience sake.
This gives users a choice since sometimes people don't want a QoS restart right away.

If they enter anything else a reminder shows up that a QoS restart will have to be done manually at some point in the future.

(Do we need to change this?) I can make the prompt loop until a "1" or "2" is received.
It is currently is set to logically assume "2" for any non "1" input.

2) The init-start timestamp was due to this command
Code:
    sed -i '/FreshJR_QOS/d' /jffs/scripts/init-start 2>/dev/null
That command is a relic to remove very old script entries if they still exist.
It causes no harm (besides the timestamp).

I will change the logic and check for entries exist before applying sed to the file to preserve the time-stamp. Consider this issue closed.

3) It doesn't matter if modifications are done from terminal or WebUI (same fields are present in both).
Many people perfer WebUI so I don't force them into the interactive menu right away.

Should I make a prompt
"Would you like to enter FreshJR [Interactive Mode]? [1=Yes 2=No] : 2
-->
Remember: Modifications can be done from [ WebUI ] or [ /jffs/scripts/FreshJR_QOS -menu ]

or for AMTM purposes do you think we should always call "/jffs/scripts/FreshJR_QOS -menu" from your end after install?

4) sure no problem. Consider this issue closed.

5) great it idea. Consider this issue closed.

--

I'll change verbiage in the about command to mention the interactive mode.
1) Makes sense, I did notice the prompt to restart QOS so the check seems to work.
3) I prefer the user is shown a menu after install. You could add some text after a fresh install of how to proceed from here (interactive or WebUI) in the menu somewhere.

I also notice the proper working of the uninstall function. No trace of your script left after uninstalling, not even in nvram. Well done!
 
#update - changes completed

After install it does not enter the script automatically but instead lists the methods available if a user wishes to do so.
The general use case is that the script doesn't require modification after install.

Entering the script and defining custom rules/rates is intended only for power users.

The general setup of non-configurable improvements is sufficient for most users.
 
Last edited:
#update - changes completed

It does not enter script automatically after install. It simply lists the commands to do so as an option.

Entering the script and defining custom rules/rates is intended only for power users.

The general setup only consists of non-configurable modifications that are already enabled after install. This is sufficient for most users.

What took you so long! :D:D:D
 

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top