I wrote a script like yours about a year ago I think, but yours looks a bit more elegant t.b.h. Main difference is I just rename the server-version.jar to server.jar so I can have my run.sh static and donāt have to modify it
I think many blynkers wrote a script like this, but it should be written single time and well. Also modifying run.sh has advantages as keeping versioning: ease roll-back( in case old server jar not removing ); compatibility with blynk server setup instructions.
True, I did keep old .jar files, but my script was more dirty, Iāll admit that, lol. Itās probably posted somewhere on the forum if you search for it.
In the common quest for the ultimate install/update/start/stop-script I have some feedback
I think the server-[version]-java8.jar is for RPi and the server-[version].jar for Linux in general. So a slight difference between those two which people might not notice. I want to use the latter
Itās ābad practiceā and actually no reason at all to set the permissions to -rwxrwxrwx. Default -rw-r--r-- will do just fine. ājava -jarā is whatās executing and just needs to read the *.jar file. Also -R changes permissions recursively and has no effect on a single file
I just manually log in with putty, grab the latest file with wget (using past ārememberedā CLI commands and adjusting for file name), stop the server edit the rc.local to match the new file name and run rc.local again. Usually done in about 30-45 secondsā¦ not bad I think for a Linux n0ob. And it keeps me a bit more cognizant of some basic commands (not that I can remember them without looking them upā¦ Each. And. Every. Timeā¦ arrggā¦).
I was just pointing out that there is a difference between the two jars. The reason I found out is this:
CPU Support - not all Pi models
Java 9 takes advantage specific CPU instruction sets commonly found in modern 64-bit processors, like the ARM v7/8 CPUs and x86 range. This move will help improve runtime performance.
However, as of today, this does limit Java 9 to the Raspberry Pi 2 and Pi 3 boards. Owners of model As, Bs and Zeros, with their older ARM v6 processor chips, will therefore have to keep using Java 8.
Hereās a beautiful command if you have jq (commandline JSON processor) installed:
But if I use BOTH index fingers I can do a fair clip
Thankfully the CLI seems to remember my past commandsā¦ stored in some file if I recall correctlyā¦ I just arrow up and down, find the command, edit, press enter, rinse & repeat
if you enter the command āhistoryā you can see a list of all past commands
Say you forgot the curl command, you can search in the list using grep:
history | grep curl
Thatāll search for curl in that list.
The chmod is a very good notice. You might want to add inputting a parameter to let the script choose for downloading the Java9 or 8 version, e.g. update.sh java8
I only have 2000 lines in my history file so that method has it limitations Yes, I know I can change thatā¦
@fragolinux uses lsb_release -rs to check which Java version that should be installed in his script from the thread Completely unattended local Blynk-Server setup which is one way to do it (But youāll get the *-java8.jar version either way because there was only one release when he wrote it ).
fragolinux script is for a complete new installation on a virgin system, thatās why he checks against the distro.
He looks in /etc/os-release after ā*BIANā and if the release version is >9 with lsb_release -rs. If so, Java 8 gets installed. But does all RPi distros have ā*BIANā as ID? Never mind. Itās not important!
I might start working on a install/update script, but for Linux only. Itās complicated enough without having to guess what the RPiās needs