2 # This file is meant to be SOURCED
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
18 # Tracks events by sending HTTP GET requests with query strings to a web server
20 # - First argument (mandatory): event name
21 # - Rest of arguments:
22 # - If they exist, they correspond to tuples of operation-value-comment-tags
23 # - operation: particular operation in an event
24 # - value: particular value for an operation
26 # - none will be passed when empty
27 # - will be parsed to replace spaces by underscores
29 # - none will be passed when empty
30 # - will be parsed to replace spaces by ~
32 # - operation: like event
37 # Sends as many HTTP requests as operations with the following query string
38 # "&{OSM_TRACK_INSTALLATION_ID}&{TIMESTAMP}&{EVENT}&{OPERATION}&{VALUE}&{COMMENT}&{TAGS}"
42 echo "Unexpected error in track function. At least 1 arg is expected: event"
46 osm_track_event_name=$1
51 query_string="${query_string}&installation_id=${OSM_TRACK_INSTALLATION_ID}"
52 query_string="${query_string}&local_ts=${ctime}"
53 query_string="${query_string}&event=${osm_track_event_name}"
57 operation="${osm_track_event_name}"
61 final_query_string="${query_string}"
62 final_query_string="${final_query_string}&operation=${operation}"
63 final_query_string="${final_query_string}&value=${value}"
64 final_query_string="${final_query_string}&comment=${comment}"
65 final_query_string="${final_query_string}&tags=${tags}"
66 url="https://osm.etsi.org/InstallLog.php?${final_query_string}"
67 echo "Track $osm_track_event_name $operation: ${url}"
68 LANG=C wget -q -O /dev/null "$url"
70 while (( "$#" > 0 )); do
71 operation="${1:-${osm_track_event_name}}"
77 comment="${comment// /_}"
82 [ "$value" == "none" ] && value=""
83 [ "$comment" == "none" ] && comment=""
84 [ "$tags" == "none" ] && tags=""
85 final_query_string="${query_string}"
86 final_query_string="${final_query_string}&operation=${operation}"
87 final_query_string="${final_query_string}&value=${value}"
88 final_query_string="${final_query_string}&comment=${comment}"
89 final_query_string="${final_query_string}&tags=${tags}"
90 url="https://osm.etsi.org/InstallLog.php?${final_query_string}"
91 echo "Track $osm_track_event_name $operation: ${url}"
92 LANG=C wget -q -O /dev/null "$url"