Add script to check dependencies

This commit is contained in:
Clinton Judy 2024-04-11 23:17:25 -04:00
parent eb5df93e9f
commit 2d24baf24f

49
bash/check-dependencies Executable file
View file

@ -0,0 +1,49 @@
#!/bin/bash
# Abort if any command fails.
set -e
# Check for presence of a command.
# $1 is name of dependency
# $2 is command that gets run to check for it
# eg. check "disroot.org reachable?" "ping disroot.org"
check() {
echo -n "Checking for $1... "
if eval $2 &> /dev/null ; then
echo ✔︎
false
else
echo ✗
storytime_ready=false
true
fi
}
# assume ready until proven otherwise
storytime_ready=true
if check "cron" "crontab -l"; then
echo " Please install cron."
fi
if check "mimic3" "mimic3 --version"; then
echo " Please install mimic3."
echo " Via pip: pip3 install mycroft-mimic3-tts[all]"
fi
if check "ffmpeg 7" "ffmpeg -version | grep \"ffmpeg version 7\""; then
echo " Please install ffmpeg ~7."
fi
if check "feed2exec" "feed2exec"; then
echo " Please install feed2exec."
echo " Via pip: pip3 install feed2exec"
fi
# final check for readiness
if $storytime_ready; then
echo -e "\nReady for Storytime!"
else
echo -e "\nStorytime is not ready to go. Please install the missing dependencies."
fi