19 lines
432 B
Bash
19 lines
432 B
Bash
#!/bin/bash
|
|
|
|
# shellcheck source=homepage_server-env
|
|
. "${HOME}"/"${USER}"-env
|
|
|
|
headers=$(curl -SsIXGET "$1")
|
|
|
|
status_code=$(echo "$headers" | grep -E "HTTP/.* [0-9]{3}" | awk '{print $2}')
|
|
|
|
if [[ $status_code == "200" ]]; then
|
|
ext=$(echo "$headers" | grep "content-type:" | awk -F/ '{print $2}' | tr -d " \t\n\r")
|
|
curl -Ss -o "${VOLUME_PATH}"/images/"${2}"."${ext}" "${1}"
|
|
echo "found"
|
|
exit 0
|
|
else
|
|
echo "Not Found"
|
|
exit 1
|
|
fi
|