Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
amousset committed May 9, 2019
1 parent 3207e57 commit bdd8096
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
12 changes: 12 additions & 0 deletions qa-test
@@ -0,0 +1,12 @@
#!/bin/bash

set -ex

# Shellcheck
find . -path ./.git -prune -o -type f -exec grep -Eq '^#!(.*/|.*env +)(sh|bash|ksh)' {} \; -print |
while IFS="" read -r file
do
# with recent shellcheck, "-S error" replaces this hack
shellcheck -f gcc "$file" | grep " error: " && exit 1 || true
done

12 changes: 3 additions & 9 deletions share/lib/api_call.sh
Expand Up @@ -2,14 +2,8 @@
API_URL="https://127.0.0.1/rudder"
TECHNIQUES_DIRECTORY="${CONFIGURATION_DIRECTORY}/technique"

if type curl >/dev/null 2>/dev/null
then
DOWNLOAD_COMMAND="curl --silent --show-error --insecure --location --proxy '' --globoff"
HEADER_OPT="--header"
else
DOWNLOAD_COMMAND="wget --quiet --no-check-certificate --no-proxy -O -"
HEADER_OPT="--header"
fi
DOWNLOAD_COMMAND="${RUDDER_CURL} --silent --show-error --insecure --location --proxy '' --globoff"
HEADER_OPT="--header"

# This functions tests if the API call returns "OK"
simple_api_call() {
Expand Down Expand Up @@ -81,7 +75,7 @@ filtered_api_call() {
action="$3"
filter="$4"
display_command="$5"
curl_command="${DOWNLOAD_COMMAND} -H \"X-API-Token: ${token}\" -X ${action} \"${url}\" ${filter}"
curl_command="${DOWNLOAD_COMMAND} --header \"X-API-Token: ${token}\" --request ${action} \"${url}\" ${filter}"
if ${display_command};
then
printf "${WHITE}${curl_command}${NORMAL}\n\n" >&2
Expand Down
7 changes: 7 additions & 0 deletions share/lib/common.sh
Expand Up @@ -151,3 +151,10 @@ then
else
FULL_COMPLIANCE=1
fi

if [ -x /opt/rudder/bin/curl ]
then
RUDDER_CURL="/opt/rudder/bin/curl"
else
RUDDER_CURL="/usr/bin/curl"
fi
10 changes: 10 additions & 0 deletions share/lib/send_runlog.sh
@@ -0,0 +1,10 @@
if [ -f "${RUDDER_JSON}" ]; then
davuser=$(grep 'DAVUSER' "${RUDDER_JSON}" | sed 's/.*"DAVUSER":"\(.*\)",.*/\1/')
davpw=$(grep 'DAVPASSWORD' "${RUDDER_JSON}" | sed 's/.*"DAVPASSWORD":"\(.*\)",.*/\1/')
fi

function send_runlog() {
file="$1"
server="$2"
${RUDDER_CURL} --tlsv1.2 --insecure --fail --silent --proxy '' --user "${davuser}:${davpw}" --upload-file "${file}" https://${server}/reports/
}

0 comments on commit bdd8096

Please sign in to comment.