fix some shellchecks
This commit is contained in:
31
run.sh
31
run.sh
@@ -3,24 +3,24 @@
|
||||
# parameters
|
||||
|
||||
FILES=${PLUGIN_FILES:-"*"}
|
||||
API_URL=${PLUGIN_API_URL}
|
||||
REPO=${PLUGIN_REPO}
|
||||
DISTRIBUTION=${PLUGIN_DISTRIBUTION}
|
||||
PASSPHRASE=${PLUGIN_PASSPHRASE}
|
||||
HTTP_USER=${PLUGIN_HTTP_USER}
|
||||
HTTP_PASS=${PLUGIN_HTTP_PASS}
|
||||
API_URL=${PLUGIN_API_URL:-}
|
||||
REPO=${PLUGIN_REPO:-}
|
||||
DISTRIBUTION=${PLUGIN_DISTRIBUTION:-}
|
||||
PASSPHRASE=${PLUGIN_PASSPHRASE:-}
|
||||
HTTP_USER=${PLUGIN_HTTP_USER:-}
|
||||
HTTP_PASS=${PLUGIN_HTTP_PASS:-}
|
||||
|
||||
if [ -z "$API_URL" ] ; then
|
||||
if [[ -z "${API_URL}" ]] ; then
|
||||
echo "API_URL is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$REPO" ] ; then
|
||||
if [[ -z "${REPO}" ]] ; then
|
||||
echo "REPO is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$DISTRIBUTION" ] ; then
|
||||
if [[ -z "${DISTRIBUTION}" ]] ; then
|
||||
echo "DISTRIBUTION is required"
|
||||
exit 1
|
||||
fi
|
||||
@@ -30,28 +30,31 @@ TMPDIR=$( mktemp -d )
|
||||
UPLOADDIRNAME=$( head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16 )
|
||||
NETRC=$( mktemp )
|
||||
|
||||
if [ -z "${HTTP_USER}" ] || [ -z "${HTTP_PASS}" ] ; then
|
||||
if [[ -z "${HTTP_USER}" || -z "${HTTP_PASS}" ]] ; then
|
||||
AUTH=""
|
||||
else
|
||||
HOST=$(echo "$API_URL" | sed -E 's/^https?\:\/\/(.*)\/.*/\1/g' )
|
||||
echo "machine ${HOST} login ${HTTP_USER} password ${HTTP_PASS}" > "$NETRC"
|
||||
HOST=$(echo "${API_URL}" | sed -E 's/^https?\:\/\/(.*)\/.*/\1/g' )
|
||||
echo "machine ${HOST} login ${HTTP_USER} password ${HTTP_PASS}" > "${NETRC}"
|
||||
AUTH="--netrc-file ${NETRC}"
|
||||
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}/"
|
||||
|
||||
cd "${TMPDIR}" || exit
|
||||
for file in *.deb ; do
|
||||
echo "uploading '$file' to remote directory '${UPLOADDIRNAME}'"
|
||||
# shellcheck disable=SC2086
|
||||
curl ${AUTH} -X POST -F "file=@${file}" "${API_URL}/files/${UPLOADDIRNAME}"
|
||||
done
|
||||
|
||||
echo "Adding files to ${REPO}"
|
||||
# shellcheck disable=SC2086
|
||||
curl ${AUTH} -X POST "${API_URL}/repos/${REPO}/file/${UPLOADDIRNAME}"
|
||||
|
||||
if [ -n "${PASSPHRASE}" ] ; then
|
||||
if [[ -n "${PASSPHRASE}" ]] ; then
|
||||
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}"
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user