Keepalive
Page content
Little Keep Alive
… mit freundlicher genehmigung von Kumpel Marc :)
keepalive.sh
#!/usr/bin/env bash
FILE="$HOME/scripts/excuses"
# Linux or BSD ? nf points to the right binary
which numfmt > /dev/null 2>&1 && nf=$(which numfmt) || nf=$(which gnumfmt);
# Linux or BSD ? gs points to the right binary
which shuf > /dev/null 2>&1 && gs=$(which shuf) || gs=$(which gshuf);
if [ ! -e "$FILE" ]; then
echo ""
echo "$FILE does not exist"
echo "##############################################"
command -v curl >/dev/null 2>&1 || { echo >&2 "Holy cow! You don't even have curl, get lost!"; echo ""; exit 1; }
mkdir -p $HOME/scripts/
curl -o $FILE https://pages.cs.wisc.edu/~ballard/bofh/excuses
echo "##############################################"
fi
keep () {
clear;
echo "If you are reading this..." && echo "Congratulations, you are alive."
echo ""
echo "You are stuck on the following planet:" `hostname`
echo "It has been" `date +%s | $nf --g` "seconds since January 1st 1970, this is quite a while..."
echo ""; echo "Your current excuse is:"; $gs -n 1 $HOME/scripts/excuses
}
while :
do
keep
sleep 30
done
Testrun
./keepalive.sh
If you are reading this...
Congratulations, you are alive.
You are stuck on the following planet: puffy201.planet
It has been 1658870361 seconds since January 1st 1970, this is quite a while...
Your current excuse is:
Power Company having EMP problems with their reactor
Any Comments ?
sha256: 5de0afbcacd56dbcaede593a6f243a3f46e4d94754683646d57e00f3c7840eca