192.168.sh

#! /bin/sh
# 192168.sh (GPL) (CC-by-sa-at-3.0) by Eric Poscher
# This is the shell script needed on the client side for the art project 192.168.epe.at
# Run this script hourly in a cron job!
# For more information, see: http://epe.at/de/portfolio/192168epeat
cd /var/www/ # go to working directory
ip r | grep default | grep 192.168 > /dev/null || exit
export IP=$( ip r |grep "default via" | awk '{print $5}' | xargs ip addr show |grep "inet " | awk '{print $2}' | sed 's/\/24//g')
export RD=$( echo $IP | sed 's/\./ /g' | awk '{print $3}')
export GD=$( echo $IP | sed 's/\./ /g' | awk '{print $4}')
BD="0"
echo '<span style="background-color:rgb('$RD','$GD','$BD')"> '$IP' </span>' >> epe.html
#Manage the content:
cat 192.html > index.html
cat 168.html >> epe.html
cat epe.html >> index.html
cat at.html >> index.html
mv epe.html 168.html
# check for serverconnection and upload file. Setup ssh public key auth first!
ping -c 1 epe.at && scp index.html epe@epe.at:/var/www/site/192.168.epe.at/
