@@ -46,9 +46,9 @@ usage() {
|
|||||||
-c|--clipboard # Throw the result into the clipboard
|
-c|--clipboard # Throw the result into the clipboard
|
||||||
-i|--my-ip # Get the IP you're reaching the service with, usually it will be your public address.
|
-i|--my-ip # Get the IP you're reaching the service with, usually it will be your public address.
|
||||||
-l|--login <username> # Get a login token sent to email for <username>
|
-l|--login <username> # Get a login token sent to email for <username>
|
||||||
-C|--xclip-selector # Set the xclip selector explicitly
|
-C|--xclip-selector <sel> # Set the xclip selector explicitly
|
||||||
--tmp-dir # Set the temp dir
|
--tmp-dir <path> # Set the temp dir
|
||||||
--url # Set the service url
|
--url <url> # Set the service url
|
||||||
|
|
||||||
Config options (~/.config/ufw):
|
Config options (~/.config/ufw):
|
||||||
secret # Your personal token. Get it at https://8fw.me/settings_form
|
secret # Your personal token. Get it at https://8fw.me/settings_form
|
||||||
@@ -250,7 +250,9 @@ get_my_ip() {
|
|||||||
login() {
|
login() {
|
||||||
declare api_response login=$1
|
declare api_response login=$1
|
||||||
|
|
||||||
api_response=$( curl "$cfg_service_url/token_request.json?login=$login" )
|
api_response=$( curl --get \
|
||||||
|
--data-urlencode "login=$login" \
|
||||||
|
"$cfg_service_url/token_request.json" )
|
||||||
|
|
||||||
if get_api_status <<< "$api_response"; then
|
if get_api_status <<< "$api_response"; then
|
||||||
printf 'Check your email.\n'
|
printf 'Check your email.\n'
|
||||||
@@ -270,7 +272,14 @@ get_token() {
|
|||||||
read -sp 'Password: ' password
|
read -sp 'Password: ' password
|
||||||
printf '\n'
|
printf '\n'
|
||||||
|
|
||||||
login_response=$(curl -c "$cfg_file.cookiejar" -d "login=$login" -d "password=$password" -sl "$cfg_service_url/login.json")
|
login_response=$(curl -f -c "$cfg_file.cookiejar" -d "login=$login" -d "password=$password" -sl "$cfg_service_url/login.json")
|
||||||
|
(( $? )) || {
|
||||||
|
err "Login failed."
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
chmod 600 "$cfg_file.cookiejar"
|
||||||
|
|
||||||
get_api_status <<< "$login_response" || {
|
get_api_status <<< "$login_response" || {
|
||||||
jq -r '.status.message' <<< "$login_response"
|
jq -r '.status.message' <<< "$login_response"
|
||||||
return 1
|
return 1
|
||||||
@@ -379,7 +388,6 @@ main() {
|
|||||||
|
|
||||||
(--tmp-dir) cfg_tmp_dir=$2; shift;;
|
(--tmp-dir) cfg_tmp_dir=$2; shift;;
|
||||||
(--url) cfg_service_url=$2; shift;;
|
(--url) cfg_service_url=$2; shift;;
|
||||||
(--max-filesize) cfg_max_filesize=$2; shift;;
|
|
||||||
|
|
||||||
(-i|--my-ip) action='getmyip';;
|
(-i|--my-ip) action='getmyip';;
|
||||||
(-u|--shorten) action='url';;
|
(-u|--shorten) action='url';;
|
||||||
@@ -448,7 +456,7 @@ main() {
|
|||||||
(( ${#args[@]} )) || return 1
|
(( ${#args[@]} )) || return 1
|
||||||
|
|
||||||
if [[ "$album_name" ]]; then
|
if [[ "$album_name" ]]; then
|
||||||
get_album_id "$album_name"
|
get_album_id "$album_name" || return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for t in "${args[@]}"; do
|
for t in "${args[@]}"; do
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ err() { echo "$*" >&2; }
|
|||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
printf 'Usage: ufwd [flags]\n'
|
printf 'Usage: ufwd [flags]\n'
|
||||||
printf ' -h # Show this message.\n'
|
printf ' --help|-h # Show this message.\n'
|
||||||
printf ' -n # Enable notifications with notify-send. Must be installed.\n'
|
printf ' --notify|-n # Enable notifications with notify-send. Must be installed.\n'
|
||||||
printf ' -d [path] # Set the dir that is to be watched.\n'
|
printf ' --workdir|-d [path] # Set the dir that is to be watched.\n'
|
||||||
printf ' -s # Push the file url into the clipboard.\n'
|
printf ' --clipboard|-c # Enable clipboard.\n'
|
||||||
printf ' --magick <type:format> # Convert files of `type` into `format` with magick.\n'
|
printf ' --magick <type:format> # Convert files of `type` into `format` with magick.\n'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ main() {
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
[[ $cfg_workdir ]] || cfg_workdir="$XDG_RUNTIME_DIR/ufwd"
|
[[ $cfg_workdir ]] || cfg_workdir=( "$XDG_RUNTIME_DIR/ufwd" )
|
||||||
|
|
||||||
if (( flag_enable_notifications )); then
|
if (( flag_enable_notifications )); then
|
||||||
if type -P notify-send &>/dev/null; then
|
if type -P notify-send &>/dev/null; then
|
||||||
@@ -87,7 +87,10 @@ main() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
for p in "${cfg_workdir[@]}"; do
|
for p in "${cfg_workdir[@]}"; do
|
||||||
[[ -d "$p" ]] || return 1
|
[[ -d "$p" ]] || {
|
||||||
|
err "No such directory: $p"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
done
|
done
|
||||||
|
|
||||||
printf 'Working in:\n'
|
printf 'Working in:\n'
|
||||||
|
|||||||
Reference in New Issue
Block a user