bash_aliases.root 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/bash
  2. #
  3. # Nifty shell aliases for debugging (Salt managed)
  4. #
  5. function peer2v6ffpb()
  6. {
  7. peername=$1
  8. peer2v6ll $1 fdca:ffee:ff12:132:
  9. }
  10. function peer2v6ll()
  11. {
  12. peername=$1
  13. prefix=$2
  14. if [ -z "$prefix" ]; then
  15. prefix="fe80::"
  16. fi
  17. mac=$(grep MAC /etc/freifunk/peers/$peername | cut -d ' ' -f 3)
  18. if [ -z "${mac}" ]; then
  19. echo "no peer named '${peername}' found, did you spell it correctly?" >&2
  20. return 1
  21. else
  22. euid64=$(ipv6calc -q --action geneui64 -I mac ${mac})
  23. echo ${prefix}${euid64}
  24. return 0
  25. fi
  26. }
  27. function connect2peer()
  28. {
  29. peername=$1
  30. target=$(peer2v6ll $peername)
  31. if [ "$?" == "0" ]; then
  32. echo "trying to ssh into peer '${peername}' (${target})"
  33. ssh -l root -6 ${target}%br-ffpb
  34. fi
  35. }
  36. function pingpeer()
  37. {
  38. peername=$1
  39. target=$(peer2v6ll $peername)
  40. if [ "$?" == "0" ]; then
  41. echo "pinging peer '${peername}' (${target})"
  42. ping6 ${target}%br-ffpb
  43. fi
  44. }
  45. function peerstatus()
  46. {
  47. peername=$1
  48. target=$(peer2v6ll $peername fdca:ffee:ff12:132:)
  49. tf=`tempfile`
  50. echo -en "\e[97mFetching node status of '$peername' ...\e[39m "
  51. wget -q "http://[$target]/cgi-bin/status" -O $tf
  52. if [ $? -eq 0 ]; then
  53. echo -e "\e[92mOK\e[39m"
  54. cp $tf /tmp/ffpb-nodestatus-$peername.htm
  55. #less /tmp/ffpb-nodestatus-$peername.htm
  56. lynx -dump /tmp/ffpb-nodestatus-$peername.htm
  57. else
  58. echo -e "\e[91mERROR\e[39m"
  59. fi
  60. rm $tf
  61. }