From fb7d445e540bc54bbd19464c7e09b03147db90c3 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Thu, 12 May 2022 19:11:17 +0200 Subject: [PATCH] scripts: Add authentication support for Wiki queries --- scripts/geojson/maps/common.sh | 3 +++ scripts/geojson/maps/fetch_bodiesofwater.sh | 4 +++- scripts/geojson/maps/fetch_city_outlines.sh | 4 +++- scripts/geojson/maps/fetch_streets.sh | 4 +++- scripts/geojson/maps/fetch_trainlines.sh | 4 +++- scripts/geojson/maps/update_all.sh | 2 ++ 6 files changed, 17 insertions(+), 4 deletions(-) create mode 100755 scripts/geojson/maps/common.sh diff --git a/scripts/geojson/maps/common.sh b/scripts/geojson/maps/common.sh new file mode 100755 index 0000000..c302bbf --- /dev/null +++ b/scripts/geojson/maps/common.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +CURLOPTS=( '-b' "/etc/lifomapserver/cookies.txt" ) diff --git a/scripts/geojson/maps/fetch_bodiesofwater.sh b/scripts/geojson/maps/fetch_bodiesofwater.sh index 8cd4a29..20ef6c2 100755 --- a/scripts/geojson/maps/fetch_bodiesofwater.sh +++ b/scripts/geojson/maps/fetch_bodiesofwater.sh @@ -1,6 +1,8 @@ #!/bin/bash -json=`curl 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:BodiesOfWater'` +source common.sh + +json=`curl ${CURLOPTS[@]} 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:BodiesOfWater'` data=`echo "$json" | json_reformat | sed -e 's/\\\\n//g' -n -e 's/begin:mapdata\([^}]\+\)/\1/gp' | sed -e "s/|-|/}/g"` section="" diff --git a/scripts/geojson/maps/fetch_city_outlines.sh b/scripts/geojson/maps/fetch_city_outlines.sh index 0e34572..ad41d70 100755 --- a/scripts/geojson/maps/fetch_city_outlines.sh +++ b/scripts/geojson/maps/fetch_city_outlines.sh @@ -1,6 +1,8 @@ #!/bin/bash -json=`curl 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:Cities'` +source common.sh + +json=`curl ${CURLOPTS[@]} 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:Cities'` data=`echo "$json" | json_reformat | sed -e 's/\\\\n//g' -n -e 's/begin:mapdata\([^}]\+\)/\1/gp' | sed -e "s/|-|/}/g"` echo "[" diff --git a/scripts/geojson/maps/fetch_streets.sh b/scripts/geojson/maps/fetch_streets.sh index 741f82a..e4491b5 100755 --- a/scripts/geojson/maps/fetch_streets.sh +++ b/scripts/geojson/maps/fetch_streets.sh @@ -2,7 +2,9 @@ # WARNING: This script is not yet production ready. The slightest error in the wikipage can throw it off. Handle with care. -json=`curl 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:Streets'` +source common.sh + +json=`curl ${CURLOPTS[@]} 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:Streets'` data=`echo "$json" | json_reformat | sed -e 's/\\\\n//g' -n -e 's/begin:mapdata\([^}]\+\)/\1/gp' | sed -e "s/|-|/}/g"` echo "[" diff --git a/scripts/geojson/maps/fetch_trainlines.sh b/scripts/geojson/maps/fetch_trainlines.sh index f0c4d25..da6f082 100755 --- a/scripts/geojson/maps/fetch_trainlines.sh +++ b/scripts/geojson/maps/fetch_trainlines.sh @@ -1,6 +1,8 @@ #!/bin/bash -json=`curl 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:Trainlines'` +source common.sh + +json=`curl ${CURLOPTS[@]} 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:Trainlines'` data=`echo "$json" | json_reformat | sed -e 's/\\\\n//g' -n -e 's/begin:mapdata\([^}]\+\)/\1/gp' | sed -e "s/|-|/}/g"` section="" diff --git a/scripts/geojson/maps/update_all.sh b/scripts/geojson/maps/update_all.sh index e25d843..a684ce8 100755 --- a/scripts/geojson/maps/update_all.sh +++ b/scripts/geojson/maps/update_all.sh @@ -1,5 +1,7 @@ #!/bin/bash +source common.sh + function fetch() { if [[ "$3" != "" ]]; then fn="$3"