Initial commit (I feel unsafe)
This commit is contained in:
18
homepage_server-getimage
Normal file
18
homepage_server-getimage
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user