What's new
  • 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!

Script to download the latest Asuswrt-Merlin development snapshots from Github

Fitz Mutch

Senior Member
I never found an easy way to automatically name the downloaded "master.tar.gz" file, so I wrote this script. It will download the latest development snapshot from Github and automatically give it an appropriate filename. Example:

380.65-beta3-cf1bb54.tar.gz



/jffs/scripts/dl-merlin.sh
Code:
#!/bin/sh
VERSION_CONF=$(/usr/sbin/curl -L -s https://raw.githubusercontent.com/RMerl/asuswrt-merlin/master/release/src-rt/version.conf)
eval $(/bin/echo $VERSION_CONF | /bin/sed 's# #\n#g' | grep SERIALNO)
eval $(/bin/echo $VERSION_CONF | /bin/sed 's# #\n#g' | grep EXTENDNO)

LATEST_COMMIT=$(/usr/sbin/curl -L -s https://github.com/RMerl/asuswrt-merlin | # download HTML using curl
        /usr/bin/tr -d '\n'           | # remove carriage returns
        /bin/sed 's#</#\n</#g'        | # tokenize by HTML tag
        /bin/grep 'Latest commit'     | # locate lines with "Latest commit"
        /bin/sed 's#  *# #g'          | # convert all multispaces to single space
        /bin/sed 's# $##g'            | # remove trailing space
        /bin/sed 's# #\n#g'           | # tokenize by space
        /usr/bin/tail -n1)              # get the last token

FILENAME="$SERIALNO-$EXTENDNO-$LATEST_COMMIT.tar.gz"
/bin/echo
/bin/echo "Downloading $FILENAME ..."
/bin/echo

[ -n "$FILENAME" ] && /usr/sbin/curl -L -S --retry 90 --retry-delay 5 -o "$FILENAME" https://github.com/RMerl/asuswrt-merlin/archive/master.tar.gz


If you need to download through a proxy, just add "--socks5-hostname 192.168.1.1:9050" to the curl commands.
 
Last edited:
would't it just be easier to do a cron task with a git pull?
If all I'm doing is downloading the latest master, applying a patch and compiling, this method is very reliable. However, you're correct that the git pull is faster because it only downloads the deltas.
 
Recommended workflow is to keep two copies of the code. One which you keep updating with "git pull" as needed, and the other is a copy of that repo on which you patch/compile/etc...

Code:
cd asuswrt-merlin
git pull
cd ..
rsync -a --del asuswrt-merlin/ asuswrt-merlin-work
cd asuswrt-merlin-work
 
Merlin's approach is a good one...

The other approach would be to do a private fork, using his repo as an upstream source, and then just keep private changes - then one can fast forward/rewind as needed.

Lot's of ways to do this, and git is extremely powerful - and it's already set up.
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

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