51 lines
1.6 KiB
Bash
Executable File
51 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# nextcloud url, username, password and local dir.
|
|
. $HOME/.config/nextcloud/nextcloud_data
|
|
|
|
help() {
|
|
cat<<EOF
|
|
syntax: --------------------------------------------------------------------------
|
|
nextcurl.sh <flag> <path_to_remote_file/folder> <name_of_the_download/upload_file>
|
|
--------------------------------------------------------------------------
|
|
options:
|
|
-u updoad file.
|
|
-d download file.
|
|
-c create folder.
|
|
-r delete folder.
|
|
-l list files in folder.
|
|
-L list folders.
|
|
-h print help.
|
|
-----------------------------------------------
|
|
EOF
|
|
}
|
|
|
|
echo "________________________________________________________________________________"
|
|
|
|
case $1 in
|
|
-d)
|
|
curl -X GET -u $USER:$PASS $URL/remote.php/dav/files/$USER/$2 --output $3
|
|
;;
|
|
-u)
|
|
curl -X PUT -u $USER:$PASS $URL/remote.php/dav/files/$USER/$2 -T $3
|
|
;;
|
|
-c)
|
|
curl -X MKCOL -u $USER:$PASS $URL/remote.php/dav/files/$USER/$2
|
|
;;
|
|
-r)
|
|
curl -X DELETE -u $USER:$PASS $URL/remote.php/dav/files/$USER/$2
|
|
;;
|
|
-l)
|
|
curl -X PROPFIND -u $USER:$PASS $URL/remote.php/dav/files/$USER/$2 | sed 's/<\//\n/g' | grep $USER | sed "s/${USER}/ /g" | cut -d ' ' -f 2
|
|
;;
|
|
-L)
|
|
curl -X PROPFIND -u $USER:$PASS $URL/remote.php/dav/files/$USER | sed 's/<\//\n/g' | grep $USER | sed "s/${USER}/ /g" | cut -d ' ' -f 2
|
|
;;
|
|
-m)
|
|
for f in $(curl -X PROPFIND -u $USER:$PASS $URL/remote.php/dav/files/$USER/$2 | sed 's/<\//\n/g' | grep $USER | sed "s/${USER}/ /g" | cut -d ' ' -f 2); do curl -X GET -u $USER:$PASS $URL/remote.php/dav/files/$USER/$f --output $(basename $f); done
|
|
;;
|
|
-h)
|
|
help
|
|
;;
|
|
esac
|