Skip to content

Commit

Permalink
Customize the shell script a bit more
Browse files Browse the repository at this point in the history
Add a shbang using env
Let override directly the url on argument if set
Still handle -l and GOSMEE_DEBUG_SERVICE
  • Loading branch information
chmouel committed Dec 1, 2023
1 parent bc8b469 commit c149d8b
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions gosmee/templates/replay_script.tmpl.bash
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
#!/bin/bash
#
#!/usr/bin/env bash
# Copyright 2023 Chmouel Boudjnah <[email protected]>
# Replay script with headers and JSON payload to the target controller.
#
# You can switch the targetURL to another one with the -l switch, which defaults
# to http://localhost:8080.
# You can switch the targetURL with the first command line argument and you can
# the -l switch, which defaults to http://localhost:8080.
# Same goes for the variable GOSMEE_DEBUG_SERVICE.
#
# You can customze this target with the env variable: GOSMEE_DEBUG_SERVICE
set -euxf
set -euxfo pipefail
cd $(dirname $(readlink -f $0))

targetURL="{{ .TargetURL }}"
[[ ${1:-""} == -l ]] && targetURL=${GOSMEE_DEBUG_SERVICE:-"http://localhost:8080"}
if [[ ${1:-""} == -l ]]; then
targetURL="http://localhost:8080"
elif [[ -n ${1:-""} ]]; then
targetURL=${1}
elif [[ -n ${GOSMEE_DEBUG_SERVICE:-""} ]]; then
targetURL=${GOSMEE_DEBUG_SERVICE}
fi

curl -sSi -H "Content-Type: {{ .ContentType }}" {{ .Headers }} -X POST -d @./{{ .FileBase }}.json ${targetURL}

0 comments on commit c149d8b

Please sign in to comment.