Update 2024-12-23 18:34 OpenBSD/amd64-t14
This commit is contained in:
parent
1bb57985ca
commit
ec7fbad49f
19
.bin/upload
19
.bin/upload
@ -1,7 +1,12 @@
|
||||
#!/bin/sh -e
|
||||
|
||||
# manage files in a webroot
|
||||
# needs: sh (cp,rm), openssh (ssh,scp), gzip, tar, sed, tail, xclip
|
||||
# needs:
|
||||
# - sh: cp, rm, mv, echo, basename, dirname
|
||||
# - openssh: ssh, scp
|
||||
# - coreutils: chmod, sed, tail
|
||||
# - archivers: gzip, tar
|
||||
# - xclip
|
||||
|
||||
###
|
||||
### CONFIGURATION
|
||||
@ -110,6 +115,7 @@ then
|
||||
ssh $_sshhost \
|
||||
"cd $_rpath/ \
|
||||
&& mv -v \"$1\" \"$2\""
|
||||
echo "$2" | remote_list_print
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@ -119,7 +125,8 @@ then
|
||||
lastfile="$(remote_list | tail -1)"
|
||||
ssh $_sshhost \
|
||||
"cd $_rpath/ \
|
||||
&& mv -v \"$lastfile\" \"$2\""
|
||||
&& mv -v \"$lastfile\" \"$1\""
|
||||
echo "$1" | remote_list_print
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@ -176,11 +183,11 @@ then
|
||||
# target filename
|
||||
file="$(basename "$item")$_ext"
|
||||
|
||||
# CASE "file" "no archive"
|
||||
# CASE "file" "no archive mode"
|
||||
if [ -f "$item" ] && [ -z "$_tgz" ] && [ -z "$_gz" ]
|
||||
then
|
||||
echo "Uploading $item as $file"
|
||||
scp -q "$item" "$_sshhost:\"$_rpath/$file\""
|
||||
scp -q "$item" $_sshhost:"$_rpath/$file"
|
||||
copy_and_print "$file"
|
||||
return
|
||||
fi
|
||||
@ -196,7 +203,7 @@ then
|
||||
# moving closer to the item to not archive the whole path
|
||||
cd $(dirname "$item")
|
||||
tar czf - "$(basename "$item")" \
|
||||
| ssh $_sshhost "pv - > \"$_rpath/$file\""
|
||||
| ssh $_sshhost "cat - > \"$_rpath/$file\""
|
||||
copy_and_print "$file"
|
||||
return
|
||||
fi
|
||||
@ -207,7 +214,7 @@ then
|
||||
file="$file.gz"
|
||||
echo "Uploading \"$item\" as \"$file\""
|
||||
cat "$item" | gzip \
|
||||
| ssh $_sshhost "pv - > \"$_rpath/$file\""
|
||||
| ssh $_sshhost "cat - > \"$_rpath/$file\""
|
||||
copy_and_print "$file"
|
||||
return
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user