New tool: supd
supd is a very simple tool that uploads everything from a directory to zfh. Also some refactoring on sup.
This commit is contained in:
parent
5e8960d376
commit
75897a38f7
19
sup
19
sup
|
@ -49,16 +49,14 @@ sup.env() {
|
|||
}
|
||||
|
||||
sup.upload() {
|
||||
curl -F file="@$file" \
|
||||
curl -fsL \
|
||||
-F file="@$file" \
|
||||
-F upload_mode='api' \
|
||||
-F flag_private="$flag_private" \
|
||||
-F secret="$secret" \
|
||||
-F submit="" \
|
||||
"$cfg_script_url" -sL -A 'zerofiles.org upload script' || { return 1; }
|
||||
|
||||
(( "$flag_rm" )) && { rm "$file"; }
|
||||
|
||||
return 0
|
||||
-A 'zerofiles.org upload script' \
|
||||
"$cfg_script_url"
|
||||
}
|
||||
|
||||
sup.mktemp() {
|
||||
|
@ -197,7 +195,14 @@ main() {
|
|||
fi
|
||||
fi
|
||||
|
||||
sup.upload
|
||||
if sup.upload; then
|
||||
if (( "$flag_rm" )); then
|
||||
rm "$file"
|
||||
fi
|
||||
else
|
||||
sup.err 'Something has gone wrong with the upload.'
|
||||
return 7
|
||||
fi
|
||||
}
|
||||
|
||||
sup.set_argv "$@"
|
||||
|
|
47
supd
Executable file
47
supd
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bash
|
||||
shopt -s nullglob
|
||||
|
||||
# Defaults
|
||||
cfg_workdir="/tmp/$USER/supd"
|
||||
cfg_scan_delay='30'
|
||||
|
||||
msg() { printf '%s\n' "$*"; }
|
||||
err() { echo "$*" >&2; }
|
||||
|
||||
usage() { echo "No help available."; }
|
||||
|
||||
main() {
|
||||
while (( $# )); do
|
||||
case "$1" in
|
||||
(--help|-h) usage; return 0;;
|
||||
(--workdir|-d) cfg_workdir="$2"; shift;;
|
||||
(--scan-delay|-D) cfg_scan_delay="$2"; shift;;
|
||||
|
||||
(--) shift; break;;
|
||||
(-*)
|
||||
err "Unknown key: $1"
|
||||
usage
|
||||
return 1
|
||||
;;
|
||||
|
||||
(*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
mkdir -p "$cfg_workdir" || {
|
||||
return 1
|
||||
}
|
||||
|
||||
cd "$cfg_workdir" || {
|
||||
return 1
|
||||
}
|
||||
|
||||
while sleep "$cfg_scan_delay"; do
|
||||
for i in *; do
|
||||
sup -R "$i"
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
main "$@"
|
Loading…
Reference in New Issue
Block a user