Enable additional motd tips showing some internal ads (#4396)

* Enable additional motd tips showing some internal ads

33% probability of showing, just like for the armbian-config

* Update quotes and add expiration date support

* Change variable names

* Add support to download quotes from our server

* Fix curl parameters

* Keep only weekly update
This commit is contained in:
Igor Pečovnik
2022-11-14 14:59:58 +01:00
committed by GitHub
parent 9ad65d83eb
commit 5888bc9704
2 changed files with 9 additions and 2 deletions

View File

@@ -0,0 +1,3 @@
#!/bin/bash
curl -s -o "/etc/update-motd.d/quotes.txt" "https://dl.armbian.com/quotes.txt"

View File

@@ -19,8 +19,12 @@ for f in $MOTD_DISABLE; do
done done
quotes="/etc/update-motd.d/quotes.txt" quotes="/etc/update-motd.d/quotes.txt"
if [[ -f $quotes ]]; then if [[ -f $quotes && $(( $RANDOM % 1 )) == 0 ]]; then
random_line=$(shuf -i 1-$(wc -l < $quotes) -n 1) random_line=$(shuf -i 1-$(wc -l < $quotes) -n 1)
quote=$(sed -n -e "$random_line"p $quotes) quote=$(sed -n -e "$random_line"p $quotes)
[[ -n $quote ]] && echo -e "\e[93mTip of the day:\e[39m $quote\n" DUE_DATE=$(echo $quote | cut -d"|" -f1)
SELECTED_QUOTE=$(echo $quote | cut -d"|" -f2)
if [[ -n $SELECTED_QUOTE && $(date +'%Y-%m-%d') < $(date -d $DUE_DATE +"%Y-%m-%d") ]]; then
echo -e "\e[93mTip of the day:\e[39m $SELECTED_QUOTE\n"
fi
fi fi