Updated bash script
This commit is contained in:
parent
8ce337233c
commit
1c8e4dff47
1 changed files with 12 additions and 20 deletions
|
@ -31,36 +31,28 @@ EOF
|
||||||
upload() {
|
upload() {
|
||||||
RESPONSE="$(curl -s -F "token={{ token }}" -F "upload=@${1}" {{ upload_url }})";
|
RESPONSE="$(curl -s -F "token={{ token }}" -F "upload=@${1}" {{ upload_url }})";
|
||||||
|
|
||||||
if jq -e . >/dev/null 2>&1 <<<"$RESPONSE"; then
|
|
||||||
# Response is JSON
|
|
||||||
echo "Upload Completed.";
|
|
||||||
else
|
|
||||||
if [ "${DESKTOP_SESSION}" != "" ]; then
|
|
||||||
notify-send "Error: Uploading returned unexpected response" "Response: ${RESPONSE}";
|
|
||||||
else
|
|
||||||
echo "Error: Uploading returned unexpected response: ${RESPONSE}"
|
|
||||||
fi
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$(echo "${RESPONSE}" | jq -r '.message')" == "OK" ]]; then
|
if [[ "$(echo "${RESPONSE}" | jq -r '.message')" == "OK" ]]; then
|
||||||
URL="$(echo "${RESPONSE}" | jq -r '.url')";
|
URL="$(echo "${RESPONSE}" | jq -r '.url')";
|
||||||
if [ "${DESKTOP_SESSION}" != "" ]; then
|
if [ "${DESKTOP_SESSION}" != "" ]; then
|
||||||
echo "${URL}" | xclip -selection c;
|
echo "${URL}" | xclip -selection c;
|
||||||
notify-send "Upload completed!" "${URL}";
|
notify-send "Upload completed!" "${URL}";
|
||||||
exit 0;
|
|
||||||
else
|
else
|
||||||
echo "${URL}";
|
echo "${URL}";
|
||||||
|
fi
|
||||||
exit 0;
|
exit 0;
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
|
MESSAGE="$(echo "${RESPONSE}" | jq -r '.message')";
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Unexpected response:";
|
||||||
|
echo "${RESPONSE}";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
if [ "${DESKTOP_SESSION}" != "" ]; then
|
if [ "${DESKTOP_SESSION}" != "" ]; then
|
||||||
notify-send "Error!" "$(echo "${RESPONSE}" | jq -r '.message')";
|
notify-send "Error!" "${MESSAGE}";
|
||||||
exit 1;
|
|
||||||
else
|
else
|
||||||
echo "Error! $(echo "${RESPONSE}" | jq -r '.message')";
|
echo "Error! ${MESSAGE}";
|
||||||
exit 1;
|
|
||||||
fi
|
fi
|
||||||
|
exit 1;
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue