Staubgeborener / klipper-backup

Klipper backup script for manual or automated GitHub backups. Lightweight, pragmatic and comfortable.
https://klipperbackup.xyz
220 stars 46 forks source link

Update manual.md #87

Closed kvikindi closed 3 months ago

kvikindi commented 3 months ago

Added optional custom message in klipper macro, and show example.

Tylerjet commented 3 months ago

Was this tested locally on your environment as I don't see in the code how the shell command is receiving the Parameters/message.

kvikindi commented 3 months ago

I have indeed ran it in my environment (mainsail OS on raspberry pi zero 2 w).

The idea here is that the shell command only gets the parameters/message if the user types in MESSAGE="insert message here". Otherwise the macro reverts to its previous behaviour, which only starts the shell command (and thus the default commit message as well).

It may not be 100% elegant, but if you run e.g. UPDATE_GIT "something" or UPDATE_GIT PARAMS="something" in klipper, then all you're getting is Unknown command: "UPDATE_GIT" or the default commit message, respectively.

Tylerjet commented 3 months ago

Right but in the actual Bash command where are you passing the parameters to it?

When you look at your repository commits does it actually have the commit message you used with the macro?

kvikindi commented 3 months ago

It's getting quite late here, but yeah. It works. yup

Tylerjet commented 3 months ago

No Problem.

hrmm that is odd i do not see the same output on the latest commit of the repo and i just did a fresh install of it. did you make any local changes to script.sh by chance that were just not pushed to this patch? Or if you run the script manually in your environment does it prompt that an update is available.

image image

kvikindi commented 3 months ago

image I think this might be why? Try making a small change (line break at the end of a file etc.), and then run it.

Tylerjet commented 3 months ago

No its not that, its setup to still commit even with no changes unless you tell it not to in the .env, you can see the line just under it with a commit message that was pushed to the repo, also tried it with changes after a fresh install and it still did not push the message which to me seems like either the gcode shell command is not pushing the parameters over or script.sh is not able to parse it correctly.

image

That is why i am really confused that it works on your end as logically speaking it shouldn't, based on the code that we have in script.sh currently it shouldn't work without modification to the script or specific formatting of the gcode. How exactly are you formatting the message in the fluidd/mainsail console?

kvikindi commented 3 months ago

My bad.

I was using: command: bash /home/pi/klipper-backup/script.sh, where passing the parameters works, whereas with the command: bash -c "bash $HOME/klipper-backup/script.sh" it seems to not work.

Tylerjet commented 3 months ago

ahhh ok, yeah bash -c is put there because it then allows for $HOME to be used so the user doesn't have to place /home/{username} there. I think instead of taking out bash -c it should be possible to change how the data is passed.

I'll try a few things and may have some suggested changes

kvikindi commented 3 months ago

image Nice little bonus feature!

Tylerjet commented 3 months ago

Nice, one last little note is maybe trying to solve the default message as it seems to auto fill with part of the conditional statement? so it looks a bit odd

image

OOP and looks like we might actually need to have 2 gcode shell commands one for with the message and one without, as if you now do not place a message $0 resolves to the command that was executed so the message just becomes bash.

Tylerjet commented 3 months ago

Sweet! Has been merged!

kvikindi commented 3 months ago

Awesomeness! Weirdly enough, I didn't see the unintended default message like you did. Cheers for this lil' back and forth - I learned a great deal off ye 🤘

Tylerjet commented 3 months ago

Yeah its some specific weirdness and differences between fluidd and mainsail.