Skip to content

Commit

Permalink
change possibly conflictual env var USERNAME (DSP-706) (#1719)
Browse files Browse the repository at this point in the history
* change possibly conflictual env var USERNAME

* applying USER_NAME to the rest of the scripts

Co-authored-by: Ivan Subotic <400790+subotic@users.noreply.github.com>
  • Loading branch information
loicjaouen and subotic committed Sep 29, 2020
1 parent 62bb64d commit eccd163
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
6 changes: 3 additions & 3 deletions webapi/scripts/fuseki-dump-repository.sh
Expand Up @@ -14,7 +14,7 @@ case $key in
shift # past value
;;
-u|--username)
USERNAME="$2"
USER_NAME="$2"
shift # past argument
shift # past value
;;
Expand All @@ -38,7 +38,7 @@ set -- "${POSITIONAL[@]}" # restore positional parameters

FILE="$1"

if [[ -z "${REPOSITORY}" || -z "${USERNAME}" || -z "${FILE}" ]]; then
if [[ -z "${REPOSITORY}" || -z "${USER_NAME}" || -z "${FILE}" ]]; then
echo "Usage: $(basename "$0") -r|--repository REPOSITORY -u|--username USERNAME [-p|--password PASSWORD] [-h|--host HOST] FILE"
exit 1
fi
Expand All @@ -53,4 +53,4 @@ if [[ -z "${HOST}" ]]; then
HOST="localhost:3030"
fi

curl -sS -X GET -H "Accept: application/trig" -u "${USERNAME}:${PASSWORD}" "http://${HOST}/${REPOSITORY}" > "${FILE}"
curl -sS -X GET -H "Accept: application/trig" -u "${USER_NAME}:${PASSWORD}" "http://${HOST}/${REPOSITORY}" > "${FILE}"
6 changes: 3 additions & 3 deletions webapi/scripts/fuseki-empty-repository.sh
Expand Up @@ -14,7 +14,7 @@ case $key in
shift # past value
;;
-u|--username)
USERNAME="$2"
USER_NAME="$2"
shift # past argument
shift # past value
;;
Expand All @@ -36,7 +36,7 @@ esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters

if [[ -z "${REPOSITORY}" || -z "${USERNAME}" ]]; then
if [[ -z "${REPOSITORY}" || -z "${USER_NAME}" ]]; then
echo "Usage: $(basename "$0") -r|--repository REPOSITORY -u|--username USERNAME [-p|--password PASSWORD] [-h|--host HOST]"
exit 1
fi
Expand All @@ -51,4 +51,4 @@ if [[ -z "${HOST}" ]]; then
HOST="localhost:3030"
fi

