Skip to content

Commit

Permalink
Missing downloadDomain in bash script if not given in plikd.cfg root-…
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles-Antoine Mathieu committed Sep 28, 2020
1 parent 6ef017c commit 7529e0f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions client/plik.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ function setTtl() {
#
## Vars
#
PLIK_URL=${PLIK_URL-"http://127.0.0.1:8080"}
PLIK_TOKEN=${PLIK_TOKEN-""}
QUIET=false
SECURE=false
Expand All @@ -57,16 +56,22 @@ if [ ! -f "$PLIKRC" ]; then
fi

if [ -f "$PLIKRC" ]; then
URL=$(grep URL $PLIKRC | grep -Po '(http[^\"]*)')
if [ "$URL" != "" ]; then
PLIK_URL=$URL
# Evironment variable takes precedence over plikrc file
if [ "$PLIK_URL" == "" ]; then
URL=$(grep URL $PLIKRC | grep -Po '(http[^\"]*)')
if [ "$URL" != "" ]; then
PLIK_URL=$URL
fi
fi
TOKEN=$(grep Token $PLIKRC | sed -n 's/^.*"\(.*\)".*$/\1/p' )
if [ "$TOKEN" != "" ]; then
PLIK_TOKEN=$TOKEN
fi
fi

# Default URL to local instance
PLIK_URL=${PLIK_URL-"http://127.0.0.1:8080"}

#
## Parse arguments
#
Expand Down Expand Up @@ -108,7 +113,11 @@ qecho -e "Create new upload on $PLIK_URL...\n"
CREATE_UPLOAD_CMD="curl -s -X POST $AUTH_TOKEN_HEADER -d '$OPTIONS' ${PLIK_URL}/upload"
NEW_UPLOAD_RESP=$(eval $CREATE_UPLOAD_CMD)
UPLOAD_ID=$(echo $NEW_UPLOAD_RESP | jsonValue id)

DOWNLOAD_DOMAIN=$(echo $NEW_UPLOAD_RESP | jsonValue downloadDomain)
if [ "$DOWNLOAD_DOMAIN" == "" ]; then
DOWNLOAD_DOMAIN=$PLIK_URL
fi

# Handle error
if [ "$UPLOAD_ID" == "" ]; then
Expand Down

0 comments on commit 7529e0f

Please sign in to comment.