Possibly change from using "which" command
I'm running your script on an unRaid box which has a "different" 'which' command that doesn't return an exit status. This is apparently not that unheard of.
I did a little looking and this answer on StackExchange recommends using "command -v" - it does seem to work in my testing... It only matters if the command you are looking for isn't found - in this instance it was "lsb_release" which there was another option to run with - for some of the other instances of 'which' things fail if it doesn't find a path, so may want to just leave those alone anyhow.
https://stackoverflow.com/questions/592620/how-to-check-if-a-program-exists-from-a-bash-script
In line 231:
231 if $(which lsb_release) ; then
It changes to
231 if $(command -v lsb_release) ; then
Thought I would mention it in the name of cross platform coverage.