dotfiles

*nix config files
git clone git://git.pyratebeard.net/dotfiles.git
Log | Files | Refs | README

sitrep (2393B)


      1 #!/bin/sh
      2 
      3 # colours
      4 RCol='\e[0m'    # Text Reset
      5 
      6 # Regular           Bold                Underline           High Intensity      BoldHigh Intens     Background          High Intensity Backgrounds
      7 Bla='\e[0;30m';     BBla='\e[1;30m';    UBla='\e[4;30m';    IBla='\e[0;90m';    BIBla='\e[1;90m';   On_Bla='\e[40m';    On_IBla='\e[0;100m';
      8 Red='\e[0;31m';     BRed='\e[1;31m';    URed='\e[4;31m';    IRed='\e[0;91m';    BIRed='\e[1;91m';   On_Red='\e[41m';    On_IRed='\e[0;101m';
      9 Gre='\e[0;32m';     BGre='\e[1;32m';    UGre='\e[4;32m';    IGre='\e[0;92m';    BIGre='\e[1;92m';   On_Gre='\e[42m';    On_IGre='\e[0;102m';
     10 Yel='\e[0;33m';     BYel='\e[1;33m';    UYel='\e[4;33m';    IYel='\e[0;93m';    BIYel='\e[1;93m';   On_Yel='\e[43m';    On_IYel='\e[0;103m';
     11 Blu='\e[0;34m';     BBlu='\e[1;34m';    UBlu='\e[4;34m';    IBlu='\e[0;94m';    BIBlu='\e[1;94m';   On_Blu='\e[44m';    On_IBlu='\e[0;104m';
     12 Pur='\e[0;35m';     BPur='\e[1;35m';    UPur='\e[4;35m';    IPur='\e[0;95m';    BIPur='\e[1;95m';   On_Pur='\e[45m';    On_IPur='\e[0;105m';
     13 Cya='\e[0;36m';     BCya='\e[1;36m';    UCya='\e[4;36m';    ICya='\e[0;96m';    BICya='\e[1;96m';   On_Cya='\e[46m';    On_ICya='\e[0;106m';
     14 Whi='\e[0;37m';     BWhi='\e[1;37m';    UWhi='\e[4;37m';    IWhi='\e[0;97m';    BIWhi='\e[1;97m';   On_Whi='\e[47m';    On_IWhi='\e[0;107m';
     15 
     16 ONLINE="${Bla}${On_Gre} online  ${RCol}"
     17 OFFLINE="${Bla}${On_Red} offline ${RCol}"
     18 
     19 [ -f /tmp/sitrep ] && rm -f /tmp/sitrep
     20 
     21 [ "${1}" == full ] && \
     22 	servers=(
     23 		"greyskull"
     24 		"nublar"
     25 		"blacksun"
     26 		"mainframe"
     27 		"laundry"
     28 		"mordhaus"
     29 	) || \
     30 	servers=(
     31 		"greyskull"
     32 		"nublar"
     33 		"laundry"
     34 	)
     35 
     36 for server in ${servers[@]} ; do
     37 	ssh ${server} "echo > /dev/null" && \
     38 		echo -e "${RCol}${server}|${ONLINE}" >> /tmp/sitrep || \
     39 		echo -e "${RCol}${server}|${OFFLINE}" >> /tmp/sitrep
     40 done
     41 
     42 [ "${1}" == full ] && \
     43 	urls=(
     44 		"pyratebeard.net"
     45 		"log.pyratebeard.net"
     46 		"git.pyratebeard.net"
     47 		"pager.pyratebeard.net"
     48 		"tube.pyratebeard.net"
     49 		"rum.sh"
     50 		"s.rum.sh"
     51 		"harbour.cafe"
     52 		"grimoire.wiki"
     53 		"2d4cinema.club"
     54 	) || \
     55 	urls=(
     56 		"pyratebeard.net"
     57 		"log.pyratebeard.net"
     58 		"git.pyratebeard.net"
     59 		"harbour.cafe"
     60 	)
     61 
     62 for url in ${urls[@]} ; do
     63 	curl -sL -o /dev/null -w "%{http_code}\n" ${url} > /dev/null && \
     64 		echo -e "${RCol}${url}|${ONLINE}" >> /tmp/sitrep || \
     65 		echo -e "${RCol}${url}|${OFFLINE}" >> /tmp/sitrep
     66 done
     67 
     68 cat /tmp/sitrep | column -t -s "|"