3 Commits
1.8.1 ... 1.9.2

Author SHA1 Message Date
fbt
776217ab00 8fw now marks new files as private unless stated otherwise
Signed-off-by: fbt <fbt@fleshless.org>
2016-02-22 23:19:06 +03:00
fbt
2d7e65682f eh 2016-01-01 17:16:03 +03:00
fbt
baa483e7cc notification support 2015-12-20 15:46:24 +03:00
2 changed files with 30 additions and 10 deletions

15
ufw
View File

@@ -1,12 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/bash
# Copyright (c) 2012 fbt <fbt@fleshless.org> # Copyright (c) 2012 fbt <fbt@fleshless.org>
# License: ISC
# #
# About: # About:
# A simple upload script for ZFH (http://zerofiles.org) # A simple upload script for UFW (http://zerofiles.org)
_self="${0##*/}"
_cat() { _cat() {
while read; do while read; do
@@ -23,14 +20,14 @@ err() { msg "(error) $1" >&2; }
usage() { usage() {
_cat <<- EOF _cat <<- EOF
Usage: ${_self} [-RsF] [-D num] [file/url]" Usage: ufw [-RsF] [-D num] [file/url]"
Flags: Flags:
-R # Remove the file after uploading. -R # Remove the file after uploading.
-s # Make a screenshot and upload it instead of a file. -s # Make a screenshot and upload it instead of a file.
-F # Make a fullscreen shot instead of prompting for a window/area. Implies -s. -F # Make a fullscreen shot instead of prompting for a window/area. Implies -s.
-d # Supply a dexcription. -d # Supply a dexcription.
-D <num> # Delay the shot by <num> seconds. -D <num> # Delay the shot by <num> seconds.
-p # Make the file private. Requires \$secret to be set in the config. -p # Make the file public.
-u # Generate a shortlink from URL. -u # Generate a shortlink from URL.
-m # Maximum filesize (takes K, M and G suffixes). -m # Maximum filesize (takes K, M and G suffixes).
@@ -260,7 +257,7 @@ main() {
while [[ "$1" ]]; do while [[ "$1" ]]; do
case "$1" in case "$1" in
-p|--private) flag_private='true';; -p|--private) flag_private='false';;
-R|--remove-file) flag_rm='1';; -R|--remove-file) flag_rm='1';;
-s|--screenshot) flag_scrot='1';; -s|--screenshot) flag_scrot='1';;

25
ufwd
View File

@@ -19,9 +19,12 @@ main() {
while (( $# )); do while (( $# )); do
case "$1" in case "$1" in
(--help|-h) usage; return 0;; (--help|-h) usage; return 0;;
(--workdir|-d) cfg_workdir="$2"; shift;; (--workdir|-d) cfg_workdir="$2"; shift;;
(--scan-delay|-D) cfg_scan_delay="$2"; shift;; (--scan-delay|-D) cfg_scan_delay="$2"; shift;;
(--notify|-n) flag_enable_notifications=1;;
(--) shift; break;; (--) shift; break;;
(-*) (-*)
err "Unknown key: $1" err "Unknown key: $1"
@@ -34,6 +37,15 @@ main() {
shift shift
done done
if (( flag_enable_notifications )); then
if type -P notify-send &>/dev/null; then
msg "Found notify-send."
else
err "notify-send not found in PATH, disabling notifications."
flag_enable_notifications=0
fi
fi
mkdir -p "$cfg_workdir" || { mkdir -p "$cfg_workdir" || {
return 1 return 1
} }
@@ -44,7 +56,18 @@ main() {
while sleep "$cfg_scan_delay"; do while sleep "$cfg_scan_delay"; do
for i in *; do for i in *; do
ufw -R "$i" upload_output=$( ufw -R "$i" )
upload_return=$?
if (( flag_enable_notifications )); then
if (( $upload_return )); then
notify-send 'ufwd' "File upload failed: $upload_output"
else
notify-send 'ufwd' "File uploaded: $upload_output"
fi
fi
printf '%s\n' "$upload_output"
done done
done done
} }