Skip to content
Snippets Groups Projects
Forked from SCS / docs.it4i.cz
1528 commits behind, 427 commits ahead of the upstream repository.
motd.sh 1.03 KiB
#!/bin/bash

### MOTD and Downtime history
# autor: kru0052
# 2016 IT4Innovations
###

#wget http://www.it4i.cz/support/?lang=en

i="index.html?lang=en"

HEAD=$(grep -n -m1 'class="matrix light-grey' "$i" |cut -f1 -d: | tr --delete '\n')
END=$(grep -n -m1 '<h3>Other</h3>' "$i" |cut -f1 -d: | tr --delete '\n')
LAST=$(wc -l "$i" | cut -f1 -d' ')
DOWN=$((LAST-END+2))

sed '1,'"$((HEAD-1))"'d' "$i" | sed -n -e :a -e '1,'"$DOWN"'!{P;N;D;};N;ba' | sed '/<div/d' > "TMP.html"
#sed '1,'"$((HEAD-1))"'d' "$i" | sed -n -e :a -e '1,'"$DOWN"'!{P;N;D;};N;ba'  > "TMP.html"

title="Message of the day"
head=$(cat TMP.html | grep "rss-item-title" | cut -d ">" -f 2 | cut -d "<" -f 1)
date=$(cat TMP.html | grep "<i>" | cut -d ">" -f 2 | cut -d "<" -f 1)
info=$(cat TMP.html | grep "<p>" | cut -d ">" -f 2 | cut -d "<" -f 1)

echo "### $title" > MOTD.md
echo "**$head**" >> MOTD.md
echo "$date - $info" >> MOTD.md

echo "$title"
echo "$head"
echo "$date - $info"

if [ "$head" = "Salomon Maintenance" ] || [ "$head" = "Anselm Maintenance" ]; then
	echo "add to table"
fi