X-Git-Url: https://git.jacobcasper.com/?p=mercuryms.git;a=blobdiff_plain;f=listener.sh;fp=listener.sh;h=040118a78dda4fdf4fe7cb335b72cd8129c8fbba;hp=182842e619267b32ed483331a0159bad20f87b16;hb=58c787a47ddfcd526efed27ec54230154d7b7640;hpb=7576a45852d74d69aeb36c06e6896b223c7fb61c diff --git a/listener.sh b/listener.sh index 182842e..040118a 100755 --- a/listener.sh +++ b/listener.sh @@ -8,12 +8,19 @@ while IFS='|' read -a DATA DATA_STR; do # WebDAV responds to a PROPFIND with a 207 if a resource exists. # It responds 404 otherwise, but we will attempt to create on any other code. # AWK exits with inverted exit codes to use the && bash short circuit. - curl --silent --include --user $USER:$($PW_COMMAND) "$HOST/remote.php/dav/files/$USER/${DATA[1]}" -X PROPFIND --data ' + curl --silent \ + --include \ + --user $USER:$($PW_COMMAND) \ + "$HOST/remote.php/dav/files/$USER/${DATA[1]}" \ + -X PROPFIND \ + --data ' - + - ' | awk '/HTTP\// {if ($2 == "207") { exit 1; } else { exit 0; } }' && curl --silent \ + ' \ + | awk '/HTTP\// {if ($2 == "207") { exit 1; } else { exit 0; }}' \ + && curl --silent \ --user $USER:$($PW_COMMAND) \ -X MKCOL "$HOST/remote.php/dav/files/$USER/${DATA[1]}" # Download the media we were sent from the URI.