Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The right way to verify that there was a change in the list version. #278

Closed
elico opened this issue Apr 15, 2018 · 8 comments
Closed

The right way to verify that there was a change in the list version. #278

elico opened this issue Apr 15, 2018 · 8 comments

Comments

@elico
Copy link

elico commented Apr 15, 2018

Currently I have seen that the only place I can see the version of the blacklist is at:

under:

- Version: **V1.1123.2018.04.15**

which is between line 10 to 20 of the file.

can I count on it to always be there as it is?
IE I want to write a bash script that will check for a version change at github every 8 hours and will trigger an update download\fetch from github.

If not or if possible to have some "version.txt" file that will contain the current version with some etag or md5\sha1\sha256 hash that will help to verify that the downloaded file is indeed the one that I should receive.

@mitchellkrogza
Copy link
Member

@elico yesy indeed, once that Readme is updated with a new version number then the RAW links are also updated too, that you can count on. We only update Ultimate once a day using Cron so you instead of every 8 hours you can safely schedule it for 14h00 UTC once a day

@mitchellkrogza
Copy link
Member

mitchellkrogza commented Apr 15, 2018

@elico just note that the version number is defined as follows V1.BUILDNUMBER.YYYY.MM.DD so technically you can just watch the build number part of that tag

@elico
Copy link
Author

elico commented Apr 15, 2018

@mitchellkrogza Thanks!
Will write this one.

@mitchellkrogza
Copy link
Member

Great @elico keep us posted.

@elico
Copy link
Author

elico commented Apr 15, 2018

@mitchellkrogza the basic script I cam up with is:

I have couple other tools that will come later.

@funilrys
Copy link
Member

funilrys commented Apr 18, 2018

Just a little comment about your code @elico.

Please avoid UPPERCASE variable as it can be confusing for people who want to start learning by reading your code (yes that exist).
Indeed UPPERCASE are generally reserved for the systemwide/environment variables like ${PATH}, ${HOME} or even ${EDITOR}.


You use ${VERSIONFILE} only once, so you do not need a variable for that. Simply append it to the array and do your check into your loop 🙂.


I'm not a big fan of oneliner like @mitchellkrogza but you may find the following as an alternative to CURRENTVERSION=$(curl "$GITROOT$VERSIONFILE" 2>/dev/null |grep "Version: \*\*" |gawk '{print $3}')

$ currentVersion=$(curl ${gitRoot}${versionFile} 2>/dev/null | grep -E "Version" | cut-d ' ' -f3

Please also consider using the format ${variableName} when calling variable as it's cleaner than $variableName.

You may also learn later (if it's not already the case) that you can to get a substring of a string which can be made with ${variableName:1:5} which is only possible with that format.

So keep it clean, understandable and safe and the world will be a better place for the learner 😉.


Question

  • Why are you exporting variable (for example export LISTSJAIL when you can directly use them like the following?
thisIsMyAwesomeVariable="The world is awesome"
echo ${thisIsMyAwesomeVariable}

Post scriptum

I'm only a student and my only experience in Bash/Shell in open source project is funceble along with other really older projects.

This is just pieces of advice do not take them personally.

For me, it's important that when you publish code in public that it should be clear because not only experienced programmer may take a look at it.

If those pieces of advice were present when I started to read and learn code, I would not waste so much time trying to find the right way.

Anyway, feel free to follow or not those (little) pieces of advice.

Cheers,
Nissar

@dnmTX
Copy link

dnmTX commented Jun 14, 2018

@funilrys i just read this....your advice is right on the spot....i am a learner(bellow beginner) and i know exactly what you mean.You should see my little scripts that i made to update my hosts files....
.....all oneliners hehehehe

@stale
Copy link

stale bot commented Oct 20, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Oct 20, 2019
@stale stale bot closed this as completed Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants