2022-03-19 06:27:22 +01:00
|
|
|
#!/usr/bin/env zsh
|
|
|
|
# Put files on a webspace via sftp
|
|
|
|
|
2022-04-03 05:47:50 +02:00
|
|
|
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
|
|
|
|
|
2022-04-10 03:39:55 +02:00
|
|
|
zmodload zsh/zutil
|
|
|
|
local -a o_dir=(-d "")
|
|
|
|
local -a o_help=()
|
|
|
|
zparseopts -D -K -- d:=o_dir h=o_help
|
|
|
|
if [[ ${#o_help} -ne 0 || ! -v 1 ]]; then
|
|
|
|
ret=$(( ${#o_help} ^ 1 ))
|
|
|
|
print -u $(( 1 + ${ret} )) "usage: ${0} [-h] [-d REMOTE SUBDIR] <FILE> …"
|
|
|
|
return ${ret}
|
|
|
|
fi
|
|
|
|
local dir=""
|
|
|
|
[[ -n ${o_dir[2]} ]] && dir=${o_dir[2]}/
|
2022-03-19 06:27:22 +01:00
|
|
|
|
|
|
|
local -a putcmds
|
|
|
|
for file in "${@}"; do
|
|
|
|
putcmds+="put ${file}"
|
|
|
|
done
|
|
|
|
|
|
|
|
sftp tastytea.de <<EOF
|
2022-04-10 03:39:55 +02:00
|
|
|
cd /var/www/tastytea.de/files/${dir}
|
2022-03-19 06:27:22 +01:00
|
|
|
$(print -l ${putcmds})
|
|
|
|
EOF
|
|
|
|
|
|
|
|
for file in "${@}"; do
|
2022-04-10 03:39:55 +02:00
|
|
|
print '\e[1;95m→\e[0m' https://tastytea.de/files/${dir}"${file##*/}"
|
2022-03-19 06:27:22 +01:00
|
|
|
done
|