2021-08-01 10:29:38 -07:00
|
|
|
#!/usr/bin/env sh
|
2017-03-02 23:24:01 -08:00
|
|
|
# remote file access (http file-sharing shenanigans)
|
2021-07-29 00:37:35 -07:00
|
|
|
# YES_ZSH
|
2021-07-29 05:44:12 -07:00
|
|
|
# YES_BASH
|
|
|
|
# YES_DASH
|
2021-09-23 06:48:05 -07:00
|
|
|
# YES_ASH
|
2017-03-02 23:24:01 -08:00
|
|
|
|
2021-08-01 10:29:38 -07:00
|
|
|
ea() { ### @- **TODO:** document.
|
|
|
|
local cmd="${1:?missing subcommand}"; shift
|
|
|
|
case "$cmd" in
|
|
|
|
head)
|
2021-10-01 04:13:49 -07:00
|
|
|
local trg="$EA_DOMAIN/$EA_DIR/${1:?missing target}"
|
2021-08-01 10:29:38 -07:00
|
|
|
curl -s -I "$trg"
|
|
|
|
return;;
|
|
|
|
|
|
|
|
get)
|
2021-10-01 04:13:49 -07:00
|
|
|
local trg="$EA_DOMAIN/$EA_DIR/${1:?missing target}"
|
2021-08-01 10:29:38 -07:00
|
|
|
curl -R "$trg" -o "${2:-$1}"
|
|
|
|
return;;
|
|
|
|
|
|
|
|
put)
|
|
|
|
local src="${1:?missing source}"
|
2021-10-01 04:13:49 -07:00
|
|
|
local dst="$EA_DOMAIN/$EA_AUTH/"
|
2021-08-01 10:29:38 -07:00
|
|
|
curl -g -n -T "$src" "$dst"
|
|
|
|
return;;
|
|
|
|
|
|
|
|
move)
|
2021-10-01 04:13:49 -07:00
|
|
|
local src="$EA_DOMAIN/$EA_AUTH/${1:?missing source}"
|
|
|
|
local dst="$EA_DOMAIN/$EA_DIR/${2:?missing destination}"
|
2021-08-01 10:29:38 -07:00
|
|
|
curl -n -X MOVE -H "Destination: $dst" "$src"
|
|
|
|
return;;
|
|
|
|
|
|
|
|
copy)
|
2021-10-01 04:13:49 -07:00
|
|
|
local src="$EA_DOMAIN/$EA_AUTH/${1:?missing source}"
|
|
|
|
local dst="$EA_DOMAIN/$EA_DIR/${2:?missing destination}"
|
2021-08-01 10:29:38 -07:00
|
|
|
curl -n -X COPY -H "Destination: $dst" "$src"
|
|
|
|
return;;
|
|
|
|
|
|
|
|
delete)
|
2021-10-01 04:13:49 -07:00
|
|
|
local trg="$EA_DOMAIN/$EA_AUTH/${1:?missing target}"
|
2021-08-01 10:29:38 -07:00
|
|
|
curl -f -n -X DELETE "$trg"
|
|
|
|
return;;
|
|
|
|
|
|
|
|
*)
|
2024-02-23 22:32:25 -08:00
|
|
|
printf 'unknown subcommand: %s\n' "$cmd" >&2
|
2021-08-01 10:29:38 -07:00
|
|
|
return 2;;
|
|
|
|
esac
|
2017-03-02 23:24:01 -08:00
|
|
|
}
|
|
|
|
|
2021-08-02 13:48:46 -07:00
|
|
|
[ -n "${preload+-}" ] || ea "$@"
|