-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ballaswag
committed
Dec 11, 2023
1 parent
62a064c
commit 965c1cf
Showing
3 changed files
with
171 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github: ballaswag | ||
ko_fi: ballaswag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
#!/bin/sh | ||
|
||
yellow=`echo "\033[01;33m"` | ||
green=`echo "\033[01;32m"` | ||
red=`echo "\033[01;31m"` | ||
white=`echo "\033[m"` | ||
|
||
K1_CONFIG_DIR=/usr/data/printer_data/config | ||
BACKUP_DIR=/usr/data/guppyify-backup | ||
K1_GUPPY_DIR=/usr/data/guppyscreen | ||
FT2FONT_PATH=/usr/lib/python3.8/site-packages/matplotlib/ft2font.cpython-38-mipsel-linux-gnu.so | ||
KLIPPY_EXTRA_DIR=/usr/share/klipper/klippy/extras | ||
GCODE_SHELL_CMD=$KLIPPY_EXTRA_DIR/gcode_shell_command.py | ||
SHAPER_CONFIG=$KLIPPY_EXTRA_DIR/calibrate_shaper_config.py | ||
|
||
printf "${green}=== Installing Guppy Screen === ${white}\n" | ||
|
||
# check ld.so version | ||
if [ ! -f /lib/ld-2.29.so ]; then | ||
printf "${red}ld.so is not the expected version. Make sure you're running 1.3.x.y firmware versions ${white}\n" | ||
exit 1 | ||
fi | ||
|
||
echo "Checking for a working Moonraker" | ||
MRK_KPY_OK=`curl localhost:7125/server/info | jq .result.klippy_connected` | ||
if [ "$MRK_KPY_OK" != "true" ]; then | ||
printf "${yellow}Moonraker is not properly setup at port 7125. Continue anyways? (y/n) ${white}\n" | ||
read confirm | ||
echo | ||
|
||
if [ "$confirm" = "y" -o "$confirm" = "Y" ]; then | ||
echo "Continuing to install GuppyScreen" | ||
else | ||
echo "Please fix Moonraker and restart this script." | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# download/extract latest guppyscreen | ||
if [ x"$1" == x"zbolt" ]; then | ||
wget -q --no-check-certificate https://github.com/ballaswag/guppyscreen/releases/latest/download/guppyscreen-zbolt.tar.gz -O /tmp/guppyscreen.tar.gz | ||
else | ||
wget -q --no-check-certificate https://github.com/ballaswag/guppyscreen/releases/latest/download/guppyscreen.tar.gz -O /tmp/guppyscreen.tar.gz | ||
fi | ||
tar xf /tmp/guppyscreen.tar.gz -C /usr/data/ | ||
|
||
if [ ! -d "$K1_GUPPY_DIR" ]; then | ||
printf "${red}Did not find guppyscreen in $K1_GUPPY_DIR. GuppyScreen must be extracted in $K1_GUPPY_DIR ${white}\n" | ||
exit 1 | ||
fi | ||
|
||
|
||
if [ ! -d "$BACKUP_DIR" ]; then | ||
printf "${green} Backing up original K1 files ${white}\n" | ||
mkdir -p $BACKUP_DIR | ||
|
||
mv /etc/init.d/S12boot_display $BACKUP_DIR | ||
cp /etc/init.d/S50dropbear $BACKUP_DIR | ||
cp /etc/init.d/S99start_app $BACKUP_DIR | ||
fi | ||
|
||
if [ ! -f $BACKUP_DIR/ft2font.cpython-38-mipsel-linux-gnu.so ]; then | ||
# backup ft2font | ||
mv /usr/lib/python3.8/site-packages/matplotlib/ft2font.cpython-38-mipsel-linux-gnu.so $BACKUP_DIR | ||
fi | ||
|
||
printf "${white}=== Do you want to disable all Creality services (revertable) with GuppyScreen installation? ===\n" | ||
printf "${green} Pros: Frees up system resources on your K1 for critical services such as Klipper (Recommended)\n" | ||
printf "${white} Cons: Disabling all Creality services breaks Creality Cloud/Creality Slider.\n\n" | ||
printf "Disable all Creality Services? (y/n)" | ||
|
||
read confirm_decreality | ||
echo | ||
|
||
if [ "$confirm_decreality" = "y" -o "$confirm_decreality" = "Y" ]; then | ||
printf "${green}Disabling Creality services ${white}\n" | ||
rm /etc/init.d/S99start_app | ||
else | ||
# disables only display-server and Monitor | ||
cp $K1_GUPPY_DIR/k1_mods/S99start_app /etc/init.d/S99start_app | ||
fi | ||
|
||
printf "${green}Setting up GuppyScreen ${white}\n" | ||
cp $K1_GUPPY_DIR/k1_mods/S50dropbear /etc/init.d/S50dropbear | ||
cp $K1_GUPPY_DIR/k1_mods/S99guppyscreen /etc/init.d/S99guppyscreen | ||
|
||
cp $K1_GUPPY_DIR/k1_mods/calibrate_shaper_config.py $SHAPER_CONFIG | ||
|
||
if [ ! -d "/usr/lib/python3.8/site-packages/matplotlib-2.2.3-py3.8.egg-info" ]; then | ||
echo "Not replacing mathplotlib ft2font module. PSD graphs might not work" | ||
else | ||
printf "${green}Replacing mathplotlib ft2font module for plotting PSD graphs ${white}\n" | ||
cp $K1_GUPPY_DIR/k1_mods/ft2font.cpython-38-mipsel-linux-gnu.so $FT2FONT_PATH | ||
fi | ||
|
||
if [ ! -f $GCODE_SHELL_CMD ]; then | ||
printf "${green}Installing gcode_shell_command.py for klippy ${white}\n" | ||
cp $K1_GUPPY_DIR/k1_mods/gcode_shell_command.py $GCODE_SHELL_CMD | ||
fi | ||
|
||
mkdir -p $K1_CONFIG_DIR/GuppyScreen/scripts | ||
cp $K1_GUPPY_DIR/scripts/*.cfg $K1_CONFIG_DIR/GuppyScreen | ||
cp $K1_GUPPY_DIR/scripts/*.py $K1_CONFIG_DIR/GuppyScreen/scripts | ||
|
||
## includ guppyscreen *.cfg in printer.cfg | ||
if grep -q "include GuppyScreen" $K1_CONFIG_DIR/printer.cfg ; then | ||
echo "printer.cfg already includes GuppyScreen cfgs" | ||
else | ||
printf "${green}Including guppyscreen cfgs in printer.cfg ${white}\n" | ||
sed -i '/\[include gcode_macro\.cfg\]/a \[include GuppyScreen/*\.cfg\]' $K1_CONFIG_DIR/printer.cfg | ||
fi | ||
|
||
sync | ||
|
||
if [ ! -f $K1_GUPPY_DIR/guppyscreen ]; then | ||
printf "${red}Installation failed, did not find guppyscreen in $K1_GUPPY_DIR. Make sure to extract the guppyscreen directory in /usr/data. ${white}\n" | ||
exit 1 | ||
fi | ||
|
||
## double check dropbear is the correct one | ||
if ! diff $K1_GUPPY_DIR/k1_mods/S50dropbear /etc/init.d/S50dropbear > /dev/null ; then | ||
printf "${red}Dropbear (SSHD) didn't install properly. ${white}\n" | ||
exit 1 | ||
fi | ||
|
||
## request to reboot | ||
printf "Restart Klipper now to pick up the new changes (y/n): " | ||
read confirm | ||
echo | ||
|
||
if [ "$confirm" = "y" -o "$confirm" = "Y" ]; then | ||
echo "Restarting Klipper" | ||
/etc/init.d/S55klipper_service restart | ||
else | ||
printf "${red}Some GuppyScreen functionaly won't work until Klipper is restarted. ${white}\n" | ||
fi | ||
|
||
killall Monitor | ||
killall display-server | ||
if [ "$confirm_decreality" = "y" -o "$confirm_decreality" = "Y" ]; then | ||
echo "Killing Creality services" | ||
killall master-server | ||
killall audio-server | ||
killall wifi-server | ||
killall app-server | ||
killall upgrade-server | ||
killall web-server | ||
fi | ||
|
||
printf "${green}Starting GuppyScreen ${white}\n" | ||
/etc/init.d/S99guppyscreen restart |