curl -sS -X POST -H "Content-Type: application/sparql-update" -d "DROP ALL" -u "${USERNAME}:${PASSWORD}" "http://${HOST}/${REPOSITORY}"
curl -sS -X POST -H "Content-Type: application/sparql-update" -d "DROP ALL" -u "${USER_NAME}:${PASSWORD}" "http://${HOST}/${REPOSITORY}"
12 changes: 6 additions & 6 deletions webapi/scripts/fuseki-functions.sh
Expand Up @@ -13,7 +13,7 @@ while [[ $# -gt 0 ]]; do
shift # past value
;;
-u | --username)
USERNAME="$2"
USER_NAME="$2"
shift # past argument
shift # past value
;;
Expand Down Expand Up @@ -45,16 +45,16 @@ if [[ -z "${HOST}" ]]; then
HOST="localhost:3030"
fi

if [[ -z "${USERNAME}" ]]; then
USERNAME="admin"
if [[ -z "${USER_NAME}" ]]; then
USER_NAME="admin"
fi

if [[ -z "${PASSWORD}" ]]; then
PASSWORD="test"
fi

delete-repository() {
STATUS=$(curl -s -o /dev/null -w '%{http_code}' -u ${USERNAME}:${PASSWORD} -X DELETE http://${HOST}/\$/datasets/${REPOSITORY})
STATUS=$(curl -s -o /dev/null -w '%{http_code}' -u ${USER_NAME}:${PASSWORD} -X DELETE http://${HOST}/\$/datasets/${REPOSITORY})

if [ "${STATUS}" -eq 200 ]; then
echo "==> delete repository done"
Expand All @@ -67,7 +67,7 @@ delete-repository() {

create-repository() {
REPOSITORY_CONFIG=$(sed "s/@REPOSITORY@/${REPOSITORY}/g" ./fuseki-repository-config.ttl.template)
STATUS=$(curl -s -o /dev/null -w '%{http_code}' -u ${USERNAME}:${PASSWORD} -H "Content-Type:text/turtle; charset=utf-8" --data-raw "${REPOSITORY_CONFIG}" -X POST http://${HOST}/\$/datasets)
STATUS=$(curl -s -o /dev/null -w '%{http_code}' -u ${USER_NAME}:${PASSWORD} -H "Content-Type:text/turtle; charset=utf-8" --data-raw "${REPOSITORY_CONFIG}" -X POST http://${HOST}/\$/datasets)

if [ "${STATUS}" -eq 200 ]; then
echo "==> create repository done"
Expand All @@ -79,7 +79,7 @@ create-repository() {
}

upload-graph() {
STATUS=$(curl -s -o /dev/null -w '%{http_code}' -u ${USERNAME}:${PASSWORD} -H "Content-Type:text/turtle; charset=utf-8" --data-binary @$1 -X PUT http://${HOST}/${REPOSITORY}\?graph\="$2")
STATUS=$(curl -s -o /dev/null -w '%{http_code}' -u ${USER_NAME}:${PASSWORD} -H "Content-Type:text/turtle; charset=utf-8" --data-binary @$1 -X PUT http://${HOST}/${REPOSITORY}\?graph\="$2")

if [ "${STATUS}" -eq 201 ]; then
echo "==> 201 Created: $1 -> $2"
Expand Down
6 changes: 3 additions & 3 deletions webapi/scripts/fuseki-upload-repository.sh
Expand Up @@ -14,7 +14,7 @@ case $key in
shift # past value
;;
-u|--username)
USERNAME="$2"
USER_NAME="$2"
shift # past argument
shift # past value
;;
Expand All @@ -38,7 +38,7 @@ set -- "${POSITIONAL[@]}" # restore positional parameters

FILE="$1"

if [[ -z "${REPOSITORY}" || -z "${USERNAME}" || -z "${FILE}" ]]; then
if [[ -z "${REPOSITORY}" || -z "${USER_NAME}" || -z "${FILE}" ]]; then
echo "Usage: $(basename "$0") -r|--repository REPOSITORY -u|--username USERNAME [-p|--password PASSWORD] [-h|--host HOST] FILE"
exit 1
fi
Expand All @@ -53,4 +53,4 @@ if [[ -z "${HOST}" ]]; then
HOST="localhost:3030"
fi

curl -sS -X POST -H "Content-Type: application/trig" --data-binary "@${FILE}" -u "${USERNAME}:${PASSWORD}" "http://${HOST}/${REPOSITORY}" | tee /dev/null
curl -sS -X POST -H "Content-Type: application/trig" --data-binary "@${FILE}" -u "${USER_NAME}:${PASSWORD}" "http://${HOST}/${REPOSITORY}" | tee /dev/null
6 changes: 3 additions & 3 deletions webapi/scripts/graphdb-dump-repository.sh
Expand Up @@ -14,7 +14,7 @@ case $key in
shift # past value
;;
-u|--username)
USERNAME="$2"
USER_NAME="$2"
shift # past argument
shift # past value
;;
Expand All @@ -38,7 +38,7 @@ set -- "${POSITIONAL[@]}" # restore positional parameters

FILE="$1"

if [[ -z "${REPOSITORY}" || -z "${USERNAME}" || -z "${FILE}" ]]; then
if [[ -z "${REPOSITORY}" || -z "${USER_NAME}" || -z "${FILE}" ]]; then
echo "Usage: $(basename "$0") -r|--repository REPOSITORY -u|--username USERNAME [-p|--password PASSWORD] [-h|--host HOST] FILE"
exit 1
fi
Expand All @@ -53,4 +53,4 @@ if [[ -z "${HOST}" ]]; then
HOST="localhost:7200"
fi

curl -sS -X GET -H "Accept: application/trig" -u "${USERNAME}:${PASSWORD}" "http://${HOST}/repositories/${REPOSITORY}/statements?infer=false" > "${FILE}"
curl -sS -X GET -H "Accept: application/trig" -u "${USER_NAME}:${PASSWORD}" "http://${HOST}/repositories/${REPOSITORY}/statements?infer=false" > "${FILE}"
6 changes: 3 additions & 3 deletions webapi/scripts/graphdb-empty-repository.sh
Expand Up @@ -14,7 +14,7 @@ case $key in
shift # past value
;;
-u|--username)
USERNAME="$2"
USER_NAME="$2"
shift # past argument
shift # past value
;;
Expand All @@ -36,7 +36,7 @@ esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters

if [[ -z "${REPOSITORY}" || -z "${USERNAME}" ]]; then
if [[ -z "${REPOSITORY}" || -z "${USER_NAME}" ]]; then
echo "Usage: $(basename "$0") -r|--repository REPOSITORY -u|--username USERNAME [-p|--password PASSWORD] [-h|--host HOST]"
exit 1
fi
Expand All @@ -51,4 +51,4 @@ if [[ -z "${HOST}" ]]; then
HOST="localhost:7200"
fi

curl -sS -X POST -H "Content-Type: application/sparql-update" -d "DROP ALL" -u "${USERNAME}:${PASSWORD}" "http://${HOST}/repositories/${REPOSITORY}/statements"
curl -sS -X POST -H "Content-Type: application/sparql-update" -d "DROP ALL" -u "${USER_NAME}:${PASSWORD}" "http://${HOST}/repositories/${REPOSITORY}/statements"
6 changes: 3 additions & 3 deletions webapi/scripts/graphdb-upload-repository.sh
Expand Up @@ -14,7 +14,7 @@ case $key in
shift # past value
;;
-u|--username)
USERNAME="$2"
USER_NAME="$2"
shift # past argument
shift # past value
;;
Expand All @@ -38,7 +38,7 @@ set -- "${POSITIONAL[@]}" # restore positional parameters

FILE="$1"

if [[ -z "${REPOSITORY}" || -z "${USERNAME}" || -z "${FILE}" ]]; then
if [[ -z "${REPOSITORY}" || -z "${USER_NAME}" || -z "${FILE}" ]]; then
echo "Usage: $(basename "$0") -r|--repository REPOSITORY -u|--username USERNAME [-p|--password PASSWORD] [-h|--host HOST] FILE"
exit 1
fi
Expand All @@ -53,4 +53,4 @@ if [[ -z "${HOST}" ]]; then
HOST="localhost:7200"
fi

curl -sS -X POST -H "Content-Type: application/trig" --data-binary "@${FILE}" -u "${USERNAME}:${PASSWORD}" "http://${HOST}/repositories/${REPOSITORY}/statements" | tee /dev/null
curl -sS -X POST -H "Content-Type: application/trig" --data-binary "@${FILE}" -u "${USER_NAME}:${PASSWORD}" "http://${HOST}/repositories/${REPOSITORY}/statements" | tee /dev/null
8 changes: 4 additions & 4 deletions webapi/scripts/wait-for-db.sh
Expand Up @@ -21,7 +21,7 @@ while [[ $# -gt 0 ]]; do
;;

-u | --username)
USERNAME="$2"
USER_NAME="$2"
shift # past argument
shift # past value
;;
Expand All @@ -48,16 +48,16 @@ if [[ -z "${TIMEOUT}" ]]; then
TIMEOUT=360
fi

if [[ -z "${USERNAME}" ]]; then
USERNAME="admin"
if [[ -z "${USER_NAME}" ]]; then
USER_NAME="admin"
fi

if [[ -z "${PASSWORD}" ]]; then
PASSWORD="test"
fi

poll-db() {
STATUS=$(curl -s -o /dev/null -w '%{http_code}' -u ${USERNAME}:${PASSWORD} http://${HOST}/\$/server)
STATUS=$(curl -s -o /dev/null -w '%{http_code}' -u ${USER_NAME}:${PASSWORD} http://${HOST}/\$/server)

if [ "${STATUS}" -eq 200 ]; then
echo "==> DB started"
Expand Down

0 comments on commit eccd163

Please sign in to comment.