Merge branch 'master' into dev

This commit is contained in:
Evgenii Shavrin
2021-09-11 02:48:15 +03:00
committed by GitHub
28 changed files with 805 additions and 469 deletions

View File

@@ -31,18 +31,11 @@ git clone https://github.com/th33xitus/kiauh.git
./kiauh/kiauh.sh
```
## Additional Instructions:
If you need some more detailed instructions on how to install Klipper and Mainsail with KIAUH, check out this website:\
[Installing Klipper and Mainsail](https://3dp.tumbleweedlabs.com/firmware/klipper-firmware/installing-klipper-and-mainsail-on-your-raspberry-pi)\
Credits for these instructions go to [@tumbleweedlabs](https://github.com/tumbleweedlabs).\
Feel free to check out his work.
---
## **🧰 Functions and Features:**
- **New in v3.0** You can now install multiple instances (Klipper/Moonraker/DWC/Octoprint) on the same Pi!
- **New in v3.0.0:** You can now install multiple instances (Klipper/Moonraker/DWC/Octoprint) on the same Pi!
---
### **Core Functions:**
@@ -67,18 +60,15 @@ Feel free to check out his work.
## **📝 Notes:**
- Tested **only** on Raspberry Pi OS Lite (Debian Buster)
- ( Although similar Debian based distributions might also work... )
- Tested **only** on Raspberry Pi OS Lite (Debian 10 Buster)
- Other Debian based distributions can work
- Reported to work on Armbian too
- During the use of this script you might be asked for your sudo password. There are several functions involved which need sudo privileges.
---
## **🛈 Sources & Further Information**
If you need some more detailed instructions on how to install Klipper and Mainsail with KIAUH, check out this website:\
[Installing Klipper and Mainsail](https://3dp.tumbleweedlabs.com/firmware/klipper-firmware/installing-klipper-and-mainsail-on-your-raspberry-pi)\
Credits for these instructions go to [@tumbleweedlabs](https://github.com/tumbleweedlabs).
For more information or instructions to the various components KIAUH can install, please check out the corresponding repositories listed below:
---
@@ -139,6 +129,12 @@ https://github.com/OctoPrint/OctoPrint
---
### **🔬PrettyGCode for Klipper** by [Kragrathea](https://github.com/Kragrathea) :
https://github.com/Kragrathea/pgcode
---
## **❓ FAQ**
**_Q: Can i use this script to install multiple instances of Klipper on the same Pi? (Multisession?)_**

View File

@@ -2,6 +2,46 @@
This document covers possible important changes to KIAUH.
### 2021-08-10
* KIAUH now supports the installation of the "PrettyGCode for Klipper" GCode-Viewer created by [Kragrathea](https://github.com/Kragrathea)! Installation, updating and removal are possible with KIAUH. For more details to this cool piece of software, please have a look here: https://github.com/Kragrathea/pgcode
### 2021-07-10
* The NGINX configuration files got updated to be in sync with MainsailOS and FluiddPi. Issues with the NGINX service not starting up due to wrong configuration should be resolved now. To get the updated configuration files, please remove Moonraker and Mainsail / Fluidd with KIAUH first and then re-install it. An automated file check for those configuration files might follow in the future which then automates updating those files if there were important changes.
* The default `moonraker.conf` was updated to reflect the recent changes to the update manager section. The update channel is set to `dev`.
### 2021-06-29
* KIAUH will now patch the new `log_path` to existing moonraker.conf files when updating Moonraker and the entry is missing. Before that, it was necessary that the user provided that path manually to make Fluidd display the logfiles in its interface. This issue should be resolved now.
### 2021-06-15
* Moonraker introduced an optional `log_path` which clients can make use of to show log files located in that folder to their users. More info here: https://github.com/Arksine/moonraker/commit/829b3a4ee80579af35dd64a37ccc092a1f67682a \
Client developers agreed upon using `~/klipper_logs` as the new default log path.\
That means, from now on, Klipper and Moonraker services installed with KIAUH will place their logfiles in that mentioned folder.
* Additionally, KIAUH will now detect Klipper and Moonraker systemd services that still use the old default location of `/tmp/<service>.log` and will update them next time the user updates Klipper and/or Moonraker with the KIAUH update function.
* Additional symlinks for the following logfiles will get created along those update procedures to make them accessible through the webinterface once its supported:
- webcamd.log
- mainsail-access.log
- mainsail-error.log
- fluidd-access.log
- fluidd-error.log
* For MainsailOS and FluiddPi users:\
MainsailOS and FluiddPi will switch the shipped Klipper service from SysVinit to systemd probably with their next release. KIAUH can already help migrate older MainsailOS (0.4.0 and below) and FluiddPi (v1.13.0) releases to match their new service-, file- and folder-structure so you don't have to re-flash the SD-Card of your Raspberry Pi.\
In detail here is what is going to happen when you use the new "CustomPiOS Migration Helper" from the Advanced Menu\
`(Main Menu -> 4 -> Enter -> 10 -> Enter)` in a short summary:
* The Klipper SysVinit service will get replaced by a Klipper systemd service
* Klipper and Moonraker will use the new log-directory `~/klipper_logs`
* The webcamd service gets updated
* The webcamd script gets updated and moved from `/root/bin/webcamd` to `/usr/local/bin/webcamd`
* The NGINX `upstreams.conf` gets updated to be able to configure up to 4 webcams
* The `mainsail.txt` / `fluiddpi.txt` gets moved from `/boot` to `~/klipper_config` and renamed to `webcam.txt`
* Symlinks for the webcamd.log and various NGINX logs get created in `~/klipper_config`
* Configuration files for Klipper, Moonraker and webcamd get added to `/etc/logrotate.d`
* If they still exist, two lines will be removed from the mainsail.cfg or client_macros.cfg macro configurations:\
`SAVE_GCODE_STATE NAME=PAUSE_state` and `RESTORE_GCODE_STATE NAME=PAUSE_state`
* **Please note:**\
The "CustomPiOS Migration Helper" is intended to only work on "vanilla" MainsailOS and FluiddPi systems. Do not try to migrate a modified MainsailOS or FluiddPi system (for example if you already used KIAUH to re-install services or to set up a multi-instance installation for Klipper / Moonraker). This won't work.
### 2021-01-31
* **This is a big one... KIAUH v3.0 is out.**\

View File

@@ -1,9 +1,9 @@
#########################################################################################
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ AUTOCREATED WITH KIAUH ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
#########################################################################################
# Those are the recommended macros and config entries if you use Mainsail or Fluidd! #
# Feel free to edit or delete those macros if you already have them defined elsewhere! #
#########################################################################################
################################################################################
# ~~~~~~~~~~~~~~~~~~~~~~~~ AUTOCREATED WITH KIAUH ~~~~~~~~~~~~~~~~~~~~~~~~~~ #
################################################################################
# Recommended macros and config entries if you use Mainsail or Fluidd! #
# You can edit or delete those macros if you already defined them elsewhere! #
################################################################################
[pause_resume]
@@ -19,20 +19,18 @@ gcode:
[gcode_macro PAUSE]
rename_existing: BASE_PAUSE
# change this if you need more or less extrusion
variable_extrude: 1.0
gcode:
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
##### set park positon for x and y #####
# default is your max posion from your printer.cfg
{% set x_park = printer.toolhead.axis_maximum.x|float - 5.0 %}
{% set y_park = printer.toolhead.axis_maximum.y|float - 5.0 %}
##### set defaults #####
{% set x = params.X|default(230) %} #edit to your park position
{% set y = params.Y|default(230) %} #edit to your park position
{% set z = params.Z|default(10)|float %} #edit to your park position
{% set e = params.E|default(1) %} #edit to your retract length
##### calculate save lift position #####
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% if act_z < (max_z - 2.0) %}
{% set z_safe = 2.0 %}
{% set lift_z = z|abs %}
{% if act_z < (max_z - lift_z) %}
{% set z_safe = lift_z %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
@@ -40,21 +38,22 @@ gcode:
SAVE_GCODE_STATE NAME=PAUSE_state
BASE_PAUSE
G91
G1 E-{E} F2100
G1 Z{z_safe} F900
G1 E-{e} F2100
G1 Z{z_safe}
G90
G1 X{x_park} Y{y_park} F6000
G1 X{x} Y{y} F6000
[gcode_macro RESUME]
rename_existing: BASE_RESUME
gcode:
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
##### end of definitions #####
##### set defaults #####
{% set e = params.E|default(1) %} #edit to your retract length
G91
G1 E{E} F2100
RESTORE_GCODE_STATE NAME=PAUSE_state
G1 E{e} F2100
G90
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1
BASE_RESUME
#########################################################################################
#########################################################################################
################################################################################
################################################################################

View File

@@ -14,7 +14,7 @@ server {
gzip_comp_level 4;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/json application/xml;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/json application/xml application/javascript;
# web_path from <<UI>> static files
root /home/pi/<<UI>>;
@@ -56,6 +56,18 @@ server {
}
location /webcam/ {
proxy_pass http://mjpgstreamer/;
proxy_pass http://mjpgstreamer1/;
}
location /webcam2/ {
proxy_pass http://mjpgstreamer2/;
}
location /webcam3/ {
proxy_pass http://mjpgstreamer3/;
}
location /webcam4/ {
proxy_pass http://mjpgstreamer4/;
}
}

View File

@@ -3,17 +3,20 @@ host: 0.0.0.0
port: %PORT%
enable_debug_logging: False
config_path: %CFG%
log_path: %LOG%
database_path: %MR_DB%
klippy_uds_address: %UDS%
[authorization]
enabled: True
api_key_file: ~/.moonraker_api_key
trusted_clients:
127.0.0.1
%LAN%
::1/128
10.0.0.0/8
127.0.0.0/8
169.254.0.0/16
172.16.0.0/12
192.168.0.0/16
FE80::/10
::1/128
cors_domains:
*.lan
*.local
@@ -25,18 +28,19 @@ cors_domains:
[history]
[update_manager]
channel: dev
[update_manager client mainsail]
[update_manager mainsail]
type: web
repo: meteyou/mainsail
path: ~/mainsail
[update_manager client fluidd]
[update_manager fluidd]
type: web
repo: cadriel/fluidd
path: ~/fluidd
#[update_manager client KlipperScreen]
#[update_manager KlipperScreen]
#type: git_repo
#path: /home/%USER%/KlipperScreen
#origin: https://github.com/jordanruthe/KlipperScreen.git

View File

@@ -1,13 +1,25 @@
# /etc/nginx/conf.d/upstreams.conf
upstream apiserver {
#edit your api port here
ip_hash;
server 127.0.0.1:7125;
}
upstream mjpgstreamer {
#edit your webcam port here
upstream mjpgstreamer1 {
ip_hash;
server 127.0.0.1:8080;
}
upstream mjpgstreamer2 {
ip_hash;
server 127.0.0.1:8081;
}
upstream mjpgstreamer3 {
ip_hash;
server 127.0.0.1:8082;
}
upstream mjpgstreamer4 {
ip_hash;
server 127.0.0.1:8083;
}

View File

@@ -27,7 +27,7 @@ install_packages()
# Update system package info
report_status "Running apt-get update..."
sudo apt-get update
sudo apt-get update --allow-releaseinfo-change
# Install desired packages
report_status "Installing packages..."

View File

@@ -25,7 +25,7 @@ install_packages()
# Update system package info
report_status "Running apt-get update..."
sudo apt-get update
sudo apt-get update --allow-releaseinfo-change
# Install desired packages
report_status "Installing packages..."

View File

@@ -82,7 +82,8 @@ change_klipper_cfg_path(){
set_klipper_cfg_path(){
### stop services
klipper_service "stop" && moonraker_service "stop"
do_action_service "stop" "klipper"
do_action_service "stop" "moonraker"
### copy config files to new klipper config folder
if [ ! -z "$old_klipper_cfg_loc" ] && [ -d "$old_klipper_cfg_loc" ]; then
@@ -137,77 +138,17 @@ set_klipper_cfg_path(){
sudo systemctl daemon-reload
### restart services
klipper_service "restart" && moonraker_service "restart"
do_action_service "restart" "klipper"
do_action_service "restart" "moonraker"
}
source_kiauh_ini(){
source $INI_FILE
}
klipper_service(){
### set a variable for the ok and status messages
[ "$1" == "start" ] && ACTION1="started" && ACTION2="Starting"
[ "$1" == "stop" ] && ACTION1="stopped" && ACTION2="Stopping"
[ "$1" == "restart" ] && ACTION1="restarted" && ACTION2="Restarting"
if ls /etc/systemd/system/klipper-*.service 2>/dev/null 1>&2; then
INSTANCE_COUNT=$(systemctl list-units --full -all -t service --no-legend | grep -E "klipper-[[:digit:]].service" | wc -l)
INSTANCE=1
status_msg "$ACTION2 $INSTANCE_COUNT Klipper Services ..."
while [ $INSTANCE -le $INSTANCE_COUNT ]; do
sudo systemctl $1 klipper-$INSTANCE && ok_msg "Klipper Service #$INSTANCE $ACTION1!"
### instance counter +1
INSTANCE=$(expr $INSTANCE + 1)
done
elif [ "$(systemctl list-units --full -all -t service --no-legend | grep -E "klipper.service")" ]; then
status_msg "$ACTION2 Klipper Service ..."
sudo systemctl $1 klipper && ok_msg "Klipper Service $ACTION1!"
fi
}
moonraker_service(){
### set a variable for the ok and status messages
[ "$1" == "start" ] && ACTION1="started" && ACTION2="Starting"
[ "$1" == "stop" ] && ACTION1="stopped" && ACTION2="Stopping"
[ "$1" == "restart" ] && ACTION1="restarted" && ACTION2="Restarting"
if ls /etc/systemd/system/moonraker-*.service 2>/dev/null 1>&2; then
INSTANCE_COUNT=$(systemctl list-units --full -all -t service --no-legend | grep -E "moonraker-[[:digit:]].service" | wc -l)
INSTANCE=1
status_msg "$ACTION2 $INSTANCE_COUNT Moonraker Services ..."
while [ $INSTANCE -le $INSTANCE_COUNT ]; do
sudo systemctl $1 moonraker-$INSTANCE && ok_msg "Moonraker Service #$INSTANCE $ACTION1!"
### instance counter +1
INSTANCE=$(expr $INSTANCE + 1)
done
elif [ "$(systemctl list-units --full -all -t service --no-legend | grep -E "moonraker.service")" ]; then
status_msg "$ACTION2 Moonraker Service ..."
sudo systemctl $1 moonraker && ok_msg "Moonraker Service $ACTION1!"
fi
}
dwc_service(){
### set a variable for the ok and status messages
[ "$1" == "start" ] && ACTION1="started" && ACTION2="Starting"
[ "$1" == "stop" ] && ACTION1="stopped" && ACTION2="Stopping"
[ "$1" == "restart" ] && ACTION1="restarted" && ACTION2="Restarting"
if ls /etc/systemd/system/dwc-*.service 2>/dev/null 1>&2; then
INSTANCE_COUNT=$(systemctl list-units --full -all -t service --no-legend | grep -E "dwc-[[:digit:]].service" | wc -l)
INSTANCE=1
status_msg "$ACTION2 $INSTANCE_COUNT DWC-for-Klipper-Socket Services ..."
while [ $INSTANCE -le $INSTANCE_COUNT ]; do
sudo systemctl $1 dwc-$INSTANCE && ok_msg "DWC-for-Klipper-Socket Service #$INSTANCE $ACTION1!"
### instance counter +1
INSTANCE=$(expr $INSTANCE + 1)
done
elif [ "$(systemctl list-units --full -all -t service --no-legend | grep -E "dwc.service")" ]; then
status_msg "$ACTION2 DWC-for-Klipper-Socket Service ..."
sudo systemctl $1 dwc && ok_msg "DWC-for-Klipper-Socket Service $ACTION1!"
fi
}
octoprint_service(){
do_action_service(){
shopt -s extglob # enable extended globbing
SERVICES="$SYSTEMDDIR/$2?(-*([0-9])).service"
### set a variable for the ok and status messages
[ "$1" == "start" ] && ACTION1="started" && ACTION2="Starting"
[ "$1" == "stop" ] && ACTION1="stopped" && ACTION2="Stopping"
@@ -215,30 +156,25 @@ octoprint_service(){
[ "$1" == "enable" ] && ACTION1="enabled" && ACTION2="Enabling"
[ "$1" == "disable" ] && ACTION1="disabled" && ACTION2="Disabling"
if ls /etc/systemd/system/octoprint-*.service 2>/dev/null 1>&2; then
INSTANCE=1
INSTANCE_COUNT=$(systemctl list-unit-files | grep -E "octoprint.*" | wc -l)
status_msg "$ACTION2 $INSTANCE_COUNT OctoPrint Services ..."
while [ $INSTANCE -le $INSTANCE_COUNT ]; do
sudo systemctl $1 octoprint-$INSTANCE && ok_msg "OctoPrint Service #$INSTANCE $ACTION1!"
### instance counter +1
INSTANCE=$(expr $INSTANCE + 1)
if ls $SERVICES 2>/dev/null 1>&2; then
for service in $(ls $SERVICES | rev | cut -d"/" -f1 | rev); do
status_msg "$ACTION2 $service ..."
sudo systemctl $1 "$service"
ok_msg "$service $ACTION1!"
done
elif [ "$(systemctl list-unit-files | grep -E "octoprint.*")" ]; then
status_msg "$ACTION2 OctoPrint Service ..."
sudo systemctl $1 octoprint && ok_msg "OctoPrint Service $ACTION1!"
fi
shopt -u extglob # disable extended globbing
}
toggle_octoprint_service(){
if systemctl list-unit-files | grep -E "octoprint.*" | grep "enabled" &>/dev/null; then
octoprint_service "stop"
octoprint_service "disable"
do_action_service "stop" "octoprint"
do_action_service "disable" "octoprint"
sleep 2
CONFIRM_MSG=" OctoPrint Service is now >>> DISABLED <<< !"
elif systemctl list-unit-files | grep -E "octoprint.*" | grep "disabled" &>/dev/null; then
octoprint_service "enable"
octoprint_service "start"
do_action_service "enable" "octoprint"
do_action_service "start" "octoprint"
sleep 2
CONFIRM_MSG=" OctoPrint Service is now >>> ENABLED <<< !"
else
@@ -248,6 +184,9 @@ toggle_octoprint_service(){
read_octoprint_service_status(){
unset OPRINT_SERVICE_STATUS
if [ ! -f "/etc/systemd/system/octoprint.service" ]; then
return 0
fi
if systemctl list-unit-files | grep -E "octoprint*" | grep "enabled" &>/dev/null; then
OPRINT_SERVICE_STATUS="${red}[Disable]${default} OctoPrint Service "
else
@@ -310,7 +249,7 @@ dependency_check(){
echo -e "${cyan}$element ${default}"
done
echo
sudo apt-get update && sudo apt-get install ${inst[@]} -y
sudo apt-get update --allow-releaseinfo-change && sudo apt-get install ${inst[@]} -y
ok_msg "Dependencies installed!"
#clearing the array
unset inst
@@ -382,7 +321,7 @@ setup_gcode_shell_command(){
}
install_gcode_shell_command(){
klipper_service "stop"
do_action_service "stop" "klipper"
status_msg "Copy 'gcode_shell_command.py' to '$KLIPPER_DIR/klippy/extras' ..."
cp ${SRCDIR}/kiauh/resources/gcode_shell_command.py $KLIPPER_DIR/klippy/extras
while true; do
@@ -424,7 +363,7 @@ install_gcode_shell_command(){
esac
done
ok_msg "Shell command extension installed!"
klipper_service "restart"
do_action_service "restart" "klipper"
}
create_minimal_cfg(){

View File

@@ -174,7 +174,7 @@ install_dwc_packages()
# Update system package info
status_msg "Running apt-get update..."
sudo apt-get update
sudo apt-get update --allow-releaseinfo-change
# Install desired packages
status_msg "Installing packages..."

View File

@@ -7,7 +7,11 @@ klipper_setup_dialog(){
status_msg "Initializing Klipper installation ..."
### check for existing klipper service files
if $(ls /etc/init.d/klipper* 2>/dev/null 1>&2) || $(ls /etc/systemd/system/klipper*.service 2>/dev/null 1>&2); then
INITD=$(ls /etc/init.d | grep -E "^klipper(\-[[:digit:]]+)?$")
SYSTEMD=$(ls /etc/systemd/system | grep -E "^klipper(\-[[:digit:]]+)?\.service$")
if [ ! -z "$INITD" ] || [ ! -z "$SYSTEMD" ]; then
echo "${red}$INITD${default}" && echo "${red}$SYSTEMD${default}"
ERROR_MSG="At least one Klipper service is already installed!\n Please remove Klipper first, before installing it again." && return 0
fi
@@ -15,19 +19,19 @@ klipper_setup_dialog(){
check_klipper_cfg_path
### ask for amount of instances to create
while true; do
INSTANCE_COUNT=""
while [[ ! ($INSTANCE_COUNT =~ ^[1-9]+$) ]]; do
echo
read -p "${cyan}###### Number of Klipper instances to set up:${default} " INSTANCE_COUNT
if [[ ! ($INSTANCE_COUNT =~ ^[1-9]+$) ]]; then
warn_msg "Invalid Input!" && echo
else
echo
read -p "${cyan}###### How many Klipper instances do you want to set up?:${default} " INSTANCE_COUNT
echo
if [ $INSTANCE_COUNT == 1 ]; then
read -p "${cyan}###### Create $INSTANCE_COUNT single instance? (Y/n):${default} " yn
else
read -p "${cyan}###### Create $INSTANCE_COUNT instances? (Y/n):${default} " yn
fi
read -p "${cyan}###### Install $INSTANCE_COUNT instance(s)? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
echo -e "###### > Yes"
status_msg "Creating $INSTANCE_COUNT Klipper instances ..."
status_msg "Installing $INSTANCE_COUNT Klipper instance(s) ..."
klipper_setup
break;;
N|n|No|no)
@@ -38,32 +42,34 @@ klipper_setup_dialog(){
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
esac
fi
done
}
install_klipper_packages(){
### Packages for python cffi
PKGLIST="python-virtualenv virtualenv python-dev libffi-dev build-essential"
### kconfig requirements
PKGLIST="${PKGLIST} libncurses-dev"
### hub-ctrl
PKGLIST="${PKGLIST} libusb-dev"
### AVR chip installation and building
PKGLIST="${PKGLIST} avrdude gcc-avr binutils-avr avr-libc"
### ARM chip installation and building
PKGLIST="${PKGLIST} stm32flash libnewlib-arm-none-eabi"
PKGLIST="${PKGLIST} gcc-arm-none-eabi binutils-arm-none-eabi libusb-1.0"
### dbus requirement for DietPi
PKGLIST="${PKGLIST} dbus"
### read PKGLIST from official install script
status_msg "Reading dependencies..."
install_script="${HOME}/klipper/scripts/install-octopi.sh"
PKGLIST=$(grep "PKGLIST=" $install_script | sed 's/PKGLIST//g; s/[$={}\n"]//g')
### rewrite packages into new array
unset PKGARR
for PKG in $PKGLIST; do PKGARR+=($PKG); done
### add dbus requirement for DietPi distro
if [ -e "/boot/dietpi" ]; then
PKGARR+=("dbus")
fi
### display dependencies to user
echo "${cyan}${PKGARR[@]}${default}"
### Update system package info
status_msg "Running apt-get update..."
sudo apt-get update
sudo apt-get update --allow-releaseinfo-change
### Install desired packages
status_msg "Installing packages..."
sudo apt-get install --yes ${PKGLIST}
sudo apt-get install --yes ${PKGARR[@]}
}
create_klipper_virtualenv(){
@@ -87,8 +93,9 @@ klipper_setup(){
install_klipper_packages
create_klipper_virtualenv
### step 3: create shared gcode_files folder
### step 3: create shared gcode_files and logs folder
[ ! -d ${HOME}/gcode_files ] && mkdir -p ${HOME}/gcode_files
[ ! -d ${HOME}/klipper_logs ] && mkdir -p ${HOME}/klipper_logs
### step 4: create klipper instances
create_klipper_service
@@ -108,7 +115,7 @@ create_klipper_service(){
CFG_PATH="$klipper_cfg_loc"
KL_ENV=$KLIPPY_ENV
KL_DIR=$KLIPPER_DIR
KL_LOG="/tmp/klippy.log"
KL_LOG="${HOME}/klipper_logs/klippy.log"
KL_UDS="/tmp/klippy_uds"
P_TMP="/tmp/printer"
P_CFG="$CFG_PATH/printer.cfg"
@@ -152,7 +159,7 @@ create_klipper_service(){
KL_SERV_TARGET="$SYSTEMDDIR/klipper-$i.service"
P_TMP="/tmp/printer-$i"
P_CFG="$CFG_PATH/printer.cfg"
KL_LOG="/tmp/klippy-$i.log"
KL_LOG="${HOME}/klipper_logs/klippy-$i.log"
KL_UDS="/tmp/klippy_uds-$i"
### write multi instance service
write_kl_service
@@ -232,69 +239,72 @@ flash_routine_sd(){
select_mcu_id(){
if [ ${#mcu_list[@]} -ge 1 ]; then
echo
top_border
echo -e "| ${red}!!! IMPORTANT WARNING !!!${default} |"
echo -e "| ${red}!!! ATTENTION !!!${default} |"
hr
echo -e "| Make sure, that you select the correct ID for the MCU |"
echo -e "| you have build the firmware for in the previous step! |"
blank_line
echo -e "| This is especially important if you use different MCU |"
echo -e "| models which each require their own firmware! |"
blank_line
echo -e "| Make sure, to select the correct number for the MCU! |"
echo -e "| ${red}ONLY flash a firmware created for the respective MCU!${default} |"
bottom_border
echo -e "${cyan}###### List of available MCU:${default}"
### list all mcus
i=1
id=0
for mcu in ${mcu_list[@]}; do
echo -e "$i) ${cyan}$mcu${default}"
i=$(expr $i + 1)
let id++
echo -e " $id) $mcu"
done
while true; do
### verify user input
sel_index=""
while [[ ! ($sel_index =~ ^[1-9]+$) ]] || [ $sel_index -gt $id ]; do
echo
read -p "${cyan}###### Please select the ID for flashing:${default} " selected_index
mcu_index=$(echo $((selected_index - 1)))
read -p "${cyan}###### Select MCU to flash:${default} " sel_index
if [[ ! ($sel_index =~ ^[1-9]+$) ]]; then
warn_msg "Invalid input!"
elif [ $sel_index -lt 1 ] || [ $sel_index -gt $id ]; then
warn_msg "Please select a number between 1 and $id!"
fi
mcu_index=$(echo $((sel_index - 1)))
selected_mcu_id="${mcu_list[$mcu_index]}"
echo -e "\nYou have selected to flash:\n● MCU #$selected_index: $selected_mcu_id\n"
while true; do
read -p "${cyan}###### Do you want to continue? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
echo -e "###### > Yes"
status_msg "Flashing $selected_mcu_id ..."
if [ "$FLASH_FIRMWARE" = "true" ]; then
flash_mcu
fi
if [ "$FLASH_FW_SD" = "true" ]; then
flash_mcu_sd
fi
break;;
N|n|No|no)
echo -e "###### > No"
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
break
done
### process flashing
while true; do
echo -e "\n###### You selected:\n ● MCU #$sel_index: $selected_mcu_id\n"
read -p "${cyan}###### Continue? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
echo -e "###### > Yes"
status_msg "Flashing $selected_mcu_id ..."
if [ "$FLASH_FIRMWARE" = "true" ]; then
flash_mcu
fi
if [ "$FLASH_FW_SD" = "true" ]; then
flash_mcu_sd
fi
break;;
N|n|No|no)
echo -e "###### > No"
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
fi
}
flash_mcu(){
klipper_service "stop"
do_action_service "stop" "klipper"
if ! make flash FLASH_DEVICE="${mcu_list[$mcu_index]}" ; then
warn_msg "Flashing failed!"
warn_msg "Please read the console output above!"
else
ok_msg "Flashing successfull!"
fi
klipper_service "start"
do_action_service "start" "klipper"
}
flash_mcu_sd(){
klipper_service "stop"
do_action_service "stop" "klipper"
### write each supported board to the array to make it selectable
board_list=()
@@ -359,13 +369,15 @@ flash_mcu_sd(){
ok_msg "Flashing successfull!"
fi
klipper_service "start"
do_action_service "start" "klipper"
}
build_fw(){
if [ -d $KLIPPER_DIR ]; then
cd $KLIPPER_DIR
status_msg "Initializing firmware build ..."
dep=(build-essential dpkg-dev make)
dependency_check
make clean
make menuconfig
status_msg "Building firmware ..."
@@ -382,17 +394,11 @@ get_mcu_id(){
echo -e "| Please make sure your MCU is connected to the Pi! |"
echo -e "| If the MCU is not connected yet, connect it now. |"
bottom_border
while true; do
echo -e "${cyan}"
read -p "###### Press any key to continue ... " yn
echo -e "${default}"
case "$yn" in
*)
break;;
esac
done
echo -e "${cyan}"
read -p "###### Press ANY KEY to continue ... " -n 1 -r
echo -e "${default}"
status_msg "Identifying the ID of your MCU ..."
sleep 2
sleep 1
unset MCU_ID
### if there are devices found, continue, else show warn message
if ls /dev/serial/by-id/* 2>/dev/null 1>&2; then
@@ -412,4 +418,4 @@ get_mcu_id(){
warn_msg "Could not retrieve ID!"
warn_msg "Printer not plugged in or not detectable!"
fi
}
}

View File

@@ -100,6 +100,9 @@ install_webui(){
### creating the mainsail/fluidd nginx cfg
set_nginx_cfg "$1"
### symlink nginx log
symlink_webui_nginx_log "$1"
### copy the kiauh_macros.cfg to the config location
install_kiauh_macros
@@ -114,6 +117,23 @@ install_webui(){
print_msg && clear_msg
}
symlink_webui_nginx_log(){
LPATH="${HOME}/klipper_logs"
UI_ACCESS_LOG="/var/log/nginx/$1-access.log"
UI_ERROR_LOG="/var/log/nginx/$1-error.log"
[ ! -d "$LPATH" ] && mkdir -p "$LPATH"
if [ -f "$UI_ACCESS_LOG" ] && [ ! -L "$LPATH/$1-access.log" ]; then
status_msg "Creating symlink for $UI_ACCESS_LOG ..."
ln -s $UI_ACCESS_LOG "$LPATH"
ok_msg "OK!"
fi
if [ -f "$UI_ERROR_LOG" ] && [ ! -L "$LPATH/$1-error.log" ]; then
status_msg "Creating symlink for $UI_ERROR_LOG ..."
ln -s $UI_ERROR_LOG "$LPATH"
ok_msg "OK!"
fi
}
install_kiauh_macros(){
source_kiauh_ini
### copy kiauh_macros.cfg
@@ -143,7 +163,7 @@ install_kiauh_macros(){
ok_msg "$klipper_cfg_loc/kiauh_macros.cfg created!"
fi
### restart klipper service to parse the modified printer.cfg
klipper_service "restart"
do_action_service "restart" "klipper"
fi
}

View File

@@ -2,13 +2,8 @@ install_klipperscreen(){
python3_check
if [ $py_chk_ok = "true" ]; then
source_kiauh_ini
system_check_klipperscreen
#ask user for customization
get_user_selections_klipperscreen
#KlipperScreen main installation
klipperscreen_setup
#execute customizations
symlinks_klipperscreen
#after install actions
restart_klipperscreen
else
@@ -29,57 +24,16 @@ python3_check(){
fi
}
system_check_klipperscreen(){
source_kiauh_ini
if [ ! -e $klipper_cfg_loc/KlipperScreen.log ]; then
KLIPPERSCREEN_SL_FOUND="false"
else
KLIPPERSCREEN_SL_FOUND="true"
fi
}
get_user_selections_klipperscreen(){
#user selection for KlipperScreen.log symlink
if [ "$KLIPPERSCREEN_SL_FOUND" = "false" ]; then
while true; do
echo
read -p "${cyan}###### Create KlipperScreen.log symlink? (y/N):${default} " yn
case "$yn" in
Y|y|Yes|yes)
echo -e "###### > Yes"
SEL_KSLOG_SL="true"
break;;
N|n|No|no|"")
echo -e "###### > No"
SEL_KSLOG_SL="false"
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
fi
}
klipperscreen_setup(){
dep=(wget curl unzip dfu-util)
dependency_check
status_msg "Downloading KlipperScreen ..."
#force remove existing KlipperScreen dir
# force remove existing KlipperScreen dir
[ -d $KLIPPERSCREEN_DIR ] && rm -rf $KLIPPERSCREEN_DIR
#clone into fresh KlipperScreen dir
# clone into fresh KlipperScreen dir
cd ${HOME} && git clone $KLIPPERSCREEN_REPO
ok_msg "Download complete!"
status_msg "Installing KlipperScreen ..."
$KLIPPERSCREEN_DIR/scripts/KlipperScreen-install.sh
echo; ok_msg "KlipperScreen successfully installed!"
}
symlinks_klipperscreen(){
#create a KlipperScreen.log symlink in klipper_config-dir just for convenience
if [ "$SEL_KSLOG_SL" = "true" ] && [ ! -e $klipper_cfg_loc/KlipperScreen.log ]; then
status_msg "Creating KlipperScreen.log symlink ..."
ln -s /tmp/KlipperScreen.log $klipper_cfg_loc
ok_msg "Symlink created!"
fi
ok_msg "KlipperScreen successfully installed!"
}

View File

@@ -1,7 +1,7 @@
### base variables
SYSTEMDDIR="/etc/systemd/system"
WEBCAMD_SRC="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mjpgstreamer/filesystem/home/root/bin/webcamd"
WEBCAM_TXT_SRC="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mjpgstreamer/filesystem/boot/mainsail.txt"
WEBCAMD_SRC="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mjpgstreamer/filesystem/root/usr/local/bin/webcamd"
WEBCAM_TXT_SRC="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mjpgstreamer/filesystem/home/pi/klipper_config/webcam.txt"
install_mjpg-streamer(){
### checking dependencies
@@ -49,8 +49,8 @@ install_mjpg-streamer(){
</html>
EOT
sudo wget $WEBCAMD_SRC -O "/usr/local/bin/webcamd"
sudo sed -i "/^config_dir=/ s|=.*|=$klipper_cfg_loc|" /usr/local/bin/webcamd
sudo sed -i "/MJPGSTREAMER_HOME/ s/pi/${USER}/" /usr/local/bin/webcamd
sudo sed -i "/^cfg_files+=/ s|=.*|=$WEBCAM_TXT|" /usr/local/bin/webcamd
sudo chmod +x /usr/local/bin/webcamd
### step 4: create webcam.txt config file
@@ -65,6 +65,7 @@ EOT
status_msg "Creating MJPG-Streamer service ..."
sudo cp $MJPG_SERV_SRC $MJPG_SERV_TARGET
sudo sed -i "s|%USER%|${USER}|" $MJPG_SERV_TARGET
ok_msg "MJPG-Streamer service created!"
### step 6: enabling and starting mjpg-streamer service
status_msg "Starting MJPG-Streamer service ..."
@@ -72,6 +73,12 @@ EOT
sudo systemctl start webcamd.service
ok_msg "MJPG-Streamer service started!"
### step 6.1: create webcamd.log symlink
[ ! -d ${HOME}/klipper_logs ] && mkdir -p "${HOME}/klipper_logs"
if [ -f "/var/log/webcamd.log" ] && [ ! -L "${HOME}/klipper_logs/webcamd.log" ]; then
ln -s "/var/log/webcamd.log" "${HOME}/klipper_logs/webcamd.log"
fi
### confirm message
CONFIRM_MSG="MJPG-Streamer has been set up!"
print_msg && clear_msg

View File

@@ -46,15 +46,19 @@ moonraker_setup_dialog(){
print_msg && clear_msg && return 0
fi
shopt -s extglob # enable extended globbing
### check for existing moonraker service installations
if ls /etc/systemd/system/moonraker*.service 2>/dev/null 1>&2; then
FILE="$SYSTEMDDIR/moonraker?(-*([0-9])).service"
if ls $FILE 2>/dev/null 1>&2; then
ERROR_MSG="At least one Moonraker service is already installed!" && return 0
fi
### check for existing klipper service installations
if ! ls /etc/systemd/system/klipper*.service 2>/dev/null 1>&2; then
FILE="$SYSTEMDDIR/klipper?(-*([0-9])).service"
if ! ls $FILE 2>/dev/null 1>&2; then
ERROR_MSG="Klipper service not found, please install Klipper first!" && return 0
fi
shopt -u extglob # disable extended globbing
### count amount of klipper services
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "klipper.service")" ]; then
@@ -103,7 +107,7 @@ moonraker_setup_dialog(){
moonraker_setup(){
### checking dependencies
dep=(wget curl unzip dfu-util)
dep=(wget curl unzip dfu-util virtualenv)
### additional deps for kiauh compatibility for armbian
dep+=(libjpeg-dev zlib1g-dev)
dependency_check
@@ -142,15 +146,22 @@ moonraker_setup(){
}
install_moonraker_packages(){
PKGLIST="python3-virtualenv python3-dev nginx libopenjp2-7 python3-libgpiod"
### read PKGLIST from official install script
status_msg "Reading dependencies..."
install_script="${HOME}/moonraker/scripts/install-moonraker.sh"
PKGLIST=$(grep "PKGLIST=" $install_script | sed 's/PKGLIST//g; s/[$={}\n"]//g')
### rewrite packages into new array
unset PKGARR
for PKG in $PKGLIST; do PKGARR+=($PKG); done
echo "${cyan}${PKGARR[@]}${default}"
### Update system package info
status_msg "Running apt-get update..."
sudo apt-get update
sudo apt-get update --allow-releaseinfo-change
### Install desired packages
status_msg "Installing packages..."
sudo apt-get install --yes ${PKGLIST}
sudo apt-get install --yes ${PKGARR[@]}
}
create_moonraker_virtualenv(){
@@ -162,7 +173,10 @@ create_moonraker_virtualenv(){
rm -rf ${MOONRAKER_ENV}
fi
[ ! -d ${MOONRAKER_ENV} ] && virtualenv -p /usr/bin/python3 --system-site-packages ${MOONRAKER_ENV}
if [ ! -d ${MOONRAKER_ENV} ]; then
virtualenv -p /usr/bin/python3 ${MOONRAKER_ENV}
ln -s /usr/lib/python3/dist-packages/gpiod* ${MOONRAKER_ENV}/lib/python*/site-packages
fi
### Install/update dependencies
${MOONRAKER_ENV}/bin/pip install -r ${MOONRAKER_DIR}/scripts/moonraker-requirements.txt
@@ -177,7 +191,7 @@ create_moonraker_service(){
CFG_PATH="$klipper_cfg_loc"
MR_ENV=$MOONRAKER_ENV
MR_DIR=$MOONRAKER_DIR
MR_LOG="/tmp/moonraker.log"
MR_LOG="${HOME}/klipper_logs/moonraker.log"
MR_CONF="$CFG_PATH/moonraker.conf"
MR_SERV_SRC="${SRCDIR}/kiauh/resources/moonraker.service"
MR_SERV_TARGET="$SYSTEMDDIR/moonraker.service"
@@ -211,7 +225,7 @@ create_moonraker_service(){
CFG_PATH="$klipper_cfg_loc/printer_$i"
MR_SERV_TARGET="$SYSTEMDDIR/moonraker-$i.service"
MR_CONF="$CFG_PATH/moonraker.conf"
MR_LOG="/tmp/moonraker-$i.log"
MR_LOG="${HOME}/klipper_logs/moonraker-$i.log"
### write multi instance service
write_mr_service
### enable instance
@@ -244,6 +258,7 @@ create_moonraker_conf(){
SINGLE_INST=1
PORT=7125
CFG_PATH="$klipper_cfg_loc"
LOG_PATH="${HOME}/klipper_logs"
MR_CONF="$CFG_PATH/moonraker.conf"
MR_DB="~/.moonraker_database"
KLIPPY_UDS="/tmp/klippy_uds"
@@ -259,9 +274,16 @@ create_moonraker_conf(){
cp $MR_CONF_SRC $MR_CONF
sed -i "s|%PORT%|$PORT|" $MR_CONF
sed -i "s|%CFG%|$CFG_PATH|" $MR_CONF
sed -i "s|%LOG%|$LOG_PATH|" $MR_CONF
sed -i "s|%MR_DB%|$MR_DB|" $MR_CONF
sed -i "s|%UDS%|$KLIPPY_UDS|" $MR_CONF
sed -i "s|%LAN%|$LAN|" $MR_CONF
# if host ip is not in the default ip ranges, replace placeholder
# otherwise remove placeholder from config
if ! grep $LAN $MR_CONF; then
sed -i "s|%LAN%|$LAN|" $MR_CONF
else
sed -i "/%LAN%/d" $MR_CONF
fi
sed -i "s|%USER%|${USER}|g" $MR_CONF
ok_msg "moonraker.conf created!"
else
@@ -336,9 +358,9 @@ process_octoprint_dialog(){
Y|y|Yes|yes|"")
echo -e "###### > Yes"
status_msg "Stopping OctoPrint ..."
octoprint_service "stop" && ok_msg "OctoPrint service stopped!"
do_action_service "stop" "octoprint" && ok_msg "OctoPrint service stopped!"
status_msg "Disabling OctoPrint ..."
octoprint_service "disable" && ok_msg "OctoPrint service disabled!"
do_action_service "disable" "octoprint" && ok_msg "OctoPrint service disabled!"
break;;
N|n|No|no)
echo -e "###### > No"

View File

@@ -0,0 +1,37 @@
### base variables
PGC_FOR_KLIPPER_REPO="https://github.com/Kragrathea/pgcode"
PGC_DIR="${HOME}/pgcode"
install_pgc_for_klipper(){
pgconfsrc="$PGC_DIR/pgcode.local.conf"
pgconf="/etc/nginx/sites-available/pgcode.local.conf"
pgconfsl="/etc/nginx/sites-enabled/pgcode.local.conf"
pgc_default_port="7136"
status_msg "Installing PrettyGCode for Klipper ..."
### let the user decide which port is used
echo -e "${cyan}\n###### On which port should PrettyGCode run? (Default: $pgc_default_port)${default} "
read -e -p "${cyan}###### Port:${default} " -i "$pgc_default_port" pgc_custom_port
### check nginx dependency
dep=(nginx)
dependency_check
### clone repo
[ -d $PGC_DIR ] && rm -rf $PGC_DIR
cd ${HOME} && git clone $PGC_FOR_KLIPPER_REPO
### copy nginx config into destination directory
sudo cp $pgconfsrc $pgconf
### replace default pi user in case the user is called different
sudo sed -i "s|/home/pi/pgcode;|/home/${USER}/pgcode;|" $pgconf
### replace default port
if [ $pgc_custom_port != $pgc_default_port ]; then
sudo sed -i "s|listen $pgc_default_port;|listen $pgc_custom_port;|" $pgconf
sudo sed -i "s|listen \[::\]:$pgc_default_port;|listen \[::\]:$pgc_custom_port;|" $pgconf
fi
### create symlink
[ ! -L $pgconfsl ] && sudo ln -s $pgconf $pgconfsl
sudo systemctl restart nginx
### show URI
pgc_uri="http://$(hostname -I | cut -d" " -f1):$pgc_custom_port"
echo -e "${cyan}\n● Accessible via:${default} $pgc_uri"
ok_msg "PrettyGCode for Klipper installed!\n"
}

View File

@@ -1,6 +1,67 @@
### base variables
SYSTEMDDIR="/etc/systemd/system"
get_theme_list(){
theme_csv_url="https://raw.githubusercontent.com/meteyou/mainsail/cb874c1918f47f79441bd80decaa272fe8bae40f/docs/_data/themes.csv"
theme_csv=$(curl -s -L $theme_csv_url)
unset t_name
unset t_note
unset t_auth
unset t_url
i=0
while IFS="," read -r col1 col2 col3 col4; do
t_name+=("$col1")
t_note+=("$col2")
t_auth+=("$col3")
t_url+=("$col4")
if [ ! "$col1" == "name" ]; then
printf "| $i) %-50s|\n" "[$col1]"
fi
let i++
done <<< $theme_csv
}
ms_theme_ui(){
top_border
echo -e "| ${red}~~~~~~~~ [ Mainsail Theme Installer ] ~~~~~~~${default} | "
hr
echo -e "| ${green}A preview of each Mainsail theme can be found here:${default} | "
echo -e "| https://docs.mainsail.xyz/theming/themes | "
blank_line
echo -e "| ${yellow}Important note:${default} | "
echo -e "| Installing a theme from this menu will overwrite an | "
echo -e "| already installed theme or modified custom.css file! | "
hr
#echo -e "| Theme: | "
# dynamically generate the themelist from a csv file
get_theme_list
echo -e "| | "
echo -e "| R) [Remove Theme] | "
#echo -e "| | "
quit_footer
}
ms_theme_menu(){
ms_theme_ui
while true; do
read -p "${cyan}Install theme:${default} " a; echo
if [ $a = "q" ] || [ $a = "Q" ]; then
clear && advanced_menu && break
elif [ $a = "r" ] || [ $a = "R" ]; then
ms_theme_delete
ms_theme_menu
elif [ $a -le ${#t_url[@]} ]; then
ms_theme_install "${t_auth[$a]}" "${t_url[$a]}" "${t_name[$a]}" "${t_note[$a]}"
ms_theme_menu
else
clear && print_header
ERROR_MSG="Invalid command!" && print_msg && clear_msg
ms_theme_menu
fi
done
ms_theme_menu
}
check_select_printer(){
unset printer_num
@@ -27,6 +88,24 @@ check_select_printer(){
[ ! -d $THEME_PATH ] && mkdir -p $THEME_PATH
}
ms_theme_install(){
THEME_URL="https://github.com/$1/$2"
### check and select printer if there is more than 1
check_select_printer
### download all files
status_msg "Installing $3 ..."
status_msg "Please wait ..."
[ -d "$THEME_PATH/.theme" ] && rm -rf "$THEME_PATH/.theme"
cd $THEME_PATH && git clone "$THEME_URL" ".theme"
ok_msg "Theme installation complete!"
[ ! -z "$4" ] && echo "${yellow}###### Theme Info: $4${default}"
ok_msg "Please remember to delete your browser cache!\n"
}
ms_theme_delete(){
### check and select printer if there is more than 1
check_select_printer
@@ -39,20 +118,3 @@ ms_theme_delete(){
status_msg "No Theme installed!\n"
fi
}
ms_theme_dracula(){
THEME_URL="https://github.com/steadyjaw/dracula-mainsail-theme"
### check and select printer if there is more than 1
check_select_printer
### download all files
status_msg "Installing Dracula theme ..."
status_msg "Please wait ..."
[ -d "$THEME_PATH/.theme" ] && rm -rf "$THEME_PATH/.theme"
cd $THEME_PATH && git clone "$THEME_URL" ".theme"
ok_msg "Theme installation complete!"
ok_msg "Please remember to delete your browser cache!\n"
}

View File

@@ -2,9 +2,11 @@
SYSTEMDDIR="/etc/systemd/system"
remove_klipper(){
shopt -s extglob # enable extended globbing
### ask the user if he wants to uninstall moonraker too.
###? currently usefull if the user wants to switch from single-instance to multi-instance
if ls /etc/systemd/system/moonraker*.service 2>/dev/null 1>&2; then
FILE="$SYSTEMDDIR/moonraker?(-*([0-9])).service"
if ls $FILE 2>/dev/null 1>&2; then
while true; do
unset REM_MR
top_border
@@ -45,9 +47,10 @@ remove_klipper(){
fi
### remove all klipper services
if ls /etc/systemd/system/klipper*.service 2>/dev/null 1>&2; then
FILE="$SYSTEMDDIR/klipper?(-*([0-9])).service"
if ls $FILE 2>/dev/null 1>&2; then
status_msg "Removing Klipper Services ..."
for service in $(ls /etc/systemd/system/klipper*.service | cut -d"/" -f5)
for service in $(ls $FILE | cut -d"/" -f5)
do
status_msg "Removing $service ..."
sudo systemctl stop $service
@@ -62,32 +65,32 @@ remove_klipper(){
fi
### remove all logfiles
if ls /tmp/klippy*.log 2>/dev/null 1>&2; then
for logfile in $(ls /tmp/klippy*.log)
do
status_msg "Removing $logfile ..."
rm -f $logfile
ok_msg "File '$logfile' removed!"
FILE="${HOME}/klipper_logs/klippy?(-*([0-9])).log"
if ls $FILE 2>/dev/null 1>&2; then
for log in $(ls $FILE); do
status_msg "Removing $log ..."
rm -f $log
ok_msg "$log removed!"
done
fi
### remove all UDS
if ls /tmp/klippy_uds* 2>/dev/null 1>&2; then
for uds in $(ls /tmp/klippy_uds*)
do
FILE="/tmp/klippy_uds?(-*([0-9]))"
if ls $FILE 2>/dev/null 1>&2; then
for uds in $(ls $FILE); do
status_msg "Removing $uds ..."
rm -f $uds
ok_msg "File '$uds' removed!"
ok_msg "$uds removed!"
done
fi
### remove all tmp-printer
if ls /tmp/printer* 2>/dev/null 1>&2; then
for tmp_printer in $(ls /tmp/printer*)
do
FILE="/tmp/printer?(-*([0-9]))"
if ls $FILE 2>/dev/null 1>&2; then
for tmp_printer in $(ls $FILE); do
status_msg "Removing $tmp_printer ..."
rm -f $tmp_printer
ok_msg "File '$tmp_printer' removed!"
ok_msg "$tmp_printer removed!"
done
fi
@@ -102,6 +105,7 @@ remove_klipper(){
fi
CONFIRM_MSG=" Klipper was successfully removed!" && print_msg && clear_msg
shopt -u extglob # enable extended globbing
if [ "$REM_MR" == "true" ]; then
remove_moonraker && unset REM_MR
@@ -112,6 +116,7 @@ remove_klipper(){
#############################################################
remove_moonraker(){
shopt -s extglob # enable extended globbing
### remove "legacy" moonraker init.d service
if [ -f /etc/init.d/moonraker ]; then
status_msg "Removing Moonraker Service ..."
@@ -123,9 +128,10 @@ remove_moonraker(){
fi
### remove all moonraker services
if ls /etc/systemd/system/moonraker*.service 2>/dev/null 1>&2; then
FILE="$SYSTEMDDIR/moonraker?(-*([0-9])).service"
if ls $FILE 2>/dev/null 1>&2; then
status_msg "Removing Moonraker Services ..."
for service in $(ls /etc/systemd/system/moonraker*.service | cut -d"/" -f5)
for service in $(ls $FILE | cut -d"/" -f5)
do
status_msg "Removing $service ..."
sudo systemctl stop $service
@@ -140,12 +146,12 @@ remove_moonraker(){
fi
### remove all logfiles
if ls /tmp/moonraker*.log 2>/dev/null 1>&2; then
for logfile in $(ls /tmp/moonraker*.log)
do
status_msg "Removing $logfile ..."
rm -f $logfile
ok_msg "File '$logfile' removed!"
FILE="${HOME}/klipper_logs/moonraker?(-*([0-9])).log"
if ls $FILE 2>/dev/null 1>&2; then
for log in $(ls $FILE); do
status_msg "Removing $log ..."
rm -f $log
ok_msg "$log removed!"
done
fi
@@ -176,6 +182,7 @@ remove_moonraker(){
fi
CONFIRM_MSG=" Moonraker was successfully removed!"
shopt -u extglob # disable extended globbing
}
#############################################################
@@ -258,6 +265,14 @@ remove_mainsail(){
sudo rm /etc/nginx/sites-enabled/mainsail && ok_msg "File removed!"
fi
### remove mainsail nginx logs and log symlinks
for log in $(find /var/log/nginx -name "mainsail*"); do
sudo rm -f $log
done
for log in $(find ${HOME}/klipper_logs -name "mainsail*"); do
rm -f $log
done
CONFIRM_MSG="Mainsail successfully removed!"
}
@@ -280,6 +295,14 @@ remove_fluidd(){
sudo rm /etc/nginx/sites-enabled/fluidd && ok_msg "File removed!"
fi
### remove mainsail nginx logs and log symlinks
for log in $(find /var/log/nginx -name "fluidd*"); do
sudo rm -f $log
done
for log in $(find ${HOME}/klipper_logs -name "fluidd*"); do
rm -f $log
done
CONFIRM_MSG="Fluidd successfully removed!"
}
@@ -442,6 +465,11 @@ remove_mjpg-streamer(){
ok_msg "MJPG-Streamer Service removed!"
fi
### remove webcamd from /usr/local/bin
if [ -e "/usr/local/bin/webcamd" ]; then
sudo rm -f "/usr/local/bin/webcamd"
fi
### remove MJPG-Streamer directory
if [ -d ${HOME}/mjpg-streamer ]; then
status_msg "Removing MJPG-Streamer directory ..."
@@ -449,5 +477,24 @@ remove_mjpg-streamer(){
ok_msg "MJPG-Streamer directory removed!"
fi
### remove webcamd log and symlink
[ -f "/var/log/webcamd.log" ] && sudo rm -f "/var/log/webcamd.log"
[ -L "${HOME}/klipper_logs/webcamd.log" ] && rm -f "${HOME}/klipper_logs/webcamd.log"
CONFIRM_MSG="MJPG-Streamer successfully removed!"
}
remove_prettygcode(){
pgconf="/etc/nginx/sites-available/pgcode.local.conf"
pgconfsl="/etc/nginx/sites-enabled/pgcode.local.conf"
if [ -d ${HOME}/pgcode ] || [ -f $pgconf ] || [ -L $pgconfsl ]; then
status_msg "Removing PrettyGCode for Klipper ..."
rm -rf ${HOME}/pgcode
sudo rm -f $pgconf
sudo rm -f $pgconfsl
sudo systemctl restart nginx
CONFIRM_MSG="PrettyGCode for Klipper successfully removed!"
else
ERROR_MSG="PrettyGCode for Klipper not found!\n Skipping..."
fi
}

View File

@@ -30,7 +30,7 @@ klipper_status(){
)
### count amount of klipper service files in /etc/systemd/system
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "klipper" | wc -l)
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "^klipper(\-[[:digit:]]+)?\.service$" | wc -l)
### a fix to detect an existing "legacy" klipper init.d installation
if [ -f /etc/init.d/klipper ] && [ -f /etc/init.d/klipper ]; then
@@ -68,7 +68,7 @@ dwc2_status(){
)
### count amount of dwc service files in /etc/systemd/system
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "dwc" | wc -l)
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "^dwc(\-[[:digit:]]+)?\.service$" | wc -l)
### remove the "SERVICE" entry from the dwc_data array if a dwc service is installed
[ $SERVICE_FILE_COUNT -gt 0 ] && unset dwc_data[0]
@@ -99,7 +99,7 @@ moonraker_status(){
)
### count amount of moonraker service files in /etc/systemd/system
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E 'moonraker\.service|moonraker-[[:digit:]]*.service' | wc -l)
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "^moonraker(\-[[:digit:]]+)?\.service$" | wc -l)
### remove the "SERVICE" entry from the moonraker_data array if a moonraker service is installed
[ $SERVICE_FILE_COUNT -gt 0 ] && unset moonraker_data[0]
@@ -175,7 +175,7 @@ octoprint_status(){
$OCTOPRINT_DIR
)
### count amount of octoprint service files in /etc/systemd/system
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "octoprint" | wc -l)
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "^octoprint(\-[[:digit:]]+)?\.service$" | wc -l)
### remove the "SERVICE" entry from the octoprint_data array if a octoprint service is installed
[ $SERVICE_FILE_COUNT -gt 0 ] && unset octoprint_data[0]
@@ -575,6 +575,37 @@ compare_MoonrakerTelegramBot_versions(){
}
#############################################################
#############################################################
read_pgc_versions(){
PGC_DIR="${HOME}/pgcode"
if [ -d $PGC_DIR ] && [ -d $PGC_DIR/.git ]; then
cd $PGC_DIR
git fetch origin main -q
LOCAL_PGC_COMMIT=$(git describe HEAD --always --tags | cut -d "-" -f 1,2)
REMOTE_PGC_COMMIT=$(git describe origin/main --always --tags | cut -d "-" -f 1,2)
else
LOCAL_PGC_COMMIT=$NONE
REMOTE_PGC_COMMIT=$NONE
fi
}
compare_pgc_versions(){
unset PGC_UPDATE_AVAIL
read_pgc_versions
if [ "$LOCAL_PGC_COMMIT" != "$REMOTE_PGC_COMMIT" ]; then
LOCAL_PGC_COMMIT="${yellow}$(printf "%-12s" "$LOCAL_PGC_COMMIT")${default}"
REMOTE_PGC_COMMIT="${green}$(printf "%-12s" "$REMOTE_PGC_COMMIT")${default}"
PGC_UPDATE_AVAIL="true"
update_arr+=(update_pgc_for_klipper)
else
LOCAL_PGC_COMMIT="${green}$(printf "%-12s" "$LOCAL_PGC_COMMIT")${default}"
REMOTE_PGC_COMMIT="${green}$(printf "%-12s" "$REMOTE_PGC_COMMIT")${default}"
PGC_UPDATE_AVAIL="false"
fi
}
#############################################################
#############################################################
@@ -592,4 +623,5 @@ ui_print_versions(){
compare_fluidd_versions
compare_klipperscreen_versions
compare_MoonrakerTelegramBot_versions
compare_pgc_versions
}

View File

@@ -2,11 +2,13 @@ advanced_ui(){
top_border
echo -e "| ${yellow}~~~~~~~~~~~~~ [ Advanced Menu ] ~~~~~~~~~~~~~${default} | "
hr
echo -e "| 0) $OPRINT_SERVICE_STATUS| "
hr
echo -e "| | | "
if [ ! "$OPRINT_SERVICE_STATUS" == "" ]; then
echo -e "| 0) $OPRINT_SERVICE_STATUS| "
hr
echo -e "| | | "
fi
echo -e "| Klipper: | Mainsail: | "
echo -e "| 1) [Switch Version] | 7) [Theme installer] | "
echo -e "| 1) [Switch Branch] | 7) [Theme installer] | "
echo -e "| 2) [Rollback] | | "
echo -e "| | System: | "
echo -e "| Firmware: | 8) [Change hostname] | "
@@ -14,6 +16,8 @@ advanced_ui(){
echo -e "| 4) [Build + Flash] | Extensions: | "
echo -e "| 5) [Build + SD Flash] | 9) [Shell Command] | "
echo -e "| 6) [Get MCU ID] | | "
echo -e "| | CustomPiOS: | "
echo -e "| | 10) [Migration Helper] | "
quit_footer
}
@@ -40,7 +44,7 @@ advanced_menu(){
clear && print_header
flash_routine
if [ $FLASH_FIRMWARE = "true" ]; then
status_msg "Please wait..." && sleep 5 && build_fw
status_msg "Please wait..." && sleep 3 && build_fw
select_mcu_id
fi
print_msg && clear_msg
@@ -49,7 +53,7 @@ advanced_menu(){
clear && print_header
flash_routine_sd
if [ $FLASH_FW_SD = "true" ]; then
status_msg "Please wait..." && sleep 5 && build_fw
status_msg "Please wait..." && sleep 3 && build_fw
select_mcu_id
fi
print_msg && clear_msg
@@ -66,6 +70,8 @@ advanced_menu(){
advanced_ui;;
9)
do_action "setup_gcode_shell_command" "advanced_ui";;
10)
do_action "migration_menu";;
Q|q)
clear; main_menu; break;;
*)
@@ -163,3 +169,40 @@ rollback_ui(){
echo -e "| $PREV_UI | "
quit_footer
}
#############################################################
#############################################################
migration_ui(){
top_border
echo -e "| $(title_msg "~~~~~~~~~ [ CustomPiOS Migration ] ~~~~~~~~~~") | "
hr
echo -e "| This function will help you to migrate a vanilla | "
echo -e "| MainsailOS or FluiddPi image to a newer state. | "
blank_line
echo -e "| Only use this function if you use MainsailOS 0.4.0 | "
echo -e "| or lower, or FluiddPi v1.13.0 or lower. | "
blank_line
echo -e "| Please have a look at the KIAUH changelog for more | "
echo -e "| details on what this function will do. | "
hr
echo -e "| | "
echo -e "| 1) [Migrate MainsailOS] | "
echo -e "| 2) [Migrate FluiddPi] | "
echo -e "| | "
quit_footer
}
migration_menu(){
print_msg && clear_msg
migration_ui
while true; do
read -p "${cyan}Perform action:${default} " action; echo
case "$action" in
1) migrate_custompios "mainsail"; migration_menu;;
2) migrate_custompios "fluiddpi"; migration_menu;;
Q|q) clear; advanced_menu; break;;
*) print_unkown_cmd; migration_menu;;
esac
done
}

View File

@@ -33,6 +33,8 @@ kiauh_update_msg(){
top_border
echo -e "|${green} New KIAUH update available! ${default}| "
hr
echo -e "|${green} View Changelog: https://git.io/JnmlX ${default}| "
blank_line
echo -e "|${yellow} It is recommended to keep KIAUH up to date. Updates ${default}| "
echo -e "|${yellow} usually contain bugfixes, important changes or new ${default}| "
echo -e "|${yellow} features. Please consider updating! ${default}| "

View File

@@ -13,9 +13,10 @@ install_ui(){
echo -e "| 2) [Moonraker] | 6) [Duet Web Control] | "
echo -e "| | 7) [OctoPrint] | "
echo -e "| Klipper Webinterface: | 8) [MoonrakerTelegramBot]| "
echo -e "| 3) [Mainsail] | | "
echo -e "| 4) [Fluidd] | Webcam: | "
echo -e "| | 9) [MJPG-Streamer] | "
echo -e "| 3) [Mainsail] | 9) [PrettyGCode] | "
echo -e "| 4) [Fluidd] | | "
echo -e "| | Webcam: | "
echo -e "| | 10) [MJPG-Streamer] | "
quit_footer
}
@@ -41,6 +42,8 @@ install_menu(){
8)
do_action "install_MoonrakerTelegramBot" "install_ui";;
9)
do_action "install_pgc_for_klipper" "install_ui";;
10)
do_action "install_mjpg-streamer" "install_ui";;
Q|q)
clear; main_menu; break;;

View File

@@ -61,46 +61,26 @@ main_menu(){
while true; do
read -p "${cyan}Perform action:${default} " action; echo
case "$action" in
"start klipper")
do_action "klipper_service start" "main_ui";;
"stop klipper")
do_action "klipper_service stop" "main_ui";;
"restart klipper")
do_action "klipper_service restart" "main_ui";;
"start moonraker")
do_action "moonraker_service start" "main_ui";;
"stop moonraker")
do_action "moonraker_service stop" "main_ui";;
"restart moonraker")
do_action "moonraker_service restart" "main_ui";;
"start dwc")
do_action "dwc_service start" "main_ui";;
"stop dwc")
do_action "dwc_service stop" "main_ui";;
"restart dwc")
do_action "dwc_service restart" "main_ui";;
"start octoprint")
do_action "octoprint_service start" "main_ui";;
"stop octoprint")
do_action "octoprint_service stop" "main_ui";;
"restart octoprint")
do_action "octoprint_service restart" "main_ui";;
update)
do_action "update_kiauh" "main_ui";;
0)
do_action "upload_selection" "main_ui";;
1)
clear && install_menu && break;;
2)
clear && update_menu && break;;
3)
clear && remove_menu && break;;
4)
clear && advanced_menu && break;;
5)
clear && backup_menu && break;;
6)
clear && settings_menu && break;;
"start klipper") do_action_service "start" "klipper"; main_ui;;
"stop klipper") do_action_service "stop" "klipper"; main_ui;;
"restart klipper") do_action_service "restart" "klipper"; main_ui;;
"start moonraker") do_action_service "start" "moonraker"; main_ui;;
"stop moonraker") do_action_service "stop" "moonraker"; main_ui;;
"restart moonraker")do_action_service "restart" "moonraker"; main_ui;;
"start dwc") do_action_service "start" "dwc"; main_ui;;
"stop dwc") do_action_service "stop" "dwc"; main_ui;;
"restart dwc") do_action_service "restart" "dwc"; main_ui;;
"start octoprint") do_action_service "start" "octoprint"; main_ui;;
"stop octoprint") do_action_service "stop" "octoprint"; main_ui;;
"restart octoprint") do_action_service "restart" "octoprint"; main_ui;;
update) do_action "update_kiauh" "main_ui";;
0) do_action "upload_selection" "main_ui";;
1) clear && install_menu && break;;
2) clear && update_menu && break;;
3) clear && remove_menu && break;;
4) clear && advanced_menu && break;;
5) clear && backup_menu && break;;
6) clear && settings_menu && break;;
Q|q)
echo -e "${green}###### Happy printing! ######${default}"; echo
exit -1;;

View File

@@ -1,33 +0,0 @@
ms_theme_ui(){
top_border
echo -e "| ${red}~~~~~~~~ [ Mainsail Theme Installer ] ~~~~~~~${default} | "
hr
echo -e "| Please note: | "
echo -e "| Installing a theme from this menu will overwrite an | "
echo -e "| already installed theme or modified custom.css file! | "
hr
echo -e "| Theme: | "
echo -e "| 1) [Dracula] | "
echo -e "| | "
echo -e "| R) [Remove Theme] | "
echo -e "| | "
quit_footer
}
ms_theme_menu(){
do_action "" "ms_theme_ui"
while true; do
read -p "${cyan}Perform action:${default} " action; echo
case "$action" in
1)
do_action "ms_theme_dracula" "ms_theme_ui";;
R|r)
do_action "ms_theme_delete" "ms_theme_ui";;
Q|q)
clear; advanced_menu; break;;
*)
deny_action "ms_theme_ui";;
esac
done
ms_theme_menu
}

View File

@@ -12,10 +12,11 @@ remove_ui(){
echo -e "| Klipper API: | Other: | "
echo -e "| 2) [Moonraker] | 6) [Duet Web Control] | "
echo -e "| | 7) [OctoPrint] | "
echo -e "| Klipper Webinterface: | 8) [NGINX] | "
echo -e "| 3) [Mainsail] | 9) [MJPG-Streamer] | "
echo -e "| Klipper Webinterface: | 8) [MJPG-Streamer] | "
echo -e "| 3) [Mainsail] | 9) [PrettyGCode] | "
echo -e "| 4) [Fluidd] | 10) [MTelegramBot] | "
echo -e "| | | "
echo -e "| | 11) [NGINX] | "
quit_footer
}
@@ -39,11 +40,13 @@ remove_menu(){
7)
do_action "remove_octoprint" "remove_ui";;
8)
do_action "remove_nginx" "remove_ui";;
9)
do_action "remove_mjpg-streamer" "remove_ui";;
9)
do_action "remove_prettygcode" "remove_ui";;
10)
do_action "remove_MoonrakerTelegramBot" "remove_ui";;
11)
do_action "remove_nginx" "remove_ui";;
Q|q)
clear; main_menu; break;;
*)

View File

@@ -21,9 +21,10 @@ update_ui(){
echo -e "| Other: |---------------|--------------| "
echo -e "| 6) [DWC2-for-Klipper] | $LOCAL_DWC2FK_COMMIT | $REMOTE_DWC2FK_COMMIT | "
echo -e "| 7) [DWC2 Web UI] | $DWC2_LOCAL_VER | $DWC2_REMOTE_VER | "
echo -e "| 8) [MTelegramBot] | $LOCAL_MOONRAKERTELEGRAMBOT_COMMIT | $REMOTE_MOONRAKERTELEGRAMBOT_COMMIT | "
echo -e "| 8) [PrettyGCode] | $LOCAL_PGC_COMMIT | $REMOTE_PGC_COMMIT | "
echo -e "| 9) [MTelegramBot] | $LOCAL_MOONRAKERTELEGRAMBOT_COMMIT | $REMOTE_MOONRAKERTELEGRAMBOT_COMMIT | "
echo -e "| |------------------------------| "
echo -e "| 9) [System] | $DISPLAY_SYS_UPDATE | "
echo -e "| 10) [System] | $DISPLAY_SYS_UPDATE | "
quit_footer
}
@@ -50,8 +51,10 @@ update_menu(){
7)
do_action "update_dwc2" "update_ui";;
8)
do_action "update_MoonrakerTelegramBot" "update_ui";;
do_action "update_pgc_for_klipper" "update_ui";;
9)
do_action "update_MoonrakerTelegramBot" "update_ui";;
10)
do_action "update_system" "update_ui";;
a)
do_action "update_all" "update_ui";;

View File

@@ -39,8 +39,11 @@ update_all(){
if [ "$KLIPPERSCREEN_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● KlipperScreen${default} |"
fi
if [ "$PGC_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● PrettyGCode for Klipper${default} |"
fi
if [ "$MOONRAKERTELEGRAMBOT_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● MoonrakerTelegramBot${default} |"
echo -e "| ${cyan}● MoonrakerTelegramBot${default} |"
fi
if [ "$SYS_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● System${default} |"
@@ -65,8 +68,159 @@ update_all(){
done
}
update_log_paths(){
### update services to make use of moonrakers new log_path option
### https://github.com/Arksine/moonraker/commit/829b3a4ee80579af35dd64a37ccc092a1f67682a
shopt -s extglob # enable extended globbing
source_kiauh_ini
LPATH="${HOME}/klipper_logs"
[ ! -d "$LPATH" ] && mkdir -p "$LPATH"
FILE="$SYSTEMDDIR/$1?(-*([0-9])).service"
for file in $(ls $FILE); do
[ "$1" == "klipper" ] && LOG="klippy"
[ "$1" == "moonraker" ] && LOG="moonraker"
if [ ! "$(grep "\-l" $file)" ]; then
status_msg "Updating $file ..."
sudo sed -i -r "/ExecStart=/ s|$| -l $LPATH/$LOG.log|" $file
ok_msg "$file updated!"
elif [ "$(grep "\-l \/tmp\/$LOG" $file)" ]; then
status_msg "Updating $file ..."
sudo sed -i -r "/ExecStart=/ s|-l \/tmp\/$LOG|-l $LPATH/$LOG|" $file
ok_msg "$file updated!"
fi
done
sudo systemctl daemon-reload
# patch log_path entry if not found
dir1="$klipper_cfg_loc"
dir2="$klipper_cfg_loc/printer_*"
for conf in $(find $dir1 $dir2 -name "moonraker.conf" 2> /dev/null); do
if ! grep -q "log_path" $conf; then
status_msg "Patching $conf"
sed -i "/^config_path/a log_path: $LPATH" $conf
ok_msg "OK!"
fi
done
# create symlink for mainsail and fluidd nginx logs
symlink_webui_nginx_log "mainsail"
symlink_webui_nginx_log "fluidd"
# create symlink for webcamd log
if [ -f "/var/log/webcamd.log" ] && [ ! -L "$LPATH/webcamd.log" ]; then
status_msg "Creating symlink for '/var/log/webcamd.log' ..."
ln -s "/var/log/webcamd.log" "$LPATH"
ok_msg "OK!"
fi
shopt -u extglob # disable extended globbing
}
migrate_custompios(){
### migrate vanilla mainsailOS 0.4.0 / fluiddPI v1.13.0
### and older to be in sync with newer releases
WEBCAMD_SRC="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mjpgstreamer/filesystem/root/usr/local/bin/webcamd"
MJPG_SERV_SRC="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mjpgstreamer/filesystem/root/etc/systemd/system/webcamd.service"
KL_SERV_SRC="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/klipper/filesystem/root/etc/systemd/system/klipper.service"
NGINX_CFG1="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mainsail/filesystem/root/etc/nginx/conf.d/upstreams.conf"
NGINX_CFG2="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mainsail/filesystem/root/etc/nginx/sites-available/mainsail"
LOG_ROTATE_KLIPPER="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/klipper/filesystem/root/etc/logrotate.d/klipper"
LOG_ROTATE_MOONRAKER="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/moonraker/filesystem/root/etc/logrotate.d/moonraker"
LOG_ROTATE_WEBCAMD="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mjpgstreamer/filesystem/root/etc/logrotate.d/webcamd"
if [ "$1" == "mainsail" ]; then
OS_VER="MainsailOS"
MACRO_CFG="mainsail.cfg"
fi
if [ "$1" == "fluiddpi" ]; then
OS_VER="FluiddPi"
MACRO_CFG="client_macros.cfg"
fi
if [ ! -f "/boot/$1.txt" ] || [ ! -f "/etc/init.d/klipper" ]; then
# abort function if there is no sign of an old CustomPiOS anymore
ERROR_MSG="No vanilla $OS_VER found. Aborting..." && return 0
fi
status_msg "Starting migration of $OS_VER... Please wait..."
if [ -d "${HOME}/klipper_logs" ]; then
# delete an existing klipper_logs directory
# shouldn't be there in the first place if its a true vanilla CustomPiOS
status_msg "Recreate '~/klipper_logs' directory..."
rm -rf "${HOME}/klipper_logs" && mkdir "${HOME}/klipper_logs"
ok_msg "OK!"
fi
if [ -f "/boot/$1.txt" ]; then
# replace old webcamd.service and webcamd
status_msg "Migrating MJPG-Streamer..."
sudo systemctl stop webcamd
sudo rm -f "/etc/systemd/system/webcamd.service"
sudo rm -f "/root/bin/webcamd"
sudo wget $WEBCAMD_SRC -O "/usr/local/bin/webcamd"
sudo wget $MJPG_SERV_SRC -O "/etc/systemd/system/webcamd.service"
sudo sed -i "s/MainsailOS/$OS_VER/" "/etc/systemd/system/webcamd.service"
sudo chmod +x "/usr/local/bin/webcamd"
# move mainsail.txt/fluiddpi.txt from boot to klipper_config and rename it
sudo mv "/boot/$1.txt" "${HOME}/klipper_config/webcam.txt"
sudo chown pi:pi "${HOME}/klipper_config/webcam.txt"
sudo systemctl daemon-reload
sudo systemctl restart webcamd
ok_msg "OK!"
fi
if [ -f "/etc/init.d/klipper" ] && [ ! -f "/etc/systemd/system/klipper.service" ]; then
# replace klipper SysVinit service with systemd service
status_msg "Migrating Klipper Service..."
sudo systemctl stop klipper
sudo update-rc.d -f klipper remove
sudo rm -f "/etc/init.d/klipper"
sudo rm -f "/etc/default/klipper"
sudo wget $KL_SERV_SRC -O "/etc/systemd/system/klipper.service"
sudo systemctl enable klipper.service
sudo systemctl daemon-reload
sudo systemctl restart klipper
ok_msg "OK!"
fi
if [ -f "/etc/systemd/system/moonraker.service" ]; then
# update new log path in existing moonraker service
status_msg "Updating Moonraker Service..."
sudo systemctl stop moonraker
update_log_paths "moonraker"
sudo systemctl restart moonraker
ok_msg "OK!"
fi
if [ -f "/etc/nginx/conf.d/upstreams.conf" ]; then
[ "$1" == "mainsail" ] && cfg="mainsail"
[ "$1" == "fluiddpi" ] && cfg="fluidd"
# update nginx upstreams.conf and mainsail/fluidd config file
status_msg "Updating NGINX configurations..."
sudo systemctl stop nginx
sudo rm -f "/etc/nginx/conf.d/upstreams.conf"
sudo rm -f "/etc/nginx/sites-available/$cfg"
sudo wget $NGINX_CFG1 -O "/etc/nginx/conf.d/upstreams.conf"
sudo wget $NGINX_CFG2 -O "/etc/nginx/sites-available/$cfg"
sudo sed -i "s/mainsail/$cfg/g" "/etc/nginx/sites-available/$cfg"
sudo systemctl restart nginx
ok_msg "OK!"
fi
if [ -f "${HOME}/klipper_config/$MACRO_CFG" ]; then
# update macro files
status_msg "Updating $MACRO_CFG ..."
MACRO_CFG_PATH="${HOME}/klipper_config/$MACRO_CFG"
sed -i "/SAVE_GCODE_STATE NAME=PAUSE_state/d" $MACRO_CFG_PATH
sed -i "/RESTORE_GCODE_STATE NAME=PAUSE_state/d" $MACRO_CFG_PATH
ok_msg "OK!"
fi
if [ -d "/etc/logrotate.d" ]; then
# download logrotate configs
status_msg "Setting up logrotations..."
sudo wget $LOG_ROTATE_KLIPPER -O "/etc/logrotate.d/klipper"
sudo wget $LOG_ROTATE_MOONRAKER -O "/etc/logrotate.d/moonraker"
sudo wget $LOG_ROTATE_WEBCAMD -O "/etc/logrotate.d/webcamd"
ok_msg "OK!"
fi
ok_msg "Migration done!"
}
update_klipper(){
klipper_service "stop"
do_action_service "stop" "klipper"
if [ ! -d $KLIPPER_DIR ]; then
cd ${HOME} && git clone $KLIPPER_REPO
else
@@ -75,42 +229,32 @@ update_klipper(){
save_klipper_state
status_msg "Updating $GET_BRANCH"
cd $KLIPPER_DIR
KLIPPER_OLDREQ_MD5SUM="$(md5sum $KLIPPER_DIR/scripts/klippy-requirements.txt | cut -d " " -f1)"
if [ "$DETACHED_HEAD" == "true" ]; then
git checkout $GET_BRANCH
unset DETACHED_HEAD
fi
### pull latest files from github
git pull && ok_msg "Update successfull!"
### check for possible new dependencies and install them
if [[ $(md5sum $KLIPPER_DIR/scripts/klippy-requirements.txt | cut -d " " -f1) != $KLIPPER_OLDREQ_MD5SUM ]]; then
PYTHONDIR="${HOME}/klippy-env"
status_msg "New dependecies detected..."
### always rebuild the pythondir from scratch if new dependencies were detected
rm -rf ${PYTHONDIR}
virtualenv -p python2 ${PYTHONDIR}
$PYTHONDIR/bin/pip install -r $KLIPPER_DIR/scripts/klippy-requirements.txt
ok_msg "Dependencies have been installed!"
fi
ok_msg "Update complete!"
git pull
### read PKGLIST and install possible new dependencies
install_klipper_packages
### install possible new python dependencies
KLIPPER_REQ_TXT="$KLIPPER_DIR/scripts/klippy-requirements.txt"
$KLIPPY_ENV/bin/pip install -r $KLIPPER_REQ_TXT
fi
klipper_service "restart"
update_log_paths "klipper"
ok_msg "Update complete!"
do_action_service "restart" "klipper"
}
update_dwc2fk(){
dwc_service "stop"
do_action_service "stop" "dwc"
bb4u "dwc2"
if [ ! -d $DWC2FK_DIR ]; then
cd ${HOME} && git clone $DWC2FK_REPO
else
cd $DWC2FK_DIR && git pull
fi
dwc_service "start"
do_action_service "start" "dwc"
}
update_dwc2(){
@@ -122,38 +266,30 @@ update_mainsail(){
bb4u "mainsail"
status_msg "Updating Mainsail ..."
mainsail_setup
symlink_webui_nginx_log "mainsail"
}
update_fluidd(){
bb4u "fluidd"
status_msg "Updating Fluidd ..."
fluidd_setup
symlink_webui_nginx_log "fluidd"
}
update_moonraker(){
moonraker_service "stop"
do_action_service "stop" "moonraker"
bb4u "moonraker"
status_msg "Updating Moonraker ..."
cd $MOONRAKER_DIR
MOONRAKER_OLDREQ_MD5SUM=$(md5sum $MOONRAKER_DIR/scripts/moonraker-requirements.txt | cut -d " " -f1)
### pull latest files from github
git pull && ok_msg "Update successfull!"
### check for possible new dependencies and install them
if [[ $(md5sum $MOONRAKER_DIR/scripts/moonraker-requirements.txt | cut -d " " -f1) != $MOONRAKER_OLDREQ_MD5SUM ]]; then
PYTHONDIR="${HOME}/moonraker-env"
status_msg "New dependecies detected..."
### always rebuild the pythondir from scratch if new dependencies were detected
rm -rf ${PYTHONDIR}
virtualenv -p /usr/bin/python3 ${PYTHONDIR}
ln -s /usr/lib/python3/dist-packages/gpiod* ${PYTHONDIR}/lib/python*/site-packages
${PYTHONDIR}/bin/pip install -r $MOONRAKER_DIR/scripts/moonraker-requirements.txt
ok_msg "Dependencies have been installed!"
fi
cd $MOONRAKER_DIR && git pull
### read PKGLIST and install possible new dependencies
install_moonraker_packages
### install possible new python dependencies
MR_REQ_TXT="$MOONRAKER_DIR/scripts/moonraker-requirements.txt"
$MOONRAKER_ENV/bin/pip install -r $MR_REQ_TXT
update_log_paths "moonraker"
ok_msg "Update complete!"
moonraker_service "restart"
do_action_service "restart" "moonraker"
}
update_klipperscreen(){
@@ -161,7 +297,7 @@ update_klipperscreen(){
cd $KLIPPERSCREEN_DIR
KLIPPERSCREEN_OLDREQ_MD5SUM=$(md5sum $KLIPPERSCREEN_DIR/scripts/KlipperScreen-requirements.txt | cut -d " " -f1)
git pull origin master -q && ok_msg "Fetch successfull!"
git checkout -f origin/master && ok_msg "Checkout successfull"
git checkout -f master && ok_msg "Checkout successfull"
#KLIPPERSCREEN_NEWREQ_MD5SUM=$(md5sum $KLIPPERSCREEN_DIR/scripts/KlipperScreen-requirements.txt)
if [[ $(md5sum $KLIPPERSCREEN_DIR/scripts/KlipperScreen-requirements.txt | cut -d " " -f1) != $KLIPPERSCREEN_OLDREQ_MD5SUM ]]; then
status_msg "New dependecies detected..."
@@ -173,6 +309,13 @@ update_klipperscreen(){
start_klipperscreen
}
update_pgc_for_klipper(){
PGC_DIR="${HOME}/pgcode"
status_msg "Updating PrettyGCode for Klipper ..."
cd $PGC_DIR && git pull
ok_msg "Update complete!"
}
update_MoonrakerTelegramBot(){
stop_MoonrakerTelegramBot
cd $MOONRAKERTELEGRAMBOT_DIR
@@ -184,7 +327,7 @@ update_MoonrakerTelegramBot(){
update_system(){
status_msg "Updating System ..."
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get update --allow-releaseinfo-change && sudo apt-get upgrade -y
ok_msg "Update complete! Check the log above!"
ok_msg "KIAUH won't do any dist-upgrades!\n"
}

View File

@@ -42,13 +42,16 @@ upload_selection(){
### find all suitable logfiles for klipper
logfiles=()
if ls /tmp/klippy*.log 2>/dev/null 1>&2; then
for kl_log in $(find /tmp/klippy*.log); do
klipper_logs="${HOME}/klipper_logs/klippy*.log"
moonraker_logs="${HOME}/klipper_logs/moonraker*.log"
if ls $klipper_logs 2>/dev/null 1>&2; then
for kl_log in $(find $klipper_logs); do
logfiles+=($kl_log)
done
fi
if ls /tmp/moonraker*.log 2>/dev/null 1>&2; then
for mr_log in $(find /tmp/moonraker*.log); do
if ls $moonraker_logs 2>/dev/null 1>&2; then
for mr_log in $(find $moonraker_logs); do
logfiles+=($mr_log)
done
fi