12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #!/bin/bash
- #
- # Nifty shell aliases for debugging (Salt managed)
- #
- function peer2v6ffpb()
- {
- peername=$1
- peer2v6ll $1 fdca:ffee:ff12:132:
- }
- function peer2v6ll()
- {
- peername=$1
- prefix=$2
- if [ -z "$prefix" ]; then
- prefix="fe80::"
- fi
- mac=$(grep MAC /etc/freifunk/peers/$peername | cut -d ' ' -f 3)
- if [ -z "${mac}" ]; then
- echo "no peer named '${peername}' found, did you spell it correctly?" >&2
- return 1
- else
- euid64=$(ipv6calc -q --action geneui64 -I mac ${mac})
- echo ${prefix}${euid64}
- return 0
- fi
- }
- function connect2peer()
- {
- peername=$1
- target=$(peer2v6ll $peername)
- if [ "$?" == "0" ]; then
- echo "trying to ssh into peer '${peername}' (${target})"
- ssh -l root -6 ${target}%br-ffpb
- fi
- }
- function pingpeer()
- {
- peername=$1
- target=$(peer2v6ll $peername)
- if [ "$?" == "0" ]; then
- echo "pinging peer '${peername}' (${target})"
- ping6 ${target}%br-ffpb
- fi
- }
- function peerstatus()
- {
- peername=$1
- target=$(peer2v6ll $peername fdca:ffee:ff12:132:)
- tf=`tempfile`
- echo -en "\e[97mFetching node status of '$peername' ...\e[39m "
- wget -q "http://[$target]/cgi-bin/status" -O $tf
- if [ $? -eq 0 ]; then
- echo -e "\e[92mOK\e[39m"
- cp $tf /tmp/ffpb-nodestatus-$peername.htm
- #less /tmp/ffpb-nodestatus-$peername.htm
- lynx -dump /tmp/ffpb-nodestatus-$peername.htm
- else
- echo -e "\e[91mERROR\e[39m"
- fi
- rm $tf
- }
|