ffapi-update-nodes.sh 489 B

12345678910111213
  1. #!/bin/bash
  2. TEMPLATE=/usr/src/services-ffms/apifile/ffapi-template.json
  3. APIFILE=/var/www/html/freifunk/ffapi.json
  4. #NUMNODES=$(jq '.nodes|.[]|.flags|.online' < $NODES | grep true | wc -l)
  5. NUMNODES=$(wget -qO - 'http://karte.freifunk-muensterland.de/data/nodes.json'| jq '.nodes|.[]|.flags|.online' | grep true | wc -l)
  6. echo "$NUMNODES"
  7. [[ $NUMNODES =~ ^[0-9]+$ ]] || exit 1
  8. cat $TEMPLATE | sed 's/#NUMNODES#/'$NUMNODES'/' | sed 's/#LASTCHANGE#/'$(date "+%Y-%m-%dT%T.%Z")'/' > $APIFILE