fix some shellchecks
This commit is contained in:
31
run.sh
31
run.sh
@@ -3,24 +3,24 @@
|
|||||||
# parameters
|
# parameters
|
||||||
|
|
||||||
FILES=${PLUGIN_FILES:-"*"}
|
FILES=${PLUGIN_FILES:-"*"}
|
||||||
API_URL=${PLUGIN_API_URL}
|
API_URL=${PLUGIN_API_URL:-}
|
||||||
REPO=${PLUGIN_REPO}
|
REPO=${PLUGIN_REPO:-}
|
||||||
DISTRIBUTION=${PLUGIN_DISTRIBUTION}
|
DISTRIBUTION=${PLUGIN_DISTRIBUTION:-}
|
||||||
PASSPHRASE=${PLUGIN_PASSPHRASE}
|
PASSPHRASE=${PLUGIN_PASSPHRASE:-}
|
||||||
HTTP_USER=${PLUGIN_HTTP_USER}
|
HTTP_USER=${PLUGIN_HTTP_USER:-}
|
||||||
HTTP_PASS=${PLUGIN_HTTP_PASS}
|
HTTP_PASS=${PLUGIN_HTTP_PASS:-}
|
||||||
|
|
||||||
if [ -z "$API_URL" ] ; then
|
if [[ -z "${API_URL}" ]] ; then
|
||||||
echo "API_URL is required"
|
echo "API_URL is required"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$REPO" ] ; then
|
if [[ -z "${REPO}" ]] ; then
|
||||||
echo "REPO is required"
|
echo "REPO is required"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$DISTRIBUTION" ] ; then
|
if [[ -z "${DISTRIBUTION}" ]] ; then
|
||||||
echo "DISTRIBUTION is required"
|
echo "DISTRIBUTION is required"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -30,28 +30,31 @@ TMPDIR=$( mktemp -d )
|
|||||||
UPLOADDIRNAME=$( head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16 )
|
UPLOADDIRNAME=$( head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16 )
|
||||||
NETRC=$( mktemp )
|
NETRC=$( mktemp )
|
||||||
|
|
||||||
if [ -z "${HTTP_USER}" ] || [ -z "${HTTP_PASS}" ] ; then
|
if [[ -z "${HTTP_USER}" || -z "${HTTP_PASS}" ]] ; then
|
||||||
AUTH=""
|
AUTH=""
|
||||||
else
|
else
|
||||||
HOST=$(echo "$API_URL" | sed -E 's/^https?\:\/\/(.*)\/.*/\1/g' )
|
HOST=$(echo "${API_URL}" | sed -E 's/^https?\:\/\/(.*)\/.*/\1/g' )
|
||||||
echo "machine ${HOST} login ${HTTP_USER} password ${HTTP_PASS}" > "$NETRC"
|
echo "machine ${HOST} login ${HTTP_USER} password ${HTTP_PASS}" > "${NETRC}"
|
||||||
AUTH="--netrc-file ${NETRC}"
|
AUTH="--netrc-file ${NETRC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# maybe do this better, it can lead to unwanted word splitting
|
# TODO: maybe do this better, it can lead to unwanted word splitting
|
||||||
cp -r $( echo "${FILES}" | sed 's/\([^\\]\)\,/\1 /g' ) "${TMPDIR}/"
|
cp -r $( echo "${FILES}" | sed 's/\([^\\]\)\,/\1 /g' ) "${TMPDIR}/"
|
||||||
|
|
||||||
cd "${TMPDIR}" || exit
|
cd "${TMPDIR}" || exit
|
||||||
for file in *.deb ; do
|
for file in *.deb ; do
|
||||||
echo "uploading '$file' to remote directory '${UPLOADDIRNAME}'"
|
echo "uploading '$file' to remote directory '${UPLOADDIRNAME}'"
|
||||||
|
# shellcheck disable=SC2086
|
||||||
curl ${AUTH} -X POST -F "file=@${file}" "${API_URL}/files/${UPLOADDIRNAME}"
|
curl ${AUTH} -X POST -F "file=@${file}" "${API_URL}/files/${UPLOADDIRNAME}"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Adding files to ${REPO}"
|
echo "Adding files to ${REPO}"
|
||||||
|
# shellcheck disable=SC2086
|
||||||
curl ${AUTH} -X POST "${API_URL}/repos/${REPO}/file/${UPLOADDIRNAME}"
|
curl ${AUTH} -X POST "${API_URL}/repos/${REPO}/file/${UPLOADDIRNAME}"
|
||||||
|
|
||||||
if [ -n "${PASSPHRASE}" ] ; then
|
if [[ -n "${PASSPHRASE}" ]] ; then
|
||||||
echo "Signing and publishing ${REPO}"
|
echo "Signing and publishing ${REPO}"
|
||||||
|
# shellcheck disable=SC2086
|
||||||
curl ${AUTH} -X PUT -H 'Content-Type: application/json' --data "{\"Signing\": {\"Passphrase\": \"${PASSPHRASE}\", \"Batch\":true}, \"ForceOverwrite\": true}" "${API_URL}/publish/:./${DISTRIBUTION}"
|
curl ${AUTH} -X PUT -H 'Content-Type: application/json' --data "{\"Signing\": {\"Passphrase\": \"${PASSPHRASE}\", \"Batch\":true}, \"ForceOverwrite\": true}" "${API_URL}/publish/:./${DISTRIBUTION}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user