Skip to content

Commit

Permalink
Rewrite FireMotD Setup
Browse files Browse the repository at this point in the history
Signed-off-by: Ethan Dye <[email protected]>
  • Loading branch information
ecdye committed Jun 1, 2020
1 parent 0606262 commit cd48fd4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion functions/java-jre.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 25 additions & 11 deletions functions/packages.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() {
Expand Down

0 comments on commit cd48fd4

Please sign in to comment.