Advertisement
Guest User

Untitled

a guest
Jun 25th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. cd /opt/freifunk/map
  2.  
  3. is_running() {
  4. pidof "$1" > /dev/null || return $?
  5. }
  6.  
  7. if ! is_running "alfred"; then
  8. echo "(I) Start alfred."
  9. start-stop-daemon --start --background --exec `which alfred` -- -i bat0
  10. sleep 1
  11. fi
  12.  
  13. #announce status website via alfred
  14. {
  15. echo -n "{\"link\" : \"http://[$ip_addr]/index.html\", \"label\" : \"Freifunk Gateway $name\"}"
  16. } | alfred -s 91
  17.  
  18. #announce map information via alfred
  19. {
  20. vpn="true"
  21. echo -n "{"
  22. [ -n "$latitude" ] && echo -n "\"latitude\" : $latitude, "
  23. [ -n "$longitude" ] && echo -n "\"longitude\" : $longitude, "
  24. [ -n "$name" ] && echo -n "\"name\" : \"$name\", "
  25. [ -n "$firmware" ] && echo -n "\"firmware\" : \"$firmware\", "
  26. [ -n "$community" ] && echo -n "\"community\" : \"$community\", "
  27. [ -n "$vpn" ] && echo -n "\"vpn\" : $vpn, "
  28. [ -n "$gateway" ] && echo -n "\"gateway\" : $gateway, "
  29. echo -n "\"links\" : ["
  30. printLink() { echo -n "{ \"smac\" : \"$(cat /sys/class/net/$3/address)\", \"dmac\" : \"$1\", \"qual\" : $2 }"; }
  31. IFS="
  32. "
  33. nd=0
  34. for entry in $(cat /sys/kernel/debug/batman_adv/bat0/originators | tr '\t/[]()' ' ' | awk '{ if($1==$4) print($1, $3, $5) }'); do
  35. [ $nd -eq 0 ] && nd=1 || echo -n ", "
  36. IFS=" "
  37. printLink $entry
  38. done
  39. echo -n '], '
  40. echo -n "\"clientcount\" : 0"
  41. echo -n '}'
  42. } | gzip -c - | alfred -s 64
  43.  
  44. #collect all map pieces
  45. alfred -r 64 > /tmp/maps.txt
  46. #create map data
  47. ./map-backend.py -m /tmp/maps.txt -a ./aliases.json --ffmap-nodes ./nodes.json
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement