Quick And Dirty "Checker" Script

Got bored and figured some people might find it useful to have a quick way to check if they’re up to date from the command line without trying to run the auto-update script.

Such a script can be found HERE.

It doesn’t auto-locate your Invoice Ninja install (more on why in a minute). You’ll have to edit line 12 to point to wherever your own version.txt is located. If that’s all you need it for, then you can stop here.

You can also use this to abuse motd.d and have it run every time you login via a console, or SSH. Simply drop the script into your /etc/motd.d/ folder, and preface the filename with whatever number you want to change where in the motd it outputs. That’s why I don’t have it try to auto-locate your install. Pulling the version # from the website adds enough time to the login process, you don’t want to wait for it to update the locate db as well.

If you’re using my autoupdate script and want to really abuse motd.d, you can uncomment lines 47-60, and change line 52 to whatever time you have the cron set to run the script (HH:MM format). That way, if an update is going to happen, it will compare that with the time you logged in and also output whether the update will happen “today” (if it’s prior to the cron’s runtime) or “tomorrow” (if the cron’s runtime has already passed for the day).

Sample Output:

Up To Date
Invoice Ninja is Up To Date

Not Up To Date
Invoice Ninja Will Update

That’s awesome!

Just in case anyone actually uses this, I’ve updated it to include a 15 second timeout on the wget command. That way, if invoiceninja.com is down for whatever reason, it’s not stuck in a wait state for the default 900 seconds. I learned this the hard way since I have it set as one of my update-motd.d scripts, and my server wouldn’t let me into the command prompt after login because technically the script was still executing.