From cd48fd44f013d2ab273ac8a647ed45e3246c60ce Mon Sep 17 00:00:00 2001 From: Ethan Dye Date: Sun, 31 May 2020 18:53:28 -0600 Subject: [PATCH] Rewrite FireMotD Setup Signed-off-by: Ethan Dye --- functions/java-jre.bash | 2 +- functions/packages.bash | 36 +++++++++++++++++++++++++----------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/functions/java-jre.bash b/functions/java-jre.bash index df0c98a39..915ab114b 100644 --- a/functions/java-jre.bash +++ b/functions/java-jre.bash @@ -389,7 +389,7 @@ adoptopenjdk_fetch_apt(){ if cond_redirect apt-key add "$repoKey"; then echo "OK" else - echo "FAILED (keyserver)" + echo "FAILED" rm -f "$repoKey" return 1; fi diff --git a/functions/packages.bash b/functions/packages.bash index d333e507c..a69d919fe 100644 --- a/functions/packages.bash +++ b/functions/packages.bash @@ -19,18 +19,30 @@ samba_setup() { } firemotd_setup() { - FAILED=0 - echo -n "$(timestamp) [openHABian] Downloading and setting up FireMotD... " - cond_redirect apt-get install --yes bc sysstat jq moreutils + local tempLoc + + tempLoc="/tmp/FireMotD" + + echo -n "$(timestamp) [openHABian] Installing FireMotD required packages... " + if cond_redirect apt-get install --yes bc sysstat jq moreutils; then echo "OK"; else echo "FAILED"; fi + + echo -n "$(timestamp) [openHABian] Downloading FireMotD... " + if cond_redirect wget -qO "$tempLoc" https://raw.githubusercontent.com/OutsideIT/FireMotD/master/FireMotD; then + echo "OK" + else + echo "FAILED" + rm -rf "$tempLoc" + return 1 + fi - # fetch and install - if ! cond_redirect curl -s https://raw.githubusercontent.com/OutsideIT/FireMotD/master/FireMotD -o /tmp/FireMotD; then echo "FAILED"; return 1; fi + echo -n "$(timestamp) [openHABian] Setting up FireMotD... " chmod 755 /tmp/FireMotD - cond_redirect /tmp/FireMotD -I - # generate theme - cond_redirect FireMotD -G Gray - # initial apt updates check - cond_redirect FireMotD -S + if cond_redirect /tmp/FireMotD -I; then echo "OK"; else echo "FAILED"; fi + + echo -n "$(timestamp) [openHABian] Generating FireMotD theme... " + if cond_redirect FireMotD -G Gray; then echo "OK"; else echo "FAILED"; fi + + echo -n "$(timestamp) [openHABian] Setting up FireMotD apt updates count service... " # the following is already in bash_profile by default if ! grep -q "FireMotD" /home/"$username"/.bash_profile; then echo -e "\\necho\\nFireMotD --theme Gray \\necho" >> /home/"$username"/.bash_profile @@ -41,7 +53,9 @@ firemotd_setup() { echo "0 0 * * * root perl -e 'sleep int(rand(21600))' && /bin/bash /usr/local/bin/FireMotD -S &>/dev/null" >> /etc/cron.d/firemotd # invoke apt updates check after every apt action ('apt-get upgrade', ...) echo "DPkg::Post-Invoke { \"if [ -x /usr/local/bin/FireMotD ]; then echo -n 'Updating FireMotD available updates count ... '; /bin/bash /usr/local/bin/FireMotD --skiprepoupdate -S; echo ''; fi\"; };" > /etc/apt/apt.conf.d/15firemotd - echo "OK" + + # initial apt updates check + if cond_redirect FireMotD -S; then echo "OK"; else echo "FAILED"; fi } create_mta_config() {