Compare commits
2 commits
ad6c9379f0
...
83f2a98d79
Author | SHA1 | Date | |
---|---|---|---|
83f2a98d79 | |||
f5ab659721 |
1 changed files with 49 additions and 13 deletions
62
bambu.sh
62
bambu.sh
|
@ -86,9 +86,51 @@ function bambu_status() {
|
||||||
mqtt_command '{"pushing": { "sequence_id": 1, "command": "pushall"}, "user_id":"1234567890"}'
|
mqtt_command '{"pushing": { "sequence_id": 1, "command": "pushall"}, "user_id":"1234567890"}'
|
||||||
}
|
}
|
||||||
|
|
||||||
function bambu_lsdir() {
|
function bambu_file() {
|
||||||
local directory="$(preprocess_directory_path "$1")"
|
local subcommand="$1"
|
||||||
curl_ftps_command "$directory"
|
shift
|
||||||
|
|
||||||
|
case "$subcommand" in
|
||||||
|
ls)
|
||||||
|
bambu_ls "$@"
|
||||||
|
;;
|
||||||
|
upload)
|
||||||
|
bambu_upload "$@"
|
||||||
|
;;
|
||||||
|
rm)
|
||||||
|
bambu_rm "$@"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
die "Unknown subcommand $subcommand"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
function bambu_ls() {
|
||||||
|
local is_file="false"
|
||||||
|
local path=""
|
||||||
|
|
||||||
|
while [ ! -z "$1" ]; do
|
||||||
|
case "$1" in
|
||||||
|
-f|--file)
|
||||||
|
is_file="true"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
path="$1"
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$is_file" == "true" ]; then
|
||||||
|
path="$(preprocess_file_path "$path")"
|
||||||
|
curl_ftps_command "$(preprocess_directory_path "$(dirname "$path")")" -s | grep "$(basename "$path")"
|
||||||
|
else
|
||||||
|
path="$(preprocess_directory_path "$path")"
|
||||||
|
curl_ftps_command "$(preprocess_directory_path "$path")"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function bambu_upload() {
|
function bambu_upload() {
|
||||||
|
@ -96,9 +138,9 @@ function bambu_upload() {
|
||||||
curl_ftps_command "$directory" -T "$1"
|
curl_ftps_command "$directory" -T "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
function bambu_rmfile() {
|
function bambu_rm() {
|
||||||
local file="$(preprocess_file_path "$1")"
|
local file="$(preprocess_file_path "$1")"
|
||||||
curl_ftps_command "$file" -Q "DELE /$file"
|
curl_ftps_command "" -Q "DELE /$file" > /dev/null 2>&1 || echo "Failed to delete file $file"
|
||||||
}
|
}
|
||||||
|
|
||||||
function bambu_print() {
|
function bambu_print() {
|
||||||
|
@ -225,14 +267,8 @@ case "$command" in
|
||||||
status)
|
status)
|
||||||
bambu_status "$@"
|
bambu_status "$@"
|
||||||
;;
|
;;
|
||||||
lsdir)
|
file)
|
||||||
bambu_lsdir "$@"
|
bambu_file "$@"
|
||||||
;;
|
|
||||||
upload)
|
|
||||||
bambu_upload "$@"
|
|
||||||
;;
|
|
||||||
rmfile)
|
|
||||||
bambu_rmfile "$@"
|
|
||||||
;;
|
;;
|
||||||
print)
|
print)
|
||||||
bambu_print "$@"
|
bambu_print "$@"
|
||||||
|
|
Loading…
Add table
Reference in a new issue