group curl settings and make em configurable at the same time
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
parent
6e9046367f
commit
522dc0e1f6
14
ufw
14
ufw
|
@ -23,6 +23,8 @@ msg() {
|
||||||
|
|
||||||
err() { printf '(error) %s\n' "$*" >&2; }
|
err() { printf '(error) %s\n' "$*" >&2; }
|
||||||
|
|
||||||
|
curl() { command curl -sL "$@"; }
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
_cat <<- EOF
|
_cat <<- EOF
|
||||||
Usage: ufw [-RsF] [-D num] [file/url]
|
Usage: ufw [-RsF] [-D num] [file/url]
|
||||||
|
@ -81,7 +83,7 @@ get_max_filesize() {
|
||||||
get_album_id() {
|
get_album_id() {
|
||||||
declare api_response api_status api_status_message
|
declare api_response api_status api_status_message
|
||||||
|
|
||||||
api_response=$( curl -fsL "$cfg_service_url/albumctl.json?m=new&name=$1&secret=$secret" )
|
api_response=$( curl -f "$cfg_service_url/albumctl.json?m=new&name=$1&secret=$secret" )
|
||||||
|
|
||||||
get_api_status <<< "$api_response"
|
get_api_status <<< "$api_response"
|
||||||
|
|
||||||
|
@ -110,7 +112,7 @@ upload() {
|
||||||
|
|
||||||
get_max_filesize || { return 1; }
|
get_max_filesize || { return 1; }
|
||||||
|
|
||||||
curl --max-filesize "$max_filesize_bytes" -sL "$target" > "$file"
|
curl --max-filesize "$max_filesize_bytes" "$target" > "$file"
|
||||||
curl_result=$?
|
curl_result=$?
|
||||||
|
|
||||||
if (( curl_result )); then
|
if (( curl_result )); then
|
||||||
|
@ -136,7 +138,7 @@ upload() {
|
||||||
get_album_id "$album_name"
|
get_album_id "$album_name"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
api_response=$( curl -sL \
|
api_response=$( curl \
|
||||||
-F file="@$file" \
|
-F file="@$file" \
|
||||||
-F api_format='json' \
|
-F api_format='json' \
|
||||||
-F flag_private="$flag_private" \
|
-F flag_private="$flag_private" \
|
||||||
|
@ -183,7 +185,7 @@ upload() {
|
||||||
get_shortlink() {
|
get_shortlink() {
|
||||||
declare url=$1 api_response api_status api_status_message
|
declare url=$1 api_response api_status api_status_message
|
||||||
|
|
||||||
api_response=$( curl -sL "$cfg_service_url/shrink.json?url=${url}&secret=$secret" )
|
api_response=$( curl "$cfg_service_url/shrink.json?url=${url}&secret=$secret" )
|
||||||
get_api_status <<< "$api_response"
|
get_api_status <<< "$api_response"
|
||||||
|
|
||||||
if (( api_status == 200 )); then
|
if (( api_status == 200 )); then
|
||||||
|
@ -225,7 +227,7 @@ _mktemp() {
|
||||||
get_my_ip() {
|
get_my_ip() {
|
||||||
declare api_response api_status api_status_message my_ip
|
declare api_response api_status api_status_message my_ip
|
||||||
|
|
||||||
api_response=$( curl -sl "$cfg_service_url/ip.json" )
|
api_response=$( curl "$cfg_service_url/ip.json" )
|
||||||
|
|
||||||
get_api_status <<< "$api_response"
|
get_api_status <<< "$api_response"
|
||||||
|
|
||||||
|
@ -240,7 +242,7 @@ get_my_ip() {
|
||||||
login() {
|
login() {
|
||||||
declare api_response
|
declare api_response
|
||||||
|
|
||||||
api_response=$( curl -sl "$cfg_service_url/token_request.json?login=$login" )
|
api_response=$( curl "$cfg_service_url/token_request.json?login=$login" )
|
||||||
|
|
||||||
if get_api_status <<< "$api_response"; then
|
if get_api_status <<< "$api_response"; then
|
||||||
printf 'Check your email.\n'
|
printf 'Check your email.\n'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user