Merge pull request #13 from th33xitus/work-13092020

Work 13092020
This commit is contained in:
th33xitus
2020-09-13 12:25:14 +02:00
committed by GitHub
7 changed files with 101 additions and 59 deletions

View File

@@ -18,7 +18,7 @@ Feel free to give it a try if you want. If you have suggestions or encounter any
## Instructions: ## Instructions:
For downloading this script it is best to have git installed on your machine or Raspberry Pi. For downloading this script it is best to have git already installed.
If you haven't, please run `sudo apt-get install git -y` to install git first. You will need it anyways! If you haven't, please run `sudo apt-get install git -y` to install git first. You will need it anyways!
After git is installed, use the following commands in the given order to download and execute the script. After git is installed, use the following commands in the given order to download and execute the script.
@@ -31,6 +31,30 @@ chmod +x kiauh.sh scripts/*
./kiauh.sh ./kiauh.sh
``` ```
---
## Functions and Features:
### Core Functions:
- **Installing** of the Klipper Firmware to your Raspberry Pi or other Linux Distribution which makes use of init.d.
- **Installing** of several different web interfaces such as Duet Web Control, Mainsail or OctoPrint including their dependencies.
- **Installing** of the Moonraker API
- **Updating** of all the listed installations above excluding OctoPrint. For updating OctoPrint, please use the OctoPrint interface!
- **Removing** of all the listed installations above.
- **Backup** of all the listed installations above.
What also is possible:
- Build the Klipper Firmware
- Flash the MCU
- Read ID of the currently connected printer (only one at the time)
- Write necessary entries to your printer.cfg, some of them customizable right in the CLI.
For a list of additional features and their descriptions please see:
[Feature List](https://github.com/th33xitus/kiauh/blob/work-13092020/docs/features.md)
---
## Notes: ## Notes:
- Tested only on Raspbian Buster Lite - Tested only on Raspbian Buster Lite
@@ -42,7 +66,7 @@ chmod +x kiauh.sh scripts/*
### For more information or instructions, please check out the appropriate repositories listed below: ### For more information or instructions, please check out the appropriate repositories listed below:
Klipper mainline by [KevinOConnor](https://github.com/KevinOConnor) : Klipper by [KevinOConnor](https://github.com/KevinOConnor) :
- https://github.com/KevinOConnor/klipper - https://github.com/KevinOConnor/klipper
@@ -51,9 +75,8 @@ Klipper S-Curve fork by [dmbutyugin](https://github.com/dmbutyugin) :
- https://github.com/dmbutyugin/klipper/tree/scurve-smoothing - https://github.com/dmbutyugin/klipper/tree/scurve-smoothing
- https://github.com/dmbutyugin/klipper/tree/scurve-shaping - https://github.com/dmbutyugin/klipper/tree/scurve-shaping
Moonraker and Klipper fork by [Arksine](https://github.com/Arksine) : Moonraker by [Arksine](https://github.com/Arksine) :
- https://github.com/Arksine/klipper/tree/dev-moonraker-testing
- https://github.com/Arksine/moonraker - https://github.com/Arksine/moonraker
Mainsail Webinterface by [meteyou](https://github.com/meteyou) : Mainsail Webinterface by [meteyou](https://github.com/meteyou) :
@@ -75,60 +98,8 @@ OctoPrint Webinterface by [OctoPrint](https://github.com/OctoPrint) :
--- ---
## Functions and Features:
### Core Functions:
- **Install:** Klipper Firmware, dwc2-for-klipper-socket + Duet Web Control, Moonraker + Mainsail, OctoPrint
- **Update:** Klipper Firmware, dwc2-for-klipper-socket + Duet Web Control, Moonraker + Mainsail
- **Backup:** Klipper Firmware, dwc2-for-klipper-socket + Duet Web Control, Moonraker + Mainsail, OctoPrint
- **Remove:** Klipper Firmware, dwc2-for-klipper-socket + Duet Web Control, Moonraker + Mainsail, OctoPrint
- Build Klipper Firmware
- Flash MCU
- Read ID of the currently connected printer (only one at the time)
- Write several entries to your printer.cfg, some of them customizable right in the console
- Before writing to an existing printer.cfg the script will create a backup! (better safe than sorry!)
### Features:
- Automatic dependency check:
- If packages are missing on your machine but needed for the asked task, the script will automatically install them
- Switch between Klipper Forks:
- [origin/master](https://github.com/KevinOConnor/klipper/tree/master), [scurve-shaping](https://github.com/dmbutyugin/klipper/tree/scurve-shaping), [scurve-smoothing](https://github.com/dmbutyugin/klipper/tree/scurve-smoothing), [moonraker](https://github.com/Arksine/klipper/tree/dev-moonraker-testing)
- The update function of the script will always update the currently selected/active fork!
- Toggle auto-create backups before updating:
- When enabled, a backup of the installation you want to update is made prior updating
- Preconfigure OctoPrint:
- When installing OctoPrint, a config is created which preconfigures your installation to be used with Klipper
- adding the restart/shutdown commands for OctoPrint
- adding the serial port `/tmp/printer`
- set the behavior to "Cancel any ongoing prints but stay connected to the printer"
- Enable/Disable OctoPrint Service:
- Usefull when using DWC2/Mainsail and OctoPrint at the same time to prevent them interfering with each other
- Set up reverse proxy for DWC2, Mainsail and OctoPrint and changing the hostname:
- The script can install and configure Nginx for the selected webinterface. This will allow you to make your webinterface reachable over an URL like `<hostname>.local`
- Example: If you name the host "mainsail" and set up a reverse proxy, type `mainsail.local` in your webbrowser to open the Mainsail webinterface
to be continued...
## What this script can't do:
- Updating OctoPrint -> Use OctoPrint for updating!
- Setting up webcam related stuff:
- If you want to use a webcam you have to install the dependencies and configurations yourself. I can't test this stuff sufficient enough due to me not having/using a webcam and therefore it's just too much work for me to set up an installation script which works, at best, with the first try.
There are install instructions (at least in case of OctoPrint) available:
[Setting up OctoPrint on a Raspberry Pi running Raspbian](https://community.octoprint.org/t/setting-up-octoprint-on-a-raspberry-pi-running-raspbian/2337)
(look for "Optional: Webcam")
## Q&A ## Q&A
**_Q: Can i install octoprint with this script?_**
**A:** ~~Soon™~~ Yes :)
**_Q: Can i use this script to install multiple instancec of Klipper on the same Pi? (Multisession?)_** **_Q: Can i use this script to install multiple instancec of Klipper on the same Pi? (Multisession?)_**
**A:** No, and at the moment i don't plan to implement this function. For multisession installations take a look at this script manu7irl created: https://github.com/manu7irl/klipper-DWC2-installer . Keep in mind that klipper-DWC2-installer and KIAUH are **NOT** compatible with each other. **A:** No, and at the moment i don't plan to implement this function. For multisession installations take a look at this script manu7irl created: https://github.com/manu7irl/klipper-DWC2-installer . Keep in mind that klipper-DWC2-installer and KIAUH are **NOT** compatible with each other.

0
docs/changelog.md Normal file
View File

25
docs/features.md Normal file
View File

@@ -0,0 +1,25 @@
# Feature List:
- Automatic dependency check:
- If packages are missing but needed for the asked task, the script will automatically install them
- Switch between Klipper Forks:
- [origin/master](https://github.com/KevinOConnor/klipper/tree/master) or [scurve-shaping](https://github.com/dmbutyugin/klipper/tree/scurve-shaping) or [scurve-smoothing](https://github.com/dmbutyugin/klipper/tree/scurve-smoothing) or [moonraker](https://github.com/Arksine/klipper/tree/dev-moonraker-testing)
- The update function of the script will always update the currently selected/active fork!
- Toggle auto-create backups before updating:
- When enabled, a backup of the installation you want to update is made prior updating
- Preconfigure OctoPrint:
- When installing OctoPrint, a config is created which preconfigures your installation to be used with Klipper
- adding the restart/shutdown commands for OctoPrint
- adding the serial port `/tmp/printer`
- set the behavior to "Cancel any ongoing prints but stay connected to the printer"
- Enable/Disable OctoPrint Service:
- Usefull when using DWC2/Mainsail and OctoPrint at the same time to prevent them interfering with each other
- Set up reverse proxy for DWC2, Mainsail and OctoPrint and changing the hostname:
- The script can install and configure Nginx for the selected webinterface. This will allow you to make your webinterface reachable over an URL like `<hostname>.local`
- Example: If you name the host "mainsail" and set up a reverse proxy, type `mainsail.local` in your webbrowser to open the Mainsail webinterface
- Installing the Shell Command extension. Please see: [Shell Command Extension](https://github.com/th33xitus/kiauh/blob/work-13092020/docs/shell_command.md)
to be continued...

View File

@@ -62,7 +62,7 @@ WantedBy=multi-user.target
Type=simple Type=simple
User=$DWC_USER User=$DWC_USER
RemainAfterExit=yes RemainAfterExit=yes
ExecStart=${PYTHONDIR}/bin/python3 ${SRCDIR}/dwc2-for-klipper-socket/web_dwc2.py ExecStart=${PYTHONDIR}/bin/python3 ${SRCDIR}/web_dwc2.py
Restart=always Restart=always
RestartSec=10 RestartSec=10
EOF EOF

View File

@@ -37,6 +37,38 @@ system_check_dwc2(){
} }
get_user_selections_dwc2(){ get_user_selections_dwc2(){
#let user choose to install systemd or init.d service
unset INST_SYSTEMD
unset INST_INITD
while true; do
echo
top_border
echo -e "| Do you want to install dwc2-for-klipper-socket as |"
echo -e "| 1) Init.d Service |"
echo -e "| 2) Systemd Service |"
hr
echo -e "| Please use the appropriate option for your chosen |"
echo -e "| Linux distribution. If you are unsure what to select, |"
echo -e "| please do a research before. |"
hr
echo -e "| If you are using Raspberry Pi OS, either option 1 or |"
echo -e "| 2 will work. |"
bottom_border
read -p "${cyan}###### Please choose:${default} " action
case "$action" in
1)
INST_INITD="true"
INST_SYSTEMD="false"
break;;
2)
INST_INITD="false"
INST_SYSTEMD="true"
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
#user selection for printer.cfg #user selection for printer.cfg
if [ "$PRINTER_CFG_FOUND" = "false" ]; then if [ "$PRINTER_CFG_FOUND" = "false" ]; then
unset SEL_DEF_CFG unset SEL_DEF_CFG
@@ -127,7 +159,11 @@ dwc2_setup(){
cp -r ${SRCDIR}/kiauh/scripts/dwc2-for-klipper-socket-installer $DWC2FK_DIR/scripts cp -r ${SRCDIR}/kiauh/scripts/dwc2-for-klipper-socket-installer $DWC2FK_DIR/scripts
ok_msg "Done!" ok_msg "Done!"
status_msg "Starting service-installer ..." status_msg "Starting service-installer ..."
if [ "$INST_INITD" = "true" ] && [ "$INST_SYSTEMD" = "false" ]; then
$DWC2FK_DIR/scripts/install-octopi.sh $DWC2FK_DIR/scripts/install-octopi.sh
elif [ "$INST_INITD" = "false" ] && [ "$INST_SYSTEMD" = "true" ]; then
$DWC2FK_DIR/scripts/install-debian.sh
fi
ok_msg "Service installed!" ok_msg "Service installed!"
#patch /etc/default/klipper to append the uds argument #patch /etc/default/klipper to append the uds argument
patch_klipper_sysfile_dwc2 patch_klipper_sysfile_dwc2

View File

@@ -34,6 +34,7 @@ remove_dwc2(){
data_arr=( data_arr=(
/etc/init.d/dwc /etc/init.d/dwc
/etc/default/dwc /etc/default/dwc
/etc/systemd/system/dwc.service
$DWC2FK_DIR $DWC2FK_DIR
$DWC_ENV_DIR $DWC_ENV_DIR
$DWC2_DIR $DWC2_DIR
@@ -42,15 +43,24 @@ remove_dwc2(){
if [ "$ERROR_MSG" = "" ]; then if [ "$ERROR_MSG" = "" ]; then
if systemctl is-active dwc -q; then if systemctl is-active dwc -q; then
status_msg "Stopping DWC2-for-Klipper-Socket Service ..." status_msg "Stopping DWC2-for-Klipper-Socket Service ..."
sudo /etc/init.d/dwc stop && sudo systemctl disable dwc sudo systemctl stop dwc && sudo systemctl disable dwc
ok_msg "Service stopped!" ok_msg "Service stopped!"
fi fi
#remove if init.d service
if [[ -e /etc/init.d/dwc || -e /etc/default/dwc ]]; then if [[ -e /etc/init.d/dwc || -e /etc/default/dwc ]]; then
status_msg "Init.d Service found ..."
status_msg "Removing DWC2-for-Klipper-Socket Service ..." status_msg "Removing DWC2-for-Klipper-Socket Service ..."
sudo rm -rf /etc/init.d/dwc /etc/default/dwc sudo rm -rf /etc/init.d/dwc /etc/default/dwc
sudo update-rc.d -f dwc remove sudo update-rc.d -f dwc remove
ok_msg "DWC2-for-Klipper-Socket Service removed!" ok_msg "DWC2-for-Klipper-Socket Service removed!"
fi fi
#remove if systemd service
if [ -e /etc/systemd/system/dwc.service ]; then
status_msg "Systemd Service found ..."
status_msg "Removing DWC2-for-Klipper-Socket Service ..."
sudo rm -rf /etc/systemd/system/dwc.service
ok_msg "DWC2-for-Klipper-Socket Service removed!"
fi
if [ -d $DWC2FK_DIR ]; then if [ -d $DWC2FK_DIR ]; then
status_msg "Removing DWC2-for-Klipper-Socket directory ..." status_msg "Removing DWC2-for-Klipper-Socket directory ..."
rm -rf $DWC2FK_DIR && ok_msg "Directory removed!" rm -rf $DWC2FK_DIR && ok_msg "Directory removed!"