OutsideIT / FireMotD

:fire: Fire Framework Linux MoTD Generator :fire:
https://outsideit.net/firemotd
GNU General Public License v3.0
174 stars 45 forks source link

check for dependencies #83

Closed willemdh closed 6 years ago

willemdh commented 6 years ago

Some code should be added for apt and zypper, but this works fro yum:

./FireMotD -T Red
2017-12-08 19:32:09,238: FireMotD: Error: Unable to detect jq. Please install.
./FireMotD -v -T Red
2017-12-08 19:31:59,208: FireMotD: Info: Verbose execution.
2017-12-08 19:31:59,531: FireMotD: Info: Detected openssh-clients
2017-12-08 19:31:59,820: FireMotD: Info: Detected bc
2017-12-08 19:32:00,121: FireMotD: Info: Detected sysstat
2017-12-08 19:32:00,533: FireMotD: Error: Unable to detect jq. Please install.

Please test if it does'nt result in any issues on apt system.

ThomDietrich commented 6 years ago

Did you consider the command command?

command -v foo >/dev/null 2>&1 || { echo "I require foo but it's not installed.  Aborting." >&2; exit 1; }
willemdh commented 6 years ago

I'll give it a try. It seems like a better solution which is on independent. Tx

willemdh commented 6 years ago

Hmm it doesn't work for moreutils, nor openssh-clients and sysstat. I'll leave the package check for now for them (for yum). It will only run when saving the json.

willemdh commented 6 years ago

So moreutils is needed for sponge, sysstat is need for mpstat. openssh-client I'm not sure anymore.. I'll leave that one out for now. Tx for the dpkg query integrated it, please confirm if it works

willemdh commented 6 years ago

Ok, I converted it to a command -v only version which is acturally quicker. Left the IsInstalled function as it could be useful.