storytime/bash/check-dependencies.sh

55 lines
1.2 KiB
Bash

#!/usr/bin/env bash
# Abort if any command fails.
set -e
# Set up some colors for output
red=$(tput setaf 1)
green=$(tput setaf 2)
normal=$(tput sgr0)
# 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() {
printf "%-28s" "Checking for $1..."
if eval $2 &> /dev/null ; then
printf "%1s\n" "${green}✔︎${normal}"
false
else
printf "%1s\n" "${red}${normal}"
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