115 lines
3.5 KiB
Bash
115 lines
3.5 KiB
Bash
#!/usr/bin/env bash
|
|
mainmenu() {
|
|
cd ~
|
|
OPTION=$(whiptail --title "Macros installer helper" --separate-output --checklist "Choose your option" 15 60 6 \
|
|
"1" "Macros" ON \
|
|
"2" "Klipper Backup" ON \
|
|
"3" "Shake and tune" ON \
|
|
"4" "Cartographer" OFF \
|
|
"5" "Motor Sync" OFF \
|
|
"6" "Chopper Tune" OFF 3>&1 1>&2 2>&3)
|
|
exitstatus=$?
|
|
|
|
if [ $exitstatus = 0 ]; then
|
|
for OPTION in $OPTION; do
|
|
case "$OPTION" in
|
|
"1")
|
|
echo "Macros was selected"
|
|
install_macros
|
|
;;
|
|
"2")
|
|
echo "Klipper Backup was selected"
|
|
install_backup
|
|
;;
|
|
"3")
|
|
echo "Shake and Tune was selected"
|
|
wget -O - https://raw.githubusercontent.com/Frix-x/klippain-shaketune/main/install.sh | bash
|
|
;;
|
|
"4")
|
|
echo "Option 3 was selected"
|
|
git clone https://github.com/Cartographer3D/cartographer-klipper.git
|
|
./cartographer-klipper/install.sh
|
|
;;
|
|
"5")
|
|
echo "Option 4 was selected"
|
|
git clone https://github.com/MRX8024/motors-sync
|
|
bash ~/motors-sync/install.sh
|
|
;;
|
|
"6")
|
|
echo "Option 4 was selected"
|
|
git clone https://github.com/MRX8024/chopper-resonance-tuner
|
|
bash ~/chopper-resonance-tuner/install.sh
|
|
;;
|
|
*)
|
|
echo "Unsupported item $OPTION!" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
else
|
|
echo "You chose Cancel."
|
|
fi
|
|
}
|
|
|
|
install_backup() {
|
|
NAME=$(whiptail --inputbox "Please enter printer name" 10 100 3>&1 1>&2 2>&3)
|
|
echo "name: $NAME"
|
|
TOKEN=$(whiptail --inputbox "Please enter printer token" 10 100 3>&1 1>&2 2>&3)
|
|
echo "TOKEN: $TOKEN"
|
|
curl -fsSL get.klipperbackup.xyz | bash
|
|
cat << EOF > ~/klipper-backup/.env #file.txt
|
|
github_token=$TOKEN
|
|
github_username=reijii
|
|
github_repository=Klipper-Backups
|
|
git_host="gitea.reijii.org"
|
|
git_protocol="https"
|
|
branch_name=$NAME
|
|
commit_username=""
|
|
commit_email="$NAME@vertorix"
|
|
backupPaths=( \\
|
|
"printer_data/config/*" \\
|
|
)
|
|
|
|
exclude=( \\
|
|
"*.swp" \\
|
|
"*.tmp" \\
|
|
"printer-[0-9]*_[0-9]*.cfg" \\
|
|
"*.bak" \\
|
|
"*.bkp" \\
|
|
"*.csv" \\
|
|
"*.zip" \\
|
|
"*.png" \\
|
|
"*.tar.gz" \\
|
|
)
|
|
EOF
|
|
rm /tmp/c1
|
|
crontab -l >/tmp/c1
|
|
echo $(($RANDOM % 60 ))' */12 * * * $HOME/klipper-backup/script.sh' >>/tmp/c1
|
|
crontab /tmp/c1
|
|
}
|
|
|
|
install_macros() {
|
|
git clone https://cloud.reijii.org/gitea/reijii/Macros
|
|
mkdir ~/printer_data/config/Macros
|
|
ln -s ~/Macros/Scripts ~/printer_data/config/Macros/Scripts
|
|
cp ~/Macros/Macros/* ~/printer_data/config/Macros/
|
|
|
|
if [[ -d $HOME/moonraker ]] && systemctl is-active moonraker >/dev/null 2>&1; then
|
|
if ! grep -Eq "^\[update_manager macros-repo\]\s*$" "$HOME/printer_data/config/moonraker.conf"; then
|
|
if [[ $(tail -c1 "$HOME/printer_data/config/moonraker.conf" | wc -l) -eq 0 ]]; then
|
|
echo "" >>"$HOME/printer_data/config/moonraker.conf"
|
|
fi
|
|
|
|
if /usr/bin/env bash -c "cat $HOME/Macros/moonraker_update.conf >> $HOME/printer_data/config/moonraker.conf"; then
|
|
sudo systemctl restart moonraker.service
|
|
fi
|
|
echo -e "Adding Macros to update manager Done!\n"
|
|
else
|
|
echo -e "Adding Macros to update manager skipped! (already added)\n"
|
|
fi
|
|
else
|
|
echo -e "Moonraker is not installed update manager configuration skipped!\n Please install moonraker then run the script again to update the moonraker configuration\n"
|
|
fi
|
|
}
|
|
|
|
mainmenu |