Hey 🙂
I've set up Klipper on my printer using a.vas as my Linux username. So my home directory is /home/a.vas, and my printer_data is located in /home/a.vas/printer_data. When I try to install Happy-Hare on that machine, install.sh -i just crashes while attempting to back up my existing configuration:
a.vas@voron24:~/Happy-Hare $ ./install.sh -i
...
Reading default configuration parameters...
Copying original printer.cfg file to /home/a-20240617_232602.vas/printer_data/config/printer.cfg-old
cp: cannot create regular file '/home/a-20240617_232602.vas/printer_data/config/printer.cfg-old': No such file or directory
a.vas@voron24:~/Happy-Hare $ pwd
/home/a.vas/Happy-Hare
It probably fails because nextfilename calculates wrong filepath, and it probably does so because it doesn't seem to play well with paths that have more than one dot (i.e. they have another dot before the last one in printer.cfg).
I managed to work around this issue like this:
function nextfilename {
local name="$1"
if [ -d "${name}" ]; then
- printf "%s-%s" ${name%%.*} $(date '+%Y%m%d_%H%M%S')
+ printf "%s-%s" ${name} $(date '+%Y%m%d_%H%M%S')
else
- printf "%s-%s.%s-old" ${name%%.*} $(date '+%Y%m%d_%H%M%S') ${name#*.}
+ printf "%s-%s.%s-old" ${name%.*} $(date '+%Y%m%d_%H%M%S') ${name##*.}
fi
}
This changes its behavior, so that:
If ${name} is a file, then nextfilename inserts current date before the last dot instead of the first;
And if ${name} is a directory, then nextfilename completely ignores dots in the path and just suffixes it with current date (this prevents the script from failing while backing up the .../printer_data/config/mmu directory).
This worked for me, but I'm not sure if this won't break any other cases.
Hey 🙂 I've set up Klipper on my printer using
a.vas
as my Linux username. So my home directory is/home/a.vas
, and my printer_data is located in/home/a.vas/printer_data
. When I try to install Happy-Hare on that machine,install.sh -i
just crashes while attempting to back up my existing configuration:It probably fails because
nextfilename
calculates wrong filepath, and it probably does so because it doesn't seem to play well with paths that have more than one dot (i.e. they have another dot before the last one inprinter.cfg
).I managed to work around this issue like this:
This changes its behavior, so that:
${name}
is a file, thennextfilename
inserts current date before the last dot instead of the first;${name}
is a directory, thennextfilename
completely ignores dots in the path and just suffixes it with current date (this prevents the script from failing while backing up the.../printer_data/config/mmu
directory).This worked for me, but I'm not sure if this won't break any other cases.