mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-11 17:44:28 +05:00
Merge branch 'dev-2.0'
This commit is contained in:
101
README.md
101
README.md
@@ -2,54 +2,93 @@
|
||||
|
||||
## Klipper Installation And Update Helper
|
||||
|
||||
This script was actually created for my personal use only but i then decided to make the script accessible for everyone.
|
||||
It is meant to help guiding you through a complete fresh install of Klipper and optionally the DWC2 web UI + DWC2-for-Klipper.
|
||||
There are also functions for updating your current installations or removing them from your system.
|
||||
### ( THIS VERSION IS STILL WORK IN PROGRESS! )
|
||||
|
||||
## First things first: When you decide to use this script, you use it at your own risk!
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
Although i implemented backup-functions for pretty much everything and tested this script extensively with my available (yet limited) hardware before releasing it, it doesn't mean that it will work 100% perfect for everyone out there. Please keep that in mind!
|
||||
## First things first: If you decide to use this script, be aware you are using it at your own risk!
|
||||
|
||||
Give it a try if you want and if you have suggestions or encounter any problems, please report them. But i can't guarantee that i will fix them immediately (or at all).
|
||||
|
||||
[](https://abload.de/image.php?img=putty_20-05-22_18-49-1nkaa.png)
|
||||
Give it a try if you want and if you have suggestions or encounter any problems, please report them to me.
|
||||
|
||||
## Instructions:
|
||||
If you don't have git already installed, please install it first:
|
||||
`sudo apt-get install git -y`
|
||||
|
||||
After you made sure to have git installed, use the following commands in the given order to download and execute the script.
|
||||
```
|
||||
If you haven't git already installed on your machine run `sudo apt-get install git -y` to install git first. You will need it anyways!
|
||||
|
||||
After you have successfully installed git, use the following commands in the given order to download and execute the script.
|
||||
|
||||
```shell
|
||||
cd ~
|
||||
git clone https://github.com/th33xitus/kiauh.git
|
||||
cd ~/kiauh
|
||||
chmod +x kiauh.sh
|
||||
cd kiauh
|
||||
chmod +x ~/kiauh/kiauh.sh
|
||||
chmod +x ~/kiauh/scripts/*
|
||||
./kiauh.sh
|
||||
```
|
||||
|
||||
## Restrictions:
|
||||
* Tested only on Raspbian Buster Lite
|
||||
## Notes:
|
||||
|
||||
## Functions and features:
|
||||
* Install Klipper + DWC2-for-klipper + DWC2 from scratch
|
||||
* Check the status of your installations
|
||||
* Update, backup and remove existing installations
|
||||
* Building firmware
|
||||
* Flashing firmware to your MCU
|
||||
* Grabbing the printer-ID of your connected printer
|
||||
* Writing the printer-ID to your printer.cfg
|
||||
* Writing the DWC2-for-Klipper example config to your printer.cfg
|
||||
- Tested only on Raspbian Buster Lite
|
||||
- During the use of this script you will be asked for your sudo password. There are several functions involved which need sudo privileges.
|
||||
- Prevent simultaneous use of DWC2 and OctoPrint if possible. There have been reports that DWC2 does strange things while the OctoPrint service is running while using the DWC2 webinterface. The script disables an existing OctoPrint service when installing DWC2. However, the service can also be reactivated with the script!
|
||||
- If you used Mainsail v0.0.12 before and you want to upgrade to v0.1.0 or later, you have to reinstall Moonraker as well! Mainsail v0.1.0 will not work with the old Moonraker service. Don't worry, the script can handle the proper removal of the old version.
|
||||
|
||||
## Functions and Features:
|
||||
|
||||
### Core Functions:
|
||||
|
||||
- **Install:** Klipper Firmware, dwc2-for-klipper + Duet Web Control, Moonraker + Mainsail, OctoPrint
|
||||
- **Update:** Klipper Firmware, dwc2-for-klipper + Duet Web Control, Moonraker + Mainsail
|
||||
- **Backup:** Klipper Firmware, dwc2-for-klipper + Duet Web Control, Moonraker + Mainsail, OctoPrint
|
||||
- **Remove:** Klipper Firmware, dwc2-for-klipper + 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: Can i install octoprint with this script?*__
|
||||
**_Q: Can i install octoprint with this script?_**
|
||||
|
||||
**A:** No, and i don't plan to implement this function
|
||||
**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
|
||||
|
||||
**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.
|
||||
|
||||
7
kiauh.ini
Normal file
7
kiauh.ini
Normal file
@@ -0,0 +1,7 @@
|
||||
#don't edit this file if you don't know what you are doing...
|
||||
backup_before_update=false
|
||||
previous_origin_state=0
|
||||
previous_smoothing_state=0
|
||||
previous_shaping_state=0
|
||||
previous_moonraker_state=0
|
||||
previous_dev_moonraker_state=0
|
||||
26
resources/dwc2_nginx.cfg
Normal file
26
resources/dwc2_nginx.cfg
Normal file
@@ -0,0 +1,26 @@
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
|
||||
upstream dwc2 {
|
||||
server 127.0.0.1:4750;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
#listen [::]:80;
|
||||
|
||||
location / {
|
||||
proxy_pass http://dwc2/;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Scheme $scheme;
|
||||
#proxy_set_header X-Script-Name /;
|
||||
proxy_http_version 1.1;
|
||||
client_max_body_size 0;
|
||||
}
|
||||
}
|
||||
82
resources/mainsail_nginx.cfg
Normal file
82
resources/mainsail_nginx.cfg
Normal file
@@ -0,0 +1,82 @@
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
|
||||
upstream apiserver {
|
||||
#edit your api port here
|
||||
ip_hash;
|
||||
server 127.0.0.1:7125;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
#listen [::]:80; # no ipv6 support in mainsail yet!
|
||||
|
||||
access_log /var/log/nginx/mainsail-access.log;
|
||||
error_log /var/log/nginx/mainsail-error.log;
|
||||
|
||||
#web_path from mainsail static files
|
||||
root /home/pi/mainsail;
|
||||
|
||||
index index.html;
|
||||
server_name _;
|
||||
|
||||
#max upload size for gcodes
|
||||
client_max_body_size 200M;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location /printer {
|
||||
proxy_pass http://apiserver/printer;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Scheme $scheme;
|
||||
}
|
||||
|
||||
location /api {
|
||||
proxy_pass http://apiserver/api;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Scheme $scheme;
|
||||
}
|
||||
|
||||
location /access {
|
||||
proxy_pass http://apiserver/access;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Scheme $scheme;
|
||||
}
|
||||
|
||||
location /websocket {
|
||||
proxy_pass http://apiserver/websocket;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_read_timeout 86400;
|
||||
}
|
||||
|
||||
location /machine {
|
||||
proxy_pass http://apiserver/machine;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Scheme $scheme;
|
||||
}
|
||||
|
||||
location /server {
|
||||
proxy_pass http://apiserver/server;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Scheme $scheme;
|
||||
}
|
||||
}
|
||||
10
resources/octoprint_config.cfg
Normal file
10
resources/octoprint_config.cfg
Normal file
@@ -0,0 +1,10 @@
|
||||
serial:
|
||||
additionalPorts:
|
||||
- /tmp/printer
|
||||
disconnectOnErrors: false
|
||||
port: /tmp/printer
|
||||
server:
|
||||
commands:
|
||||
serverRestartCommand: sudo service octoprint restart
|
||||
systemRestartCommand: sudo shutdown -r now
|
||||
systemShutdownCommand: sudo shutdown -h now
|
||||
40
resources/octoprint_nginx.cfg
Normal file
40
resources/octoprint_nginx.cfg
Normal file
@@ -0,0 +1,40 @@
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
|
||||
upstream octoprint {
|
||||
server 127.0.0.1:5000;
|
||||
}
|
||||
|
||||
upstream mjpg-streamer {
|
||||
server 127.0.0.1:8080;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
#listen [::]:80;
|
||||
|
||||
location / {
|
||||
proxy_pass http://octoprint/;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Scheme $scheme;
|
||||
#proxy_set_header X-Script-Name /;
|
||||
proxy_http_version 1.1;
|
||||
client_max_body_size 0;
|
||||
}
|
||||
|
||||
location /webcam {
|
||||
proxy_pass http://mjpg-streamer/;
|
||||
}
|
||||
|
||||
# redirect server error pages to the static page /50x.html
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root html;
|
||||
}
|
||||
}
|
||||
BIN
resources/screenshots/advanced.png
Normal file
BIN
resources/screenshots/advanced.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
BIN
resources/screenshots/main.png
Normal file
BIN
resources/screenshots/main.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
BIN
resources/screenshots/remove.png
Normal file
BIN
resources/screenshots/remove.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
BIN
resources/screenshots/update.png
Normal file
BIN
resources/screenshots/update.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
102
scripts/backup.sh
Normal file
102
scripts/backup.sh
Normal file
@@ -0,0 +1,102 @@
|
||||
check_for_backup_dir(){
|
||||
if [ ! -d $BACKUP_DIR ]; then
|
||||
status_msg "Create backup directory ..."
|
||||
mkdir -p $BACKUP_DIR && ok_msg "Directory created!"
|
||||
fi
|
||||
}
|
||||
|
||||
backup_printer_cfg(){
|
||||
check_for_backup_dir
|
||||
if [ -f $PRINTER_CFG ]; then
|
||||
get_date
|
||||
status_msg "Create backup of printer.cfg ..."
|
||||
cp $PRINTER_CFG $BACKUP_DIR/printer.cfg."$current_date".backup && ok_msg "Backup created!"
|
||||
else
|
||||
ok_msg "No printer.cfg found! Skipping backup ..."
|
||||
fi
|
||||
}
|
||||
|
||||
read_bb4u_stat(){
|
||||
source_ini
|
||||
if [ ! "$backup_before_update" = "true" ]; then
|
||||
BB4U_STATUS="${green}[Enable]${default} backups before updating "
|
||||
else
|
||||
BB4U_STATUS="${red}[Disable]${default} backups before updating "
|
||||
fi
|
||||
}
|
||||
|
||||
toggle_backups(){
|
||||
source_ini
|
||||
if [ "$backup_before_update" = "true" ]; then
|
||||
sed -i '/backup_before_update=/s/true/false/' $INI_FILE
|
||||
BB4U_STATUS="${green}[Enable]${default} backups before updating "
|
||||
CONFIRM_MSG=" Backups before updates are now >>> DISABLED <<< !"
|
||||
fi
|
||||
if [ "$backup_before_update" = "false" ]; then
|
||||
sed -i '/backup_before_update=/s/false/true/' $INI_FILE
|
||||
BB4U_STATUS="${red}[Disable]${default} backups before updating "
|
||||
CONFIRM_MSG=" Backups before updates are now >>> ENABLED <<< !"
|
||||
fi
|
||||
}
|
||||
|
||||
bb4u(){
|
||||
source_ini
|
||||
if [ "$backup_before_update" = "true" ]; then
|
||||
backup_$1
|
||||
fi
|
||||
}
|
||||
|
||||
backup_klipper(){
|
||||
if [ -d $KLIPPER_DIR ] && [ -d $KLIPPY_ENV_DIR ]; then
|
||||
status_msg "Creating Klipper backup ..."
|
||||
check_for_backup_dir
|
||||
get_date
|
||||
status_msg "Timestamp: $current_date"
|
||||
mkdir -p $BACKUP_DIR/klipper-backups/"$current_date"
|
||||
cp -r $KLIPPER_DIR $_ && cp -r $KLIPPY_ENV_DIR $_
|
||||
ok_msg "Backup complete!"
|
||||
else
|
||||
ERROR_MSG=" Can't backup klipper and/or klipper-env directory! Not found!"
|
||||
fi
|
||||
}
|
||||
|
||||
backup_dwc2(){
|
||||
if [ -d $DWC2FK_DIR ] && [ -d $DWC2_DIR ]; then
|
||||
status_msg "Creating DWC2 Web UI backup ..."
|
||||
check_for_backup_dir
|
||||
get_date
|
||||
status_msg "Timestamp: $current_date"
|
||||
mkdir -p $BACKUP_DIR/dwc2-backups/"$current_date"
|
||||
cp -r $DWC2FK_DIR $_ && cp -r $DWC2_DIR $_
|
||||
ok_msg "Backup complete!"
|
||||
else
|
||||
ERROR_MSG=" Can't backup dwc2-for-klipper and/or dwc2 directory!\n Not found!"
|
||||
fi
|
||||
}
|
||||
|
||||
backup_mainsail(){
|
||||
if [ -d $MAINSAIL_DIR ]; then
|
||||
status_msg "Creating Mainsail backup ..."
|
||||
check_for_backup_dir
|
||||
get_date
|
||||
status_msg "Timestamp: $current_date"
|
||||
mkdir -p $BACKUP_DIR/mainsail-backups/"$current_date"
|
||||
cp -r $MAINSAIL_DIR $_ && ok_msg "Backup complete!"
|
||||
else
|
||||
ERROR_MSG=" Can't backup mainsail directory! Not found!"
|
||||
fi
|
||||
}
|
||||
|
||||
backup_octoprint(){
|
||||
if [ -d $OCTOPRINT_DIR ] && [ -d $OCTOPRINT_CFG_DIR ]; then
|
||||
status_msg "Creating OctoPrint backup ..."
|
||||
check_for_backup_dir
|
||||
get_date
|
||||
status_msg "Timestamp: $current_date"
|
||||
mkdir -p $BACKUP_DIR/octoprint-backups/"$current_date"
|
||||
cp -r $OCTOPRINT_DIR $_ && cp -r $OCTOPRINT_CFG_DIR $_
|
||||
ok_msg "Backup complete!"
|
||||
else
|
||||
ERROR_MSG=" Can't backup OctoPrint and/or .octoprint directory!\n Not found!"
|
||||
fi
|
||||
}
|
||||
354
scripts/functions.sh
Normal file
354
scripts/functions.sh
Normal file
@@ -0,0 +1,354 @@
|
||||
# setting up some frequently used functions
|
||||
check_euid(){
|
||||
if [ "$EUID" -eq 0 ]
|
||||
then
|
||||
echo -e "${red}"
|
||||
top_border
|
||||
echo -e "| !!! THIS SCRIPT MUST NOT RAN AS ROOT !!! |"
|
||||
bottom_border
|
||||
echo -e "${default}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
source_ini(){
|
||||
source ${HOME}/kiauh/kiauh.ini
|
||||
}
|
||||
|
||||
start_klipper(){
|
||||
if [ -e /etc/init.d/klipper ]; then
|
||||
status_msg "Starting Klipper Service ..."
|
||||
sudo /etc/init.d/klipper start && sleep 2 && ok_msg "Klipper Service started!"
|
||||
fi
|
||||
}
|
||||
|
||||
stop_klipper(){
|
||||
if [ -e /etc/init.d/klipper ]; then
|
||||
status_msg "Stopping Klipper Service ..."
|
||||
sudo /etc/init.d/klipper stop && sleep 2 && ok_msg "Klipper Service stopped!"
|
||||
fi
|
||||
}
|
||||
|
||||
restart_klipper(){
|
||||
if [ -e /etc/init.d/klipper ]; then
|
||||
status_msg "Restarting Klipper Service ..."
|
||||
sudo /etc/init.d/klipper restart && sleep 2 && ok_msg "Klipper Service restarted!"
|
||||
fi
|
||||
}
|
||||
|
||||
start_moonraker(){
|
||||
if [ -e /etc/init.d/moonraker ]; then
|
||||
status_msg "Starting Moonraker Service ..."
|
||||
sudo /etc/init.d/moonraker start && sleep 2 && ok_msg "Moonraker Service started!"
|
||||
fi
|
||||
}
|
||||
|
||||
stop_moonraker(){
|
||||
if [ -e /etc/init.d/moonraker ]; then
|
||||
status_msg "Stopping Moonraker Service ..."
|
||||
sudo /etc/init.d/moonraker stop && sleep 2 && ok_msg "Moonraker Service stopped!"
|
||||
fi
|
||||
}
|
||||
|
||||
restart_moonraker(){
|
||||
if [ -e /etc/init.d/moonraker ]; then
|
||||
status_msg "Restarting Moonraker Service ..."
|
||||
sudo /etc/init.d/moonraker restart && sleep 2 && ok_msg "Moonraker Service restarted!"
|
||||
fi
|
||||
}
|
||||
|
||||
start_octoprint(){
|
||||
if [ -e /etc/init.d/octoprint ]; then
|
||||
status_msg "Starting OctoPrint Service ..."
|
||||
sudo /etc/init.d/octoprint start && sleep 2 && ok_msg "OctoPrint Service started!"
|
||||
fi
|
||||
}
|
||||
|
||||
stop_octoprint(){
|
||||
if [ -e /etc/init.d/octoprint ]; then
|
||||
status_msg "Stopping OctoPrint Service ..."
|
||||
sudo /etc/init.d/octoprint stop && sleep 2 && ok_msg "OctoPrint Service stopped!"
|
||||
fi
|
||||
}
|
||||
|
||||
restart_octoprint(){
|
||||
if [ -e /etc/init.d/octoprint ]; then
|
||||
status_msg "Restarting OctoPrint Service ..."
|
||||
sudo /etc/init.d/octoprint restart && sleep 2 && ok_msg "OctoPrint Service restarted!"
|
||||
fi
|
||||
}
|
||||
|
||||
restart_nginx(){
|
||||
if [ -e /etc/init.d/nginx ]; then
|
||||
status_msg "Restarting Nginx Service ..."
|
||||
sudo /etc/init.d/nginx restart && sleep 2 && ok_msg "Nginx Service restarted!"
|
||||
fi
|
||||
}
|
||||
|
||||
dependency_check(){
|
||||
status_msg "Checking for dependencies ..."
|
||||
#check if package is installed, if not write name into array
|
||||
for pkg in "${dep[@]}"
|
||||
do
|
||||
if [[ ! $(dpkg-query -f'${Status}' --show $pkg 2>/dev/null) = *\ installed ]]; then
|
||||
inst+=($pkg)
|
||||
fi
|
||||
done
|
||||
#if array is not empty, install packages from array elements
|
||||
if [ "${#inst[@]}" != "0" ]; then
|
||||
status_msg "Installing the following dependencies:"
|
||||
for element in ${inst[@]}
|
||||
do
|
||||
echo -e "${cyan}● $element ${default}"
|
||||
done
|
||||
echo
|
||||
sudo apt-get install ${inst[@]} -y
|
||||
ok_msg "Dependencies installed!"
|
||||
#clearing the array
|
||||
unset inst
|
||||
else
|
||||
ok_msg "Dependencies already met! Continue..."
|
||||
fi
|
||||
}
|
||||
|
||||
print_error(){
|
||||
for data in "${data_arr[@]}"
|
||||
do
|
||||
if [ ! -e $data ]; then
|
||||
data_count+=(0)
|
||||
else
|
||||
data_count+=(1)
|
||||
fi
|
||||
done
|
||||
sum=$(IFS=+; echo "$((${data_count[*]}))")
|
||||
if [ $sum -eq 0 ]; then
|
||||
ERROR_MSG=" Looks like $1 was already removed!\n Skipping..."
|
||||
else
|
||||
ERROR_MSG=""
|
||||
fi
|
||||
}
|
||||
|
||||
build_fw(){
|
||||
if [ -d $KLIPPER_DIR ]; then
|
||||
cd $KLIPPER_DIR && make menuconfig
|
||||
status_msg "Building Firmware ..."
|
||||
make clean && make && ok_msg "Firmware built!"
|
||||
else
|
||||
warn_msg "Can not build Firmware without a Klipper directory!"
|
||||
fi
|
||||
}
|
||||
|
||||
### grab the printers id
|
||||
get_usb_id(){
|
||||
warn_msg "Make sure your printer is the only USB device connected!"
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "###### Press any key to continue ... " yn
|
||||
echo -e "${default}"
|
||||
case "$yn" in
|
||||
*) break;;
|
||||
esac
|
||||
done
|
||||
status_msg "Identifying the correct USB port ..."
|
||||
USB_ID=$(ls /dev/serial/by-id/*)
|
||||
if [ -e /dev/serial/by-id/* ]; then
|
||||
status_msg "The ID of your printer is:"
|
||||
title_msg "$USB_ID"
|
||||
else
|
||||
warn_msg "Could not retrieve ID!"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
write_printer_id(){
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "###### Do you want to write the ID to your printer.cfg? (Y/n): " yn
|
||||
echo -e "${default}"
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
backup_printer_cfg
|
||||
cat <<PRINTERID >> $PRINTER_CFG
|
||||
|
||||
##########################
|
||||
### CREATED WITH KIAUH ###
|
||||
##########################
|
||||
[mcu]
|
||||
serial: $USB_ID
|
||||
##########################
|
||||
##########################
|
||||
PRINTERID
|
||||
ok_msg "Config written!"
|
||||
break;;
|
||||
N|n|No|no) break;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
flash_routine(){
|
||||
echo -e "/=================================================\ "
|
||||
echo -e "| ${red}~~~~~~~~~~~ [ ATTENTION! ] ~~~~~~~~~~~~${default} |"
|
||||
echo -e "| Flashing a Smoothie based board for the first |"
|
||||
echo -e "| time with this script will certainly fail. |"
|
||||
echo -e "| This applies to boards like the BTT SKR V1.3 or |"
|
||||
echo -e "| the newer SKR V1.4 (Turbo). You have to copy |"
|
||||
echo -e "| the firmware file to the microSD card manually |"
|
||||
echo -e "| and rename it to 'firmware.bin'. |"
|
||||
echo -e "| |"
|
||||
echo -e "| You find the file in: ~/klipper/out/klipper.bin |"
|
||||
echo -e "\=================================================/ "
|
||||
echo
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "###### Do you want to continue? (Y/n): " yn
|
||||
echo -e "${default}"
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
get_usb_id && flash_mcu && write_printer_id; break;;
|
||||
N|n|No|no) break;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
flash_mcu(){
|
||||
stop_klipper
|
||||
if ! make flash FLASH_DEVICE="$USB_ID" ; then
|
||||
warn_msg "Flashing failed!"
|
||||
warn_msg "Please read the log above!"
|
||||
else
|
||||
ok_msg "Flashing successfull!"
|
||||
fi
|
||||
start_klipper
|
||||
}
|
||||
|
||||
enable_octoprint_service(){
|
||||
if [[ -f $OCTOPRINT_SERVICE1 && -f $OCTOPRINT_SERVICE2 ]]; then
|
||||
status_msg "OctoPrint Service is disabled! Enabling now ..."
|
||||
sudo systemctl enable octoprint -q && sudo systemctl start octoprint
|
||||
fi
|
||||
}
|
||||
|
||||
disable_octoprint_service(){
|
||||
if [[ -f $OCTOPRINT_SERVICE1 && -f $OCTOPRINT_SERVICE2 ]]; then
|
||||
status_msg "OctoPrint Service is enabled! Disabling now ..."
|
||||
sudo systemctl stop octoprint && sudo systemctl disable octoprint -q
|
||||
fi
|
||||
}
|
||||
|
||||
toggle_octoprint_service(){
|
||||
if [[ -f $OCTOPRINT_SERVICE1 && -f $OCTOPRINT_SERVICE2 ]]; then
|
||||
if systemctl is-enabled octoprint.service -q; then
|
||||
disable_octoprint_service
|
||||
sleep 2
|
||||
CONFIRM_MSG=" OctoPrint Service is now >>> DISABLED <<< !"
|
||||
else
|
||||
enable_octoprint_service
|
||||
sleep 2
|
||||
CONFIRM_MSG=" OctoPrint Service is now >>> ENABLED <<< !"
|
||||
fi
|
||||
else
|
||||
ERROR_MSG=" You cannot activate a service that does not exist!"
|
||||
fi
|
||||
}
|
||||
|
||||
read_octoprint_service_status(){
|
||||
if ! systemctl is-enabled octoprint.service -q &>/dev/null; then
|
||||
OPRINT_SERVICE_STATUS="${green}[Enable]${default} OctoPrint Service "
|
||||
else
|
||||
OPRINT_SERVICE_STATUS="${red}[Disable]${default} OctoPrint Service "
|
||||
fi
|
||||
}
|
||||
|
||||
create_reverse_proxy(){
|
||||
#check for dependencies
|
||||
dep=(nginx)
|
||||
dependency_check
|
||||
#execute operations
|
||||
status_msg "Creating Nginx configuration for $1 ..."
|
||||
cat ${HOME}/kiauh/resources/$1_nginx.cfg > ${HOME}/kiauh/resources/$1
|
||||
sudo mv ${HOME}/kiauh/resources/$1 /etc/nginx/sites-available/$1
|
||||
#ONLY FOR MAINSAIL: replace username if not "pi"
|
||||
if [ "$1" = "mainsail" ]; then
|
||||
sudo sed -i "/root/s/pi/${USER}/" /etc/nginx/sites-available/mainsail
|
||||
fi
|
||||
ok_msg "Nginx configuration for $1 was set!"
|
||||
#remove default config
|
||||
if [ -e /etc/nginx/sites-enabled/default ]; then
|
||||
sudo rm /etc/nginx/sites-enabled/default
|
||||
fi
|
||||
#create symlink for own configs
|
||||
if [ ! -e /etc/nginx/sites-enabled/$1 ]; then
|
||||
sudo ln -s /etc/nginx/sites-available/$1 /etc/nginx/sites-enabled/
|
||||
fi
|
||||
restart_nginx
|
||||
}
|
||||
|
||||
create_custom_hostname(){
|
||||
echo
|
||||
top_border
|
||||
echo -e "| You can change the hostname of this machine to use |"
|
||||
echo -e "| that name to open the Interface in your browser. |"
|
||||
echo -e "| |"
|
||||
echo -e "| Example: If you set the hostname to 'my-printer' |"
|
||||
echo -e "| you can open Mainsail/Octoprint by |"
|
||||
echo -e "| browsing to: http://my-printer.local |"
|
||||
bottom_border
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "###### Do you want to change the hostname? (Y/n): " yn
|
||||
echo -e "${default}"
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"") set_hostname; break;;
|
||||
N|n|No|no) break;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
set_hostname(){
|
||||
#check for dependencies
|
||||
dep=(avahi-daemon)
|
||||
dependency_check
|
||||
#execute operations
|
||||
#get current hostname and write to variable
|
||||
HOSTNAME=$(hostname)
|
||||
#create host file if missing or create backup of existing one with current date&time
|
||||
if [ -f /etc/hosts ]; then
|
||||
status_msg "Creating backup of hosts file ..."
|
||||
get_date
|
||||
sudo cp /etc/hosts /etc/hosts."$current_date".bak
|
||||
ok_msg "Backup done!"
|
||||
ok_msg "File:'/etc/hosts."$current_date".bak'"
|
||||
else
|
||||
sudo touch /etc/hosts
|
||||
fi
|
||||
echo
|
||||
top_border
|
||||
echo -e "| ${green}Allowed characters: a-z, 0-9 and single '-'${default} |"
|
||||
echo -e "| ${red}No special characters allowed!${default} |"
|
||||
echo -e "| ${red}No leading or trailing '-' allowed!${default} |"
|
||||
bottom_border
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "###### Please set the new hostname: " NEW_HOSTNAME
|
||||
echo -e "${default}"
|
||||
if [[ $NEW_HOSTNAME =~ ^[^\-]+([0-9a-z]\-{0,1})+[^\-]+$ ]]; then
|
||||
ok_msg "'$NEW_HOSTNAME' is a valid hostname!"
|
||||
#set hostname in /etc/hostname
|
||||
status_msg "Setting hostname to '$NEW_HOSTNAME' ..."
|
||||
status_msg "Please wait ..."
|
||||
sudo hostnamectl set-hostname $NEW_HOSTNAME
|
||||
#write new hostname to /etc/hosts
|
||||
status_msg "Writing new hostname to /etc/hosts ..."
|
||||
if cat /etc/hosts | grep "###set by kiauh" &>/dev/null; then
|
||||
sudo sed -i "/###set by kiauh/s/\<$HOSTNAME\>/$NEW_HOSTNAME/" /etc/hosts
|
||||
else
|
||||
echo "127.0.0.1 $NEW_HOSTNAME ###set by kiauh" | sudo tee -a /etc/hosts &>/dev/null
|
||||
fi
|
||||
ok_msg "New hostname successfully configured!"
|
||||
ok_msg "Remember to reboot your machine for the changes to take effect!"
|
||||
break
|
||||
else
|
||||
warn_msg "'$NEW_HOSTNAME' is not a valid hostname!"
|
||||
fi
|
||||
done
|
||||
}
|
||||
171
scripts/install_dwc2.sh
Normal file
171
scripts/install_dwc2.sh
Normal file
@@ -0,0 +1,171 @@
|
||||
#TODO:
|
||||
# - ask for permission to disable octoprint service
|
||||
|
||||
dwc2_install_routine(){
|
||||
if [ -d $KLIPPER_DIR ]; then
|
||||
# check for existing installation
|
||||
if [ -d $DWC2FK_DIR ] && [ -d $DWC2_DIR ]; then
|
||||
ERROR_MSG=" Looks like DWC2 is already installed!\n Skipping..."
|
||||
return
|
||||
fi
|
||||
stop_klipper
|
||||
#disable octoprint service if installed
|
||||
if systemctl is-enabled octoprint.service -q 2>/dev/null; then
|
||||
disable_octoprint_service
|
||||
fi
|
||||
install_tornado
|
||||
install_dwc2fk && dwc2fk_cfg
|
||||
install_dwc2
|
||||
dwc2_reverse_proxy_dialog
|
||||
create_custom_hostname
|
||||
start_klipper
|
||||
else
|
||||
ERROR_MSG=" Please install Klipper first!\n Skipping..."
|
||||
fi
|
||||
}
|
||||
|
||||
install_tornado(){
|
||||
if [ "$(cd $KLIPPY_ENV_DIR/bin/ && $_/pip list 2>/dev/null | grep "tornado" | cut -d" " -f9)" = "5.1.1" ]; then
|
||||
ok_msg "Tornado 5.1.1 is already installed! Continue..."
|
||||
else
|
||||
status_msg "Installing Tornado 5.1.1 ..."
|
||||
cd ${HOME}
|
||||
PYTHONDIR="${HOME}/klippy-env"
|
||||
virtualenv ${PYTHONDIR}
|
||||
${PYTHONDIR}/bin/pip install tornado==5.1.1
|
||||
ok_msg "Tornado 5.1.1 successfully installed!"
|
||||
fi
|
||||
}
|
||||
|
||||
install_dwc2fk(){
|
||||
cd ${HOME}
|
||||
status_msg "Cloning DWC2-for-Klipper repository ..."
|
||||
git clone $DWC2FK_REPO && ok_msg "DWC2-for-Klipper successfully cloned!"
|
||||
#create a web_dwc2.py symlink if not already existing
|
||||
if [ -d $KLIPPER_DIR/klippy/extras ] && [ ! -e $KLIPPER_DIR/klippy/extras/web_dwc2.py ]; then
|
||||
status_msg "Creating web_dwc2.py Symlink ..."
|
||||
ln -s $DWC2FK_DIR/web_dwc2.py $KLIPPER_DIR/klippy/extras/web_dwc2.py && ok_msg "Symlink created!"
|
||||
fi
|
||||
}
|
||||
|
||||
dwc2fk_cfg(){
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "###### Do you want to create the config now? (Y/n): " yn
|
||||
echo -e "${default}"
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"") create_dwc2fk_cfg; break;;
|
||||
N|n|No|no) break;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
create_dwc2fk_cfg(){
|
||||
echo -e "/=================================================\ "
|
||||
echo -e "| 1) [Default configuration] | "
|
||||
echo -e "| 2) [Custom configuration] | "
|
||||
echo -e "| 3) [Skip] | "
|
||||
echo -e "\=================================================/ "
|
||||
while true; do
|
||||
read -p "Please select: " choice; echo
|
||||
case "$choice" in
|
||||
1) dwc2fk_default_cfg && ok_msg "Config written ..."; break;;
|
||||
2) create_dwc2fk_custom_cfg && ok_msg "Config written ..."; break;;
|
||||
3) echo "Skipping ..."; break;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
dwc2fk_default_cfg(){
|
||||
cat <<DWC2 >> $PRINTER_CFG
|
||||
|
||||
##########################
|
||||
### CREATED WITH KIAUH ###
|
||||
##########################
|
||||
[virtual_sdcard]
|
||||
path: ~/sdcard
|
||||
|
||||
[web_dwc2]
|
||||
printer_name: my_printer
|
||||
listen_adress: 0.0.0.0
|
||||
listen_port: 4750
|
||||
web_path: dwc2/web
|
||||
##########################
|
||||
##########################
|
||||
DWC2
|
||||
}
|
||||
|
||||
create_dwc2fk_custom_cfg(){
|
||||
echo -e "${cyan}"
|
||||
read -e -p "Printer name: " -i "my_printer" PRINTER_NAME
|
||||
read -e -p "Listen adress: " -i "0.0.0.0" LISTEN_ADRESS
|
||||
read -e -p "Listen port: " -i "4750" LISTEN_PORT
|
||||
read -e -p "Web path: " -i "dwc2/web" WEB_PATH
|
||||
echo -e "${default}"
|
||||
DWC2_CFG=$(cat <<DWC2
|
||||
|
||||
##########################
|
||||
### CREATED WITH KIAUH ###
|
||||
##########################
|
||||
[virtual_sdcard]
|
||||
path: ~/sdcard
|
||||
|
||||
[web_dwc2]
|
||||
printer_name: $PRINTER_NAME
|
||||
listen_adress: $LISTEN_ADRESS
|
||||
listen_port: $LISTEN_PORT
|
||||
web_path: $WEB_PATH
|
||||
##########################
|
||||
##########################
|
||||
DWC2
|
||||
)
|
||||
echo "The following lines will be written:"
|
||||
echo -e "$DWC2_CFG"
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "###### Write now (Y) or start over (n)? (Y/n): " yn
|
||||
echo -e "${default}"
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"") echo -e "$DWC2_CFG" >> $PRINTER_CFG; break;;
|
||||
N|n|No|no) create_dwc2fk_custom_cfg;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
install_dwc2(){
|
||||
#check dependencies
|
||||
dep=(wget gzip tar curl)
|
||||
dependency_check
|
||||
#execute operation
|
||||
GET_DWC2_URL=`curl -s https://api.github.com/repositories/28820678/releases/latest | grep browser_download_url | cut -d'"' -f4`
|
||||
if [ ! -d $DWC2_DIR/web ]; then
|
||||
mkdir -p $DWC2_DIR/web
|
||||
fi
|
||||
cd $DWC2_DIR/web
|
||||
status_msg "Downloading DWC2 Web UI ..."
|
||||
wget -q $GET_DWC2_URL && ok_msg "Download complete!"
|
||||
status_msg "Unzipping archive ..."
|
||||
unzip -q -o *.zip && for f_ in $(find . | grep '.gz');do gunzip -f ${f_};done && ok_msg "Done!"
|
||||
status_msg "Writing version to file ..."
|
||||
echo $GET_DWC2_URL | cut -d/ -f8 > $DWC2_DIR/web/version && ok_msg "Done!"
|
||||
status_msg "Do a little cleanup ..."
|
||||
rm -rf DuetWebControl-SD.zip && ok_msg "Done!"
|
||||
ok_msg "DWC2 Web UI installed!"
|
||||
}
|
||||
|
||||
dwc2_reverse_proxy_dialog(){
|
||||
top_border
|
||||
echo -e "| If you want to have a nicer URL or simply need/want | "
|
||||
echo -e "| DWC2 to run on port 80 (http's default port) you | "
|
||||
echo -e "| can set up a reverse proxy to run DWC2 on port 80. | "
|
||||
bottom_border
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "###### Do you want to set up a reverse proxy now? (Y/n): " yn
|
||||
echo -e "${default}"
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"") create_reverse_proxy "dwc2"; break;;
|
||||
N|n|No|no) break;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
29
scripts/install_klipper.sh
Normal file
29
scripts/install_klipper.sh
Normal file
@@ -0,0 +1,29 @@
|
||||
install_klipper(){
|
||||
if [ -e /etc/init.d/klipper ] && [ -e /etc/default/klipper ]; then
|
||||
ERROR_MSG=" Looks like Klipper is already installed!\n Skipping ..."
|
||||
else
|
||||
#check for dependencies
|
||||
dep=(git)
|
||||
dependency_check
|
||||
#execute operation
|
||||
cd ${HOME}
|
||||
status_msg "Cloning Klipper repository ..."
|
||||
git clone $KLIPPER_REPO && ok_msg "Klipper successfully cloned!"
|
||||
status_msg "Installing Klipper Service ..."
|
||||
$KLIPPER_DIR/scripts/install-octopi.sh && sleep 2 && ok_msg "Klipper installation complete!"
|
||||
#create a klippy.log symlink in home-dir just for convenience
|
||||
if [ ! -e ${HOME}/klippy.log ]; then
|
||||
status_msg "Creating klippy.log Symlink ..."
|
||||
ln -s /tmp/klippy.log ${HOME}/klippy.log && ok_msg "Symlink created!"
|
||||
fi
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "###### Do you want to flash your MCU now? (Y/n): " yn
|
||||
echo -e "${default}"
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"") build_fw && flash_routine; break;;
|
||||
N|n|No|no) break;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
}
|
||||
249
scripts/install_mainsail.sh
Normal file
249
scripts/install_mainsail.sh
Normal file
@@ -0,0 +1,249 @@
|
||||
mainsail_install_routine(){
|
||||
ERROR="0" #reset error state
|
||||
if [ -d $KLIPPER_DIR ]; then
|
||||
#disable octoprint service if installed
|
||||
if systemctl is-enabled octoprint.service -q 2>/dev/null; then
|
||||
disable_octoprint_service
|
||||
fi
|
||||
disable_haproxy_lighttpd
|
||||
remove_haproxy_lighttpd
|
||||
install_moonraker
|
||||
if [ "$ERROR" != "1" ]; then
|
||||
check_printer_cfg
|
||||
restart_moonraker
|
||||
restart_klipper
|
||||
create_reverse_proxy "mainsail"
|
||||
test_api
|
||||
test_nginx
|
||||
install_mainsail
|
||||
create_custom_hostname
|
||||
ok_msg "Mainsail installation complete!"; echo
|
||||
fi
|
||||
else
|
||||
ERROR_MSG=" Please install Klipper first!\n Skipping..."
|
||||
fi
|
||||
}
|
||||
|
||||
install_moonraker(){
|
||||
cd $KLIPPER_DIR
|
||||
if [[ $(git describe --all) = "remotes/Arksine/dev-moonraker-testing" ]]; then
|
||||
dep=(wget curl unzip)
|
||||
dependency_check
|
||||
status_msg "Downloading Moonraker ..."
|
||||
cd ${HOME} && git clone $MOONRAKER_REPO
|
||||
ok_msg "Download complete!"
|
||||
status_msg "Installing Moonraker ..."
|
||||
$MOONRAKER_DIR/scripts/install-moonraker.sh && ok_msg "Moonraker successfully installed!"
|
||||
#create sdcard folder if it doesn't exists yet
|
||||
if [ ! -d ${HOME}/sdcard ]; then
|
||||
mkdir ${HOME}/sdcard
|
||||
fi
|
||||
#create a moonraker.log symlink in home-dir just for convenience
|
||||
if [ ! -e ${HOME}/moonraker.log ]; then
|
||||
status_msg "Creating moonraker.log symlink ..."
|
||||
ln -s /tmp/moonraker.log ${HOME}/moonraker.log && ok_msg "Symlink created!"
|
||||
fi
|
||||
else
|
||||
ERROR_MSG=" You are not using the Moonraker fork\n Please switch to the Moonraker fork first! Aborting ..."
|
||||
ERROR=1
|
||||
fi
|
||||
}
|
||||
|
||||
check_printer_cfg(){
|
||||
if [ -e $PRINTER_CFG ]; then
|
||||
check_vsdcard_section
|
||||
check_api_section
|
||||
else
|
||||
echo; warn_msg "No printer.cfg found!"
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "###### Do you want to create a default config now? (Y/n): " yn
|
||||
echo -e "${default}"
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"") create_default_cfg; break;;
|
||||
N|n|No|no) break;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
check_vsdcard_section(){
|
||||
# check if virtual sdcard is present in printer.cfg
|
||||
status_msg "Checking for virtual_sdcard configuration ..."
|
||||
if [ $(grep '^\[virtual_sdcard\]$' $PRINTER_CFG) ]; then
|
||||
ok_msg "Virtual sdcard already configured!"
|
||||
else
|
||||
status_msg "No virtual sdcard entry found."
|
||||
ok_msg "Virtual sdcard entry added to printer.cfg!"
|
||||
# append the following lines to printer.cfg
|
||||
cat <<VSDCARD >> $PRINTER_CFG
|
||||
|
||||
##########################
|
||||
### CREATED WITH KIAUH ###
|
||||
##########################
|
||||
[virtual_sdcard]
|
||||
path: ~/sdcard
|
||||
##########################
|
||||
##########################
|
||||
VSDCARD
|
||||
fi
|
||||
}
|
||||
|
||||
check_api_section(){
|
||||
status_msg "Checking for moonraker configuration ..."
|
||||
# check if api server is present in printer.cfg
|
||||
if [ $(grep '^\[moonraker\]$' $PRINTER_CFG) ]; then
|
||||
ok_msg "Moonraker already configured"
|
||||
else
|
||||
status_msg "No Moonraker entry found."
|
||||
ok_msg "Moonraker entry added to printer.cfg!"
|
||||
# append the following lines to printer.cfg
|
||||
cat <<API >> $PRINTER_CFG
|
||||
|
||||
##########################
|
||||
### CREATED WITH KIAUH ###
|
||||
##########################
|
||||
[moonraker]
|
||||
trusted_clients:
|
||||
192.168.0.0/24
|
||||
192.168.1.0/24
|
||||
127.0.0.0/24
|
||||
##########################
|
||||
##########################
|
||||
API
|
||||
fi
|
||||
}
|
||||
|
||||
create_default_cfg(){
|
||||
cat <<DEFAULT_CFG >> $PRINTER_CFG
|
||||
|
||||
##########################
|
||||
### CREATED WITH KIAUH ###
|
||||
##########################
|
||||
[virtual_sdcard]
|
||||
path: ~/sdcard
|
||||
|
||||
[moonraker]
|
||||
trusted_clients:
|
||||
192.168.0.0/24
|
||||
192.168.1.0/24
|
||||
127.0.0.0/24
|
||||
|
||||
[pause_resume]
|
||||
|
||||
[gcode_macro CANCEL]
|
||||
default_parameter_X: 230
|
||||
default_parameter_Y: 230
|
||||
default_parameter_Z: 10
|
||||
gcode:
|
||||
M104 S0
|
||||
M140 S0
|
||||
M141 S0
|
||||
M106 S0
|
||||
CLEAR_PAUSE
|
||||
RESET_SD
|
||||
|
||||
[gcode_macro CANCEL_PRINT]
|
||||
gcode:
|
||||
CANCEL
|
||||
|
||||
[gcode_macro PAUSE]
|
||||
rename_existing: BASE_PAUSE
|
||||
default_parameter_X: 230
|
||||
default_parameter_Y: 230
|
||||
default_parameter_Z: 10
|
||||
gcode:
|
||||
SAVE_GCODE_STATE NAME=PAUSE_state
|
||||
BASE_PAUSE
|
||||
G91
|
||||
G1 E-1.7 F2100
|
||||
G1 Z{Z}
|
||||
G90
|
||||
G1 X{X} Y{Y} F6000
|
||||
G91
|
||||
|
||||
[gcode_macro RESUME]
|
||||
rename_existing: BASE_RESUME
|
||||
gcode:
|
||||
G91
|
||||
G1 E1.7 F2100
|
||||
G91
|
||||
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1
|
||||
BASE_RESUME
|
||||
##########################
|
||||
##########################
|
||||
DEFAULT_CFG
|
||||
}
|
||||
|
||||
disable_haproxy_lighttpd(){
|
||||
if systemctl is-active haproxy -q; then
|
||||
status_msg "Stopping haproxy service ..."
|
||||
sudo /etc/init.d/haproxy stop && ok_msg "Service stopped!"
|
||||
fi
|
||||
if systemctl is-active lighttpd -q; then
|
||||
status_msg "Stopping lighttpd service ..."
|
||||
sudo /etc/init.d/lighttpd stop && ok_msg "Service stopped!"
|
||||
fi
|
||||
}
|
||||
|
||||
remove_haproxy_lighttpd(){
|
||||
rem=(haproxy lighttpd)
|
||||
for remove in "${rem[@]}"
|
||||
do
|
||||
if [[ $(dpkg-query -f'${Status}' --show $remove 2>/dev/null) = *\ installed ]]; then
|
||||
delete+=($remove)
|
||||
fi
|
||||
done
|
||||
if ! [ ${#delete[@]} -eq 0 ]; then
|
||||
sudo apt-get remove ${delete[@]} -y
|
||||
fi
|
||||
}
|
||||
|
||||
test_api(){
|
||||
status_msg "Testing API ..."
|
||||
sleep 5
|
||||
status_msg "API response from http://localhost:7125/printer/info:"
|
||||
API_RESPONSE="$(curl -sG4 http://localhost:7125/printer/info)"
|
||||
echo -e "${cyan}$API_RESPONSE${default}"
|
||||
if [ $(curl -sG4 "http://localhost:7125/printer/info" | grep '^{"result"' -c) -eq 1 ]; then
|
||||
echo; ok_msg "Klipper API is working correctly!"; echo
|
||||
else
|
||||
echo; warn_msg "Klipper API not working correctly!"; echo
|
||||
fi
|
||||
}
|
||||
|
||||
test_nginx(){
|
||||
sudo /etc/init.d/nginx restart
|
||||
status_msg "Testing Nginx ..."
|
||||
sleep 5
|
||||
status_msg "API response from http://localhost/printer/info:"
|
||||
API_RESPONSE="$(curl -sG4 http://localhost/printer/info)"
|
||||
echo -e "${cyan}$API_RESPONSE${default}"
|
||||
if [ $(curl -sG4 "http://localhost/printer/info" | grep '^{"result"' -c) -eq 1 ]; then
|
||||
echo; ok_msg "Nginx is working correctly!"; echo
|
||||
else
|
||||
echo; warn_msg "Nginx is not working correctly!"; echo
|
||||
fi
|
||||
}
|
||||
|
||||
get_mainsail_ver(){
|
||||
MAINSAIL_VERSION=$(curl -s https://api.github.com/repositories/240875926/tags | grep name | cut -d'"' -f4 | cut -d"v" -f2 | head -1)
|
||||
}
|
||||
|
||||
mainsail_dl_url(){
|
||||
get_mainsail_ver
|
||||
MAINSAIL_URL=https://github.com/meteyou/mainsail/releases/download/v"$MAINSAIL_VERSION"/mainsail-beta-"$MAINSAIL_VERSION".zip
|
||||
}
|
||||
|
||||
install_mainsail(){
|
||||
mainsail_dl_url
|
||||
if [ ! -d $MAINSAIL_DIR ]; then
|
||||
mkdir $MAINSAIL_DIR
|
||||
fi
|
||||
cd $MAINSAIL_DIR
|
||||
status_msg "Downloading Mainsail v$MAINSAIL_VERSION ..."
|
||||
wget -q -O mainsail.zip $MAINSAIL_URL && status_msg "Extracting archive ..." && unzip -o mainsail.zip && rm mainsail.zip
|
||||
### write mainsail version to file for update check reasons
|
||||
echo "$MAINSAIL_VERSION" > $MAINSAIL_DIR/version
|
||||
echo
|
||||
}
|
||||
137
scripts/install_octoprint.sh
Executable file
137
scripts/install_octoprint.sh
Executable file
@@ -0,0 +1,137 @@
|
||||
octoprint_install_routine(){
|
||||
octoprint_dependencies
|
||||
install_octoprint
|
||||
add_groups
|
||||
configure_autostart
|
||||
add_reboot_permission
|
||||
octoprint_reverse_proxy_dialog
|
||||
create_custom_hostname
|
||||
create_config_yaml
|
||||
load_server
|
||||
}
|
||||
|
||||
octoprint_dependencies(){
|
||||
dep=(
|
||||
git
|
||||
wget
|
||||
python-pip
|
||||
python-dev
|
||||
libyaml-dev
|
||||
build-essential
|
||||
python-setuptools
|
||||
python-virtualenv
|
||||
)
|
||||
dependency_check
|
||||
}
|
||||
|
||||
install_octoprint(){
|
||||
if [ ! -d $OCTOPRINT_DIR ];then
|
||||
status_msg "Create OctoPrint directory ..."
|
||||
mkdir -p $OCTOPRINT_DIR && ok_msg "Directory created!"
|
||||
fi
|
||||
cd $OCTOPRINT_DIR
|
||||
#create the virtualenv
|
||||
status_msg "Set up virtualenv ..."
|
||||
virtualenv venv
|
||||
source venv/bin/activate
|
||||
#install octoprint with pip
|
||||
status_msg "Download and install OctoPrint ..."
|
||||
pip install pip --upgrade
|
||||
pip install --no-cache-dir octoprint
|
||||
ok_msg "Download complete!"
|
||||
#leave virtualenv
|
||||
deactivate
|
||||
}
|
||||
|
||||
add_groups(){
|
||||
if [ ! "$(groups | grep tty)" ]; then
|
||||
status_msg "Adding user '${USER}' to group 'tty' ..."
|
||||
sudo usermod -a -G tty ${USER} && ok_msg "Done!"
|
||||
fi
|
||||
if [ ! "$(groups | grep dialout)" ]; then
|
||||
status_msg "Adding user '${USER}' to group 'dialout' ..."
|
||||
sudo usermod -a -G dialout ${USER} && ok_msg "Done!"
|
||||
fi
|
||||
}
|
||||
|
||||
configure_autostart(){
|
||||
USER=$(whoami)
|
||||
cd $OCTOPRINT_DIR
|
||||
status_msg "Downloading files ..."
|
||||
wget https://github.com/foosel/OctoPrint/raw/master/scripts/octoprint.init
|
||||
wget https://github.com/foosel/OctoPrint/raw/master/scripts/octoprint.default
|
||||
ok_msg "Files downloaded successfully!"
|
||||
#make necessary changes in default file
|
||||
status_msg "Configure OctoPrint Service ..."
|
||||
DEFAULT_FILE=$OCTOPRINT_DIR/octoprint.default
|
||||
sed -i "s/pi/$USER/g" $DEFAULT_FILE
|
||||
sed -i "s/#BASEDIR=/BASEDIR=/" $DEFAULT_FILE
|
||||
sed -i "s/#CONFIGFILE=/CONFIGFILE=/" $DEFAULT_FILE
|
||||
sed -i "s/#DAEMON=/DAEMON=/" $DEFAULT_FILE
|
||||
#move files to correct location
|
||||
sudo mv octoprint.init $OCTOPRINT_SERVICE1
|
||||
sudo mv octoprint.default $OCTOPRINT_SERVICE2
|
||||
#make file in init.d executable
|
||||
sudo chmod +x $OCTOPRINT_SERVICE1
|
||||
status_msg "Reload systemd configuration files"
|
||||
sudo update-rc.d octoprint defaults
|
||||
sudo systemctl daemon-reload
|
||||
ok_msg "Configuration complete!"
|
||||
ok_msg "OctoPrint installed!"
|
||||
}
|
||||
|
||||
add_reboot_permission(){
|
||||
USER=$(whoami)
|
||||
#create a backup when file already exists
|
||||
if [ -f /etc/sudoers.d/octoprint-shutdown ]; then
|
||||
sudo mv /etc/sudoers.d/octoprint-shutdown /etc/sudoers.d/octoprint-shutdown.old
|
||||
fi
|
||||
#create new permission file
|
||||
status_msg "Add reboot permission to user '$USER' ..."
|
||||
cd $OCTOPRINT_DIR
|
||||
echo "$USER ALL=NOPASSWD: /sbin/shutdown" > octoprint-shutdown
|
||||
sudo chown 0 octoprint-shutdown
|
||||
sudo mv octoprint-shutdown /etc/sudoers.d/octoprint-shutdown
|
||||
ok_msg "Permission set!"
|
||||
sleep 2
|
||||
}
|
||||
|
||||
octoprint_reverse_proxy_dialog(){
|
||||
top_border
|
||||
echo -e "| If you want to have nicer URLs or simply need | "
|
||||
echo -e "| OctoPrint to run on port 80 (http's default port) | "
|
||||
echo -e "| due to some network restrictions, you can set up a | "
|
||||
echo -e "| reverse proxy instead of configuring OctoPrint to | "
|
||||
echo -e "| run on port 80. | "
|
||||
bottom_border
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "###### Do you want to set up a reverse proxy now? (Y/n): " yn
|
||||
echo -e "${default}"
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"") create_reverse_proxy "octoprint"; break;;
|
||||
N|n|No|no) break;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
create_config_yaml(){
|
||||
if [ ! -d $OCTOPRINT_CFG_DIR ]; then
|
||||
status_msg "Creating config.yaml ..."
|
||||
mkdir $OCTOPRINT_CFG_DIR
|
||||
cp ${HOME}/kiauh/resources/octoprint_config.cfg $OCTOPRINT_CFG_DIR/config.yaml
|
||||
ok_msg "Config created!"
|
||||
fi
|
||||
}
|
||||
|
||||
load_server(){
|
||||
start_octoprint
|
||||
#create an octoprint.log symlink in home-dir just for convenience
|
||||
if [ ! -e ${HOME}/octoprint.log ]; then
|
||||
status_msg "Creating octoprint.log Symlink ..."
|
||||
ln -s ${HOME}/.octoprint/logs/octoprint.log ${HOME}/octoprint.log && ok_msg "Symlink created!"
|
||||
fi
|
||||
ok_msg "OctoPrint is now running on:"
|
||||
ok_msg "$(hostname -I | cut -d " " -f1):5000 or"
|
||||
ok_msg "http://localhost:5000"; echo
|
||||
}
|
||||
178
scripts/remove.sh
Normal file
178
scripts/remove.sh
Normal file
@@ -0,0 +1,178 @@
|
||||
remove_klipper(){
|
||||
data_arr=(
|
||||
/etc/init.d/klipper
|
||||
/etc/default/klipper
|
||||
$KLIPPER_DIR
|
||||
$KLIPPY_ENV_DIR
|
||||
${HOME}/klippy.log
|
||||
)
|
||||
print_error "Klipper" && data_count=()
|
||||
if [ "$ERROR_MSG" = "" ]; then
|
||||
stop_klipper
|
||||
if [[ -e /etc/init.d/klipper || -e /etc/default/klipper ]]; then
|
||||
status_msg "Removing Klipper Service ..."
|
||||
sudo update-rc.d -f klipper remove
|
||||
sudo rm -rf /etc/init.d/klipper /etc/default/klipper && ok_msg "Klipper Service removed!"
|
||||
fi
|
||||
if [[ -d $KLIPPER_DIR || -d $KLIPPY_ENV_DIR ]]; then
|
||||
status_msg "Removing Klipper and klippy-env directory ..."
|
||||
rm -rf $KLIPPER_DIR $KLIPPY_ENV_DIR && ok_msg "Directories removed!"
|
||||
fi
|
||||
if [[ -L ${HOME}/klippy.log || -e /tmp/klippy.log ]]; then
|
||||
status_msg "Removing klippy.log Symlink ..."
|
||||
rm -rf ${HOME}/klippy.log /tmp/klippy.log && ok_msg "Symlink removed!"
|
||||
fi
|
||||
CONFIRM_MSG=" Klipper successfully removed!"
|
||||
fi
|
||||
}
|
||||
|
||||
remove_tornado(){
|
||||
data_arr=(
|
||||
$TORNADO_DIR1
|
||||
$TORNADO_DIR2
|
||||
)
|
||||
print_error "Tornado" && data_count=()
|
||||
if [ "$ERROR_MSG" = "" ]; then
|
||||
status_msg "Removing Tornado from klippy-env ..."
|
||||
PYTHONDIR=$KLIPPY_ENV_DIR
|
||||
$PYTHONDIR/bin/pip uninstall tornado -y
|
||||
CONFIRM_MSG=" Tornado successfully removed!"
|
||||
fi
|
||||
}
|
||||
|
||||
remove_dwc2(){
|
||||
data_arr=(
|
||||
$DWC2FK_DIR
|
||||
$WEB_DWC2
|
||||
$DWC2_DIR
|
||||
)
|
||||
print_error "DWC2-for-Klipper &\n DWC2 Web UI" && data_count=()
|
||||
if [ "$ERROR_MSG" = "" ]; then
|
||||
if [ -d $DWC2FK_DIR ]; then
|
||||
status_msg "Removing DWC2-for-Klipper directory ..."
|
||||
rm -rf $DWC2FK_DIR && ok_msg "Directory removed!"
|
||||
fi
|
||||
if [ -e $WEB_DWC2 ]; then
|
||||
status_msg "Removing web_dwc2.py Symlink from klippy ..."
|
||||
rm -rf $WEB_DWC2 && ok_msg "File removed!"
|
||||
fi
|
||||
if [ -d $DWC2_DIR ]; then
|
||||
status_msg "Removing DWC2 directory ..."
|
||||
rm -rf $DWC2_DIR && ok_msg "Directory removed!"
|
||||
fi
|
||||
CONFIRM_MSG=" DWC2-for-Klipper & DWC2 Web UI successfully removed!"
|
||||
fi
|
||||
}
|
||||
|
||||
remove_mainsail(){
|
||||
data_arr=(
|
||||
$MOONRAKER_SERVICE1
|
||||
$MOONRAKER_SERVICE2
|
||||
$MAINSAIL_DIR
|
||||
$MOONRAKER_DIR
|
||||
$MOONRAKER_ENV_DIR
|
||||
${HOME}/moonraker.log
|
||||
${HOME}/.klippy_api_key
|
||||
${HOME}/.moonraker_api_key
|
||||
/etc/nginx/sites-available/mainsail
|
||||
/etc/nginx/sites-enabled/mainsail
|
||||
)
|
||||
print_error "Mainsail" && data_count=()
|
||||
if [ "$ERROR_MSG" = "" ]; then
|
||||
stop_moonraker
|
||||
#remove moonraker services
|
||||
if [[ -e /etc/init.d/moonraker || -e /etc/default/moonraker ]]; then
|
||||
status_msg "Removing Moonraker Service ..."
|
||||
sudo update-rc.d -f moonraker remove
|
||||
sudo rm -rf /etc/init.d/moonraker /etc/default/moonraker && ok_msg "Moonraker Service removed!"
|
||||
fi
|
||||
#remove mainsail dir
|
||||
if [ -d $MAINSAIL_DIR ]; then
|
||||
status_msg "Removing Mainsail directory ..."
|
||||
rm -rf $MAINSAIL_DIR && ok_msg "Directory removed!"
|
||||
fi
|
||||
#remove moonraker and moonraker-env dir
|
||||
if [[ -d $MOONRAKER_DIR || -d $MOONRAKER_ENV_DIR ]]; then
|
||||
status_msg "Removing Moonraker and moonraker-env directory ..."
|
||||
rm -rf $MOONRAKER_DIR $MOONRAKER_ENV_DIR && ok_msg "Directories removed!"
|
||||
fi
|
||||
#remove moonraker.log and symlink
|
||||
if [[ -L ${HOME}/moonraker.log || -e /tmp/moonraker.log ]]; then
|
||||
status_msg "Removing moonraker.log and Symlink ..."
|
||||
rm -rf ${HOME}/moonraker.log /tmp/moonraker.log && ok_msg "Files removed!"
|
||||
fi
|
||||
#remove mainsail cfg
|
||||
if [ -e /etc/nginx/sites-available/mainsail ]; then
|
||||
status_msg "Removing Mainsail configuration for Nginx ..."
|
||||
sudo rm /etc/nginx/sites-available/mainsail && ok_msg "File removed!"
|
||||
fi
|
||||
#remove mainsail symlink
|
||||
if [ -L /etc/nginx/sites-enabled/mainsail ]; then
|
||||
status_msg "Removing Mainsail Symlink for Nginx ..."
|
||||
sudo rm /etc/nginx/sites-enabled/mainsail && ok_msg "File removed!"
|
||||
fi
|
||||
#remove legacy api key
|
||||
if [ -e ${HOME}/.klippy_api_key ]; then
|
||||
status_msg "Removing legacy API Key ..."
|
||||
rm ${HOME}/.klippy_api_key && ok_msg "Done!"
|
||||
fi
|
||||
#remove api key
|
||||
if [ -e ${HOME}/.moonraker_api_key ]; then
|
||||
status_msg "Removing API Key ..."
|
||||
rm ${HOME}/.moonraker_api_key && ok_msg "Done!"
|
||||
fi
|
||||
CONFIRM_MSG=" Mainsail successfully removed!"
|
||||
fi
|
||||
}
|
||||
|
||||
remove_octoprint(){
|
||||
data_arr=(
|
||||
$OCTOPRINT_SERVICE1
|
||||
$OCTOPRINT_SERVICE2
|
||||
$OCTOPRINT_DIR
|
||||
$OCTOPRINT_CFG_DIR
|
||||
${HOME}/octoprint.log
|
||||
/etc/sudoers.d/octoprint-shutdown
|
||||
/etc/nginx/sites-available/octoprint
|
||||
/etc/nginx/sites-enabled/octoprint
|
||||
)
|
||||
print_error "OctoPrint" && data_count=()
|
||||
if [ "$ERROR_MSG" = "" ]; then
|
||||
stop_octoprint
|
||||
if [[ -e $OCTOPRINT_SERVICE1 || -e $OCTOPRINT_SERVICE2 ]]; then
|
||||
status_msg "Removing OctoPrint Service ..."
|
||||
sudo update-rc.d -f octoprint remove
|
||||
sudo rm -rf $OCTOPRINT_SERVICE1 $OCTOPRINT_SERVICE2 && ok_msg "OctoPrint Service removed!"
|
||||
fi
|
||||
if [[ -d $OCTOPRINT_DIR || -d $OCTOPRINT_CFG_DIR ]]; then
|
||||
status_msg "Removing OctoPrint and .octoprint directory ..."
|
||||
rm -rf $OCTOPRINT_DIR $OCTOPRINT_CFG_DIR && ok_msg "Directories removed!"
|
||||
fi
|
||||
if [ -f /etc/sudoers.d/octoprint-shutdown ]; then
|
||||
sudo rm -rf /etc/sudoers.d/octoprint-shutdown
|
||||
fi
|
||||
if [ -L ${HOME}/octoprint.log ]; then
|
||||
status_msg "Removing octoprint.log Symlink ..."
|
||||
rm -rf ${HOME}/octoprint.log && ok_msg "Symlink removed!"
|
||||
fi
|
||||
CONFIRM_MSG=" OctoPrint successfully removed!"
|
||||
fi
|
||||
}
|
||||
|
||||
remove_nginx(){
|
||||
if [[ $(dpkg-query -f'${Status}' --show nginx 2>/dev/null) = *\ installed ]] ; then
|
||||
status_msg "Stopping and removing Nginx Service ..."
|
||||
if [ -e /etc/init.d/nginx ]; then
|
||||
sudo /etc/init.d/nginx stop && ok_msg "Nginx Service stopped!"
|
||||
sudo rm /etc/init.d/nginx && ok_msg "Nginx Service removed!"
|
||||
fi
|
||||
if [ -e /etc/default/nginx ]; then
|
||||
sudo rm /etc/default/nginx
|
||||
fi
|
||||
status_msg "Purging Nginx from system ..."
|
||||
sudo apt-get purge nginx nginx-common -y
|
||||
CONFIRM_MSG=" Nginx successfully removed!"
|
||||
else
|
||||
ERROR_MSG=" Looks like Nginx was already removed!\n Skipping..."
|
||||
fi
|
||||
}
|
||||
92
scripts/rollback.sh
Executable file
92
scripts/rollback.sh
Executable file
@@ -0,0 +1,92 @@
|
||||
save_klipper_state(){
|
||||
source_ini
|
||||
#read current klipper state
|
||||
COMMIT_STATE=$(git rev-parse --short HEAD)
|
||||
if [ $GET_BRANCH = origin/master ]; then
|
||||
ORI_OLD=$previous_origin_state
|
||||
ORI_NEW=$COMMIT_STATE
|
||||
sed -i "/previous_origin_state=/s/$ORI_OLD/$ORI_NEW/" $INI_FILE
|
||||
elif [ $GET_BRANCH = dmbutyugin/scurve-shaping ]; then
|
||||
SHA_OLD=$previous_shaping_state
|
||||
SHA_NEW=$COMMIT_STATE
|
||||
sed -i "/previous_shaping_state=/s/$SHA_OLD/$SHA_NEW/" $INI_FILE
|
||||
elif [ $GET_BRANCH = dmbutyugin/scurve-smoothing ]; then
|
||||
SMO_OLD=$previous_smoothing_state
|
||||
SMO_NEW=$COMMIT_STATE
|
||||
sed -i "/previous_smoothing_state=/s/$SMO_OLD/$SMO_NEW/" $INI_FILE
|
||||
elif [ $GET_BRANCH = Arksine/work-web_server-20200131 ]; then
|
||||
WWS_OLD=$previous_moonraker_state
|
||||
WWS_NEW=$COMMIT_STATE
|
||||
sed -i "/previous_moonraker_state=/s/$WWS_OLD/$WWS_NEW/" $INI_FILE
|
||||
elif [ $GET_BRANCH = Arksine/dev-moonraker-testing ]; then
|
||||
DMT_OLD=$previous_dev_moonraker_state
|
||||
DMT_NEW=$COMMIT_STATE
|
||||
sed -i "/previous_dev_moonraker_state=/s/$DMT_OLD/$DMT_NEW/" $INI_FILE
|
||||
fi
|
||||
}
|
||||
|
||||
load_klipper_state(){
|
||||
source_ini
|
||||
print_branch
|
||||
CURR_COMM=$(git rev-parse --short=8 HEAD)
|
||||
if [ "$GET_BRANCH" == "origin/master" ]; then
|
||||
PREV_COMM=$previous_origin_state
|
||||
elif [ "$GET_BRANCH" == "dmbutyugin/scurve-shaping" ]; then
|
||||
PREV_COMM=$previous_shaping_state
|
||||
elif [ "$GET_BRANCH" == "dmbutyugin/scurve-smoothing" ]; then
|
||||
PREV_COMM=$previous_smoothing_state
|
||||
elif [ "$GET_BRANCH" == "Arksine/work-web_server-20200131" ]; then
|
||||
PREV_COMM=$previous_moonraker_state
|
||||
elif [ "$GET_BRANCH" == "Arksine/dev-moonraker-testing" ]; then
|
||||
PREV_COMM=$previous_dev_moonraker_state
|
||||
fi
|
||||
PREV_COMM_DATE=$(git show -s --format=%cd --date=short $PREV_COMM)
|
||||
CURR_COMM_DATE=$(git show -s --format=%cd --date=short $CURR_COMM)
|
||||
if [ $CURR_COMM = $PREV_COMM ]; then
|
||||
CURR_UI=$(echo -e "${green}$CURR_COMM from $CURR_COMM_DATE${default}")
|
||||
PREV_UI=$(echo -e "${green}$PREV_COMM from $PREV_COMM_DATE${default}")
|
||||
else
|
||||
CURR_UI=$(echo -e "${yellow}$CURR_COMM from $CURR_COMM_DATE${default}")
|
||||
PREV_UI=$(echo -e "${yellow}$PREV_COMM from $PREV_COMM_DATE${default}")
|
||||
fi
|
||||
rollback_ui
|
||||
rollback_klipper
|
||||
}
|
||||
|
||||
rollback_klipper(){
|
||||
if [ "$CURR_COMM" != "$PREV_COMM" ]; then
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "###### Do you want to rollback to $PREV_COMM? (Y/n): " yn
|
||||
echo -e "${default}"
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
clear
|
||||
print_header
|
||||
status_msg "Rolling back to $PREV_COMM ..."
|
||||
git reset --hard $PREV_COMM -q
|
||||
ok_msg "Rollback complete!"; echo
|
||||
load_klipper_state
|
||||
break;;
|
||||
N|n|No|no) clear; advanced_menu; break;;
|
||||
Q|q) clear; advanced_menu; break;;
|
||||
esac
|
||||
done
|
||||
else
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "Perform action: " action; echo
|
||||
echo -e "${default}"
|
||||
case "$action" in
|
||||
Q|q)
|
||||
clear; advanced_menu; break;;
|
||||
*)
|
||||
clear
|
||||
print_header
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg
|
||||
rollback_ui;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
}
|
||||
273
scripts/status.sh
Normal file
273
scripts/status.sh
Normal file
@@ -0,0 +1,273 @@
|
||||
kiauh_status(){
|
||||
cd ${HOME}/kiauh
|
||||
#get local state
|
||||
LOCAL_KIAUH_COMMIT=$(git rev-parse --short=8 HEAD)
|
||||
#REMOTE_KIAUH_COMMIT=$(git rev-parse --short=8 origin/master)
|
||||
REMOTE_KIAUH_COMMIT=$(git rev-parse --short=8 dev-2.0)
|
||||
if [ "$LOCAL_KIAUH_COMMIT" != "$REMOTE_KIAUH_COMMIT" ]; then
|
||||
KIAUH_UPDATE_AVAIL=1
|
||||
else
|
||||
KIAUH_UPDATE_AVAIL=0
|
||||
fi
|
||||
}
|
||||
|
||||
klipper_status(){
|
||||
kcount=0
|
||||
klipper_data=(
|
||||
$KLIPPER_DIR
|
||||
$KLIPPY_ENV_DIR
|
||||
$KLIPPER_SERVICE1
|
||||
$KLIPPER_SERVICE2
|
||||
)
|
||||
#count+1 for each found data-item from array
|
||||
for kd in "${klipper_data[@]}"
|
||||
do
|
||||
if [ -e $kd ]; then
|
||||
kcount=$(expr $kcount + 1)
|
||||
fi
|
||||
done
|
||||
if [ "$kcount" == "${#klipper_data[*]}" ]; then
|
||||
KLIPPER_STATUS="${green}Installed!${default} "
|
||||
elif [ "$kcount" == 0 ]; then
|
||||
KLIPPER_STATUS="${red}Not installed!${default} "
|
||||
else
|
||||
KLIPPER_STATUS="${yellow}Incomplete!${default} "
|
||||
fi
|
||||
}
|
||||
|
||||
dwc2_status(){
|
||||
dcount=0
|
||||
dwc2_data=(
|
||||
$DWC2FK_DIR
|
||||
$WEB_DWC2
|
||||
$DWC2_DIR
|
||||
)
|
||||
#count+1 for each found data-item from array
|
||||
for dd in "${dwc2_data[@]}"
|
||||
do
|
||||
if [ -e $dd ]; then
|
||||
dcount=$(expr $dcount + 1)
|
||||
fi
|
||||
done
|
||||
if [ "$dcount" == "${#dwc2_data[*]}" ]; then
|
||||
DWC2_STATUS="${green}Installed!${default} "
|
||||
elif [ "$dcount" == 0 ]; then
|
||||
DWC2_STATUS="${red}Not installed!${default} "
|
||||
else
|
||||
DWC2_STATUS="${yellow}Incomplete!${default} "
|
||||
fi
|
||||
}
|
||||
|
||||
mainsail_status(){
|
||||
mcount=0
|
||||
mainsail_data=(
|
||||
$MOONRAKER_SERVICE1
|
||||
$MOONRAKER_SERVICE2
|
||||
$MAINSAIL_DIR
|
||||
#${HOME}/.klippy_api_key
|
||||
#${HOME}/.moonraker_api_key
|
||||
#${HOME}/moonraker-env
|
||||
/etc/nginx/sites-available/mainsail
|
||||
/etc/nginx/sites-enabled/mainsail
|
||||
)
|
||||
#count+1 for each found data-item from array
|
||||
for md in "${mainsail_data[@]}"
|
||||
do
|
||||
if [ -e $md ]; then
|
||||
mcount=$(expr $mcount + 1)
|
||||
fi
|
||||
done
|
||||
if [ "$mcount" == "${#mainsail_data[*]}" ]; then
|
||||
MAINSAIL_STATUS="${green}Installed!${default} "
|
||||
elif [ "$mcount" == 0 ]; then
|
||||
MAINSAIL_STATUS="${red}Not installed!${default} "
|
||||
else
|
||||
MAINSAIL_STATUS="${yellow}Incomplete!${default} "
|
||||
fi
|
||||
}
|
||||
|
||||
octoprint_status(){
|
||||
ocount=0
|
||||
octoprint_data=(
|
||||
$OCTOPRINT_DIR
|
||||
$OCTOPRINT_CFG_DIR
|
||||
$OCTOPRINT_SERVICE1
|
||||
$OCTOPRINT_SERVICE2
|
||||
)
|
||||
#count+1 for each found data-item from array
|
||||
for op in "${octoprint_data[@]}"
|
||||
do
|
||||
if [ -e $op ]; then
|
||||
ocount=$(expr $ocount + 1)
|
||||
fi
|
||||
done
|
||||
if [ "$ocount" == "${#octoprint_data[*]}" ]; then
|
||||
OCTOPRINT_STATUS="${green}Installed!${default} "
|
||||
elif [ "$ocount" == 0 ]; then
|
||||
OCTOPRINT_STATUS="${red}Not installed!${default} "
|
||||
else
|
||||
OCTOPRINT_STATUS="${yellow}Incomplete!${default} "
|
||||
fi
|
||||
}
|
||||
|
||||
read_branch(){
|
||||
if [ -d $KLIPPER_DIR ] && [ -d $KLIPPER_DIR/.git ]; then
|
||||
cd $KLIPPER_DIR
|
||||
GET_BRANCH=$(git branch -a | head -1 | cut -d " " -f5 | cut -d ")" -f1)
|
||||
#if reading the branch gives an empty string
|
||||
#we are on non-detached HEAD state on origin/master
|
||||
#and need to set GET_BRANCH to make a non-empty string
|
||||
if [ -z "$GET_BRANCH" ]; then
|
||||
GET_BRANCH="origin/master"
|
||||
fi
|
||||
else
|
||||
GET_BRANCH=""
|
||||
fi
|
||||
}
|
||||
|
||||
print_branch(){
|
||||
read_branch
|
||||
if [ "$GET_BRANCH" == "origin/master" ]; then
|
||||
PRINT_BRANCH="$GET_BRANCH "
|
||||
elif [ "$GET_BRANCH" == "dmbutyugin/scurve-shaping" ]; then
|
||||
PRINT_BRANCH="scurve-shaping "
|
||||
elif [ "$GET_BRANCH" == "dmbutyugin/scurve-smoothing" ]; then
|
||||
PRINT_BRANCH="scurve-smoothing "
|
||||
elif [ "$GET_BRANCH" == "Arksine/dev-moonraker-testing" ]; then
|
||||
PRINT_BRANCH="moonraker "
|
||||
else
|
||||
PRINT_BRANCH="${red}----${default} "
|
||||
fi
|
||||
}
|
||||
|
||||
read_local_klipper_commit(){
|
||||
if [ -d $KLIPPER_DIR ] && [ -d $KLIPPER_DIR/.git ]; then
|
||||
cd $KLIPPER_DIR
|
||||
LOCAL_COMMIT=$(git rev-parse --short=8 HEAD)
|
||||
else
|
||||
LOCAL_COMMIT="${red}--------${default}"
|
||||
fi
|
||||
}
|
||||
|
||||
read_remote_klipper_commit(){
|
||||
read_branch
|
||||
if [ ! -z "$GET_BRANCH" ];then
|
||||
if [ "$GET_BRANCH" == "origin/master" ]; then
|
||||
git fetch origin master -q
|
||||
else
|
||||
git fetch $(echo "$GET_BRANCH" | cut -d"/" -f1) -q
|
||||
fi
|
||||
REMOTE_COMMIT=$(git rev-parse --short=8 $GET_BRANCH)
|
||||
else
|
||||
REMOTE_COMMIT="${red}--------${default}"
|
||||
fi
|
||||
}
|
||||
|
||||
compare_klipper_versions(){
|
||||
read_local_klipper_commit
|
||||
read_remote_klipper_commit
|
||||
#echo "Local: $LOCAL_COMMIT"
|
||||
#echo "Remote: $REMOTE_COMMIT"
|
||||
if [ "$LOCAL_COMMIT" != "$REMOTE_COMMIT" ]; then
|
||||
LOCAL_COMMIT="${yellow}$LOCAL_COMMIT${default}"
|
||||
REMOTE_COMMIT="${green}$REMOTE_COMMIT${default}"
|
||||
else
|
||||
LOCAL_COMMIT="${green}$LOCAL_COMMIT${default}"
|
||||
REMOTE_COMMIT="${green}$REMOTE_COMMIT${default}"
|
||||
fi
|
||||
}
|
||||
|
||||
read_dwc2fk_versions(){
|
||||
if [ -d $DWC2FK_DIR ] && [ -d $DWC2FK_DIR/.git ]; then
|
||||
cd $DWC2FK_DIR
|
||||
git fetch origin master -q
|
||||
LOCAL_DWC2FK_COMMIT=$(git rev-parse --short=8 HEAD)
|
||||
REMOTE_DWC2FK_COMMIT=$(git rev-parse --short=8 origin/master)
|
||||
else
|
||||
LOCAL_DWC2FK_COMMIT="${red}--------${default}"
|
||||
REMOTE_DWC2FK_COMMIT="${red}--------${default}"
|
||||
fi
|
||||
}
|
||||
|
||||
compare_dwc2fk_versions(){
|
||||
read_dwc2fk_versions
|
||||
#echo "Local: $LOCAL_DWC2FK_COMMIT"
|
||||
#echo "Remote: $REMOTE_DWC2FK_COMMIT"
|
||||
if [ "$LOCAL_DWC2FK_COMMIT" != "$REMOTE_DWC2FK_COMMIT" ]; then
|
||||
LOCAL_DWC2FK_COMMIT="${yellow}$LOCAL_DWC2FK_COMMIT${default}"
|
||||
REMOTE_DWC2FK_COMMIT="${green}$REMOTE_DWC2FK_COMMIT${default}"
|
||||
else
|
||||
LOCAL_DWC2FK_COMMIT="${green}$LOCAL_DWC2FK_COMMIT${default}"
|
||||
REMOTE_DWC2FK_COMMIT="${green}$REMOTE_DWC2FK_COMMIT${default}"
|
||||
fi
|
||||
}
|
||||
|
||||
read_local_dwc2_version(){
|
||||
if [ -e $DWC2_DIR/web/version ]; then
|
||||
DWC2_LOCAL_VER=$(head -n 1 $DWC2_DIR/web/version)
|
||||
else
|
||||
DWC2_LOCAL_VER="${red}-----${default}"
|
||||
fi
|
||||
}
|
||||
|
||||
read_remote_dwc2_version(){
|
||||
#remote checks don't work without curl installed!
|
||||
if [[ ! $(dpkg-query -f'${Status}' --show curl 2>/dev/null) = *\ installed ]]; then
|
||||
DWC2_REMOTE_VER="${red}-----${default}"
|
||||
else
|
||||
DWC2_REMOTE_VER=$(curl -s https://api.github.com/repositories/28820678/releases/latest | grep tag_name | cut -d'"' -f4)
|
||||
fi
|
||||
}
|
||||
|
||||
compare_dwc2_versions(){
|
||||
read_local_dwc2_version
|
||||
read_remote_dwc2_version
|
||||
#echo "Local: $DWC2_LOCAL_VER"
|
||||
#echo "Remote: $DWC2_REMOTE_VER"
|
||||
if [ "$DWC2_LOCAL_VER" != "$DWC2_REMOTE_VER" ]; then
|
||||
DWC2_LOCAL_VER="${yellow}$DWC2_LOCAL_VER${default}"
|
||||
DWC2_REMOTE_VER="${green}$DWC2_REMOTE_VER${default}"
|
||||
else
|
||||
DWC2_LOCAL_VER="${green}$DWC2_LOCAL_VER${default}"
|
||||
DWC2_REMOTE_VER="${green}$DWC2_REMOTE_VER${default}"
|
||||
fi
|
||||
}
|
||||
|
||||
read_local_mainsail_version(){
|
||||
if [ -e $MAINSAIL_DIR/version ]; then
|
||||
MAINSAIL_LOCAL_VER=$(head -n 1 $MAINSAIL_DIR/version)
|
||||
else
|
||||
MAINSAIL_LOCAL_VER="${red}------${default}"
|
||||
fi
|
||||
}
|
||||
|
||||
read_remote_mainsail_version(){
|
||||
#remote checks don't work without curl installed!
|
||||
if [[ ! $(dpkg-query -f'${Status}' --show curl 2>/dev/null) = *\ installed ]]; then
|
||||
MAINSAIL_REMOTE_VER="${red}------${default}"
|
||||
else
|
||||
get_mainsail_ver
|
||||
MAINSAIL_REMOTE_VER=$MAINSAIL_VERSION
|
||||
fi
|
||||
}
|
||||
|
||||
compare_mainsail_versions(){
|
||||
read_local_mainsail_version
|
||||
read_remote_mainsail_version
|
||||
#echo "Local: $MAINSAIL_LOCAL_VER"
|
||||
#echo "Remote: $MAINSAIL_REMOTE_VER"
|
||||
if [ "$MAINSAIL_LOCAL_VER" != "$MAINSAIL_REMOTE_VER" ]; then
|
||||
MAINSAIL_LOCAL_VER="${yellow}$MAINSAIL_LOCAL_VER${default}"
|
||||
MAINSAIL_REMOTE_VER="${green}$MAINSAIL_REMOTE_VER${default}"
|
||||
else
|
||||
MAINSAIL_LOCAL_VER="${green}$MAINSAIL_LOCAL_VER${default}"
|
||||
MAINSAIL_REMOTE_VER="${green}$MAINSAIL_REMOTE_VER${default}"
|
||||
fi
|
||||
}
|
||||
|
||||
ui_print_versions(){
|
||||
compare_klipper_versions
|
||||
compare_dwc2fk_versions
|
||||
compare_dwc2_versions
|
||||
compare_mainsail_versions
|
||||
}
|
||||
32
scripts/switch_branch.sh
Normal file
32
scripts/switch_branch.sh
Normal file
@@ -0,0 +1,32 @@
|
||||
switch_to_origin(){
|
||||
cd $KLIPPER_DIR
|
||||
status_msg "Switching...Please wait ..."; echo
|
||||
git fetch origin -q && git checkout origin/master -q
|
||||
}
|
||||
|
||||
switch_to_scurve_shaping(){
|
||||
cd $KLIPPER_DIR
|
||||
status_msg "Switching...Please wait ..."; echo
|
||||
if ! git remote | grep dmbutyugin -q; then
|
||||
git remote add dmbutyugin $DMBUTYUGIN_REPO
|
||||
fi
|
||||
git fetch dmbutyugin -q && git checkout $BRANCH_SCURVE_SHAPING -q
|
||||
}
|
||||
|
||||
switch_to_scurve_smoothing(){
|
||||
cd $KLIPPER_DIR
|
||||
status_msg "Switching...Please wait ..."; echo
|
||||
if ! git remote | grep dmbutyugin -q; then
|
||||
git remote add dmbutyugin $DMBUTYUGIN_REPO
|
||||
fi
|
||||
git fetch dmbutyugin -q && git checkout $BRANCH_SCURVE_SMOOTHING -q
|
||||
}
|
||||
|
||||
switch_to_moonraker(){
|
||||
cd $KLIPPER_DIR
|
||||
status_msg "Switching...Please wait ..."; echo
|
||||
if ! git remote | grep Arksine -q; then
|
||||
git remote add Arksine $ARKSINE_REPO
|
||||
fi
|
||||
git fetch Arksine -q && git checkout $BRANCH_MOONRAKER -q
|
||||
}
|
||||
183
scripts/ui.sh
Normal file
183
scripts/ui.sh
Normal file
@@ -0,0 +1,183 @@
|
||||
### set up some UI stuff
|
||||
|
||||
#ui total width = 57 chars
|
||||
top_border(){
|
||||
echo -e "/=======================================================\ "
|
||||
}
|
||||
|
||||
bottom_border(){
|
||||
echo -e "\=======================================================/"
|
||||
}
|
||||
|
||||
hr(){
|
||||
echo -e "|-------------------------------------------------------|"
|
||||
}
|
||||
|
||||
quit_footer(){
|
||||
hr
|
||||
echo -e "| ${red}Q) Quit${default} | "
|
||||
bottom_border
|
||||
}
|
||||
|
||||
print_header(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~~~~ [ KIAUH ] ~~~~~~~~~~~~~~~~~") |"
|
||||
echo -e "| $(title_msg " Klipper Installation And Update Helper ") |"
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") |"
|
||||
bottom_border
|
||||
}
|
||||
|
||||
main_ui(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~~ [ Main Menu ] ~~~~~~~~~~~~~~~") |"
|
||||
hr
|
||||
echo -e "| 0) [System status] | |"
|
||||
echo -e "| | Klipper: $KLIPPER_STATUS|"
|
||||
echo -e "| 1) [Install] | Branch: ${cyan}$PRINT_BRANCH${default}|"
|
||||
echo -e "| 2) [Update] | |"
|
||||
echo -e "| 3) [Remove] | DWC2: $DWC2_STATUS|"
|
||||
echo -e "| | Mainsail: $MAINSAIL_STATUS|"
|
||||
echo -e "| 4) [Advanced] | Octoprint: $OCTOPRINT_STATUS|"
|
||||
echo -e "| 5) [Backup] | |"
|
||||
quit_footer
|
||||
}
|
||||
|
||||
install_ui(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~ [ Installation Menu ] ~~~~~~~~~~~") | "
|
||||
hr
|
||||
echo -e "| You need this menu usually only for installing | "
|
||||
echo -e "| all necessary dependencies for the various | "
|
||||
echo -e "| functions on a completely fresh system. | "
|
||||
hr
|
||||
echo -e "| Firmware: | | "
|
||||
echo -e "| 1) [Klipper] | | "
|
||||
echo -e "| | | "
|
||||
echo -e "| Webinterface: | | "
|
||||
echo -e "| 2) [DWC2] | | "
|
||||
echo -e "| 3) [Mainsail] | | "
|
||||
echo -e "| 4) [Octoprint] | | "
|
||||
quit_footer
|
||||
}
|
||||
|
||||
update_ui(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~ [ Update Menu ] ~~~~~~~~~~~~~~") | "
|
||||
hr
|
||||
echo -e "| It is a good idea to check the following website | "
|
||||
echo -e "| for important software changes to the config file | "
|
||||
echo -e "| >> BEFORE << updating your klipper installation: | "
|
||||
echo -e "| | "
|
||||
echo -e "| ${yellow}https://www.klipper3d.org/Config_Changes.html${default} | "
|
||||
bottom_border
|
||||
top_border
|
||||
echo -e "| 0) $BB4U_STATUS| "
|
||||
hr
|
||||
echo -e "| | Local Vers: | Remote Vers: | "
|
||||
echo -e "| Firmware: | | | "
|
||||
echo -e "| 1) [Klipper] | $(echo "$LOCAL_COMMIT") | $(echo "$REMOTE_COMMIT") | "
|
||||
echo -e "| | | | "
|
||||
echo -e "| Webinterface: | | | "
|
||||
echo -e "| 2) [DWC2-for-Klipper] | $(echo "$LOCAL_DWC2FK_COMMIT") | $(echo "$REMOTE_DWC2FK_COMMIT") | "
|
||||
echo -e "| 3) [DWC2 Web UI] | $(echo "$DWC2_LOCAL_VER") | $(echo "$DWC2_REMOTE_VER") | "
|
||||
echo -e "| 4) [Mainsail] | $(echo "$MAINSAIL_LOCAL_VER") | $(echo "$MAINSAIL_REMOTE_VER") | "
|
||||
echo -e "| | | | "
|
||||
quit_footer
|
||||
}
|
||||
|
||||
remove_ui(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~ [ Remove Menu ] ~~~~~~~~~~~~~~") | "
|
||||
hr
|
||||
echo -e "| Files and directories which remain untouched: | "
|
||||
echo -e "| --> ~/printer.cfg | "
|
||||
echo -e "| --> ~/kiauh-backups | "
|
||||
echo -e "| You need remove them manually if you wish so. | "
|
||||
hr
|
||||
echo -e "| 1) [Klipper] | 5) [Tornado] | "
|
||||
echo -e "| 2) [DWC2-for-Klipper] | 6) [Nginx] | "
|
||||
echo -e "| 3) [Mainsail] | | "
|
||||
echo -e "| 4) [Octoprint] | | "
|
||||
quit_footer
|
||||
}
|
||||
|
||||
advanced_ui(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~ [ Advanced Menu ] ~~~~~~~~~~~~~") | "
|
||||
hr
|
||||
echo -e "| 0) $OPRINT_SERVICE_STATUS| "
|
||||
hr
|
||||
echo -e "| | | "
|
||||
echo -e "| Klipper: | System: | "
|
||||
echo -e "| 1) [Switch Version] | 8) [Change hostname] | "
|
||||
echo -e "| 2) [Rollback] | | "
|
||||
echo -e "| | | "
|
||||
echo -e "| Firmware: | | "
|
||||
echo -e "| 3) [Build Firmware] | | "
|
||||
echo -e "| 4) [Flash MCU] | | "
|
||||
echo -e "| 5) [Get Printer-ID] | | "
|
||||
echo -e "| 6) [Write Printer-ID] | | "
|
||||
echo -e "| 7) [Write DWC2 config] | | "
|
||||
echo -e "| | | "
|
||||
quit_footer
|
||||
}
|
||||
|
||||
backup_ui(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~ [ Backup Menu ] ~~~~~~~~~~~~~~") | "
|
||||
hr
|
||||
echo -e "| ${yellow}Backup location: ~/kiauh-backups${default} | "
|
||||
hr
|
||||
echo -e "| Firmware: | "
|
||||
echo -e "| 1) [Klipper] | "
|
||||
echo -e "| | "
|
||||
echo -e "| Webinterface: | "
|
||||
echo -e "| 2) [DWC2-for-Klipper + DWC2 Web UI] | "
|
||||
echo -e "| 3) [Mainsail] | "
|
||||
echo -e "| 4) [OctoPrint] | "
|
||||
echo -e "| | "
|
||||
quit_footer
|
||||
}
|
||||
|
||||
switch_ui(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~ [ Switch Klipper Branch ] ~~~~~~~~~") |"
|
||||
bottom_border
|
||||
echo
|
||||
echo -e " $(title_msg "Active Branch: ")${green}$GET_BRANCH${default}"
|
||||
echo
|
||||
top_border
|
||||
echo -e "| 1) [--> origin/master] | "
|
||||
echo -e "| | "
|
||||
echo -e "| 2) [--> scurve-shaping] | "
|
||||
echo -e "| 3) [--> scurve-smoothing] | "
|
||||
echo -e "| | "
|
||||
echo -e "| 4) [--> moonraker] | "
|
||||
quit_footer
|
||||
}
|
||||
|
||||
kiauh_update_msg(){
|
||||
top_border
|
||||
echo -e "| ${yellow}There is a newer version of this script available!${default} | "
|
||||
echo -e "| ${yellow}Type 'update' if you want to update KIAUH now.${default} | "
|
||||
bottom_border
|
||||
}
|
||||
|
||||
rollback_ui(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~ [ Rollback Menu ] ~~~~~~~~~~~~~") | "
|
||||
hr
|
||||
echo -e "| If serious errors occured after updating Klipper, | "
|
||||
echo -e "| you can use this menu to return to the previously | "
|
||||
echo -e "| used commit from which you have updated. | "
|
||||
bottom_border
|
||||
top_border
|
||||
echo -e "| Active branch: ${green}$PRINT_BRANCH${default} | "
|
||||
hr
|
||||
echo -e "| Currently on commit: | "
|
||||
echo -e "| $CURR_UI | "
|
||||
hr
|
||||
echo -e "| Commit last updated from: | "
|
||||
echo -e "| $PREV_UI | "
|
||||
quit_footer
|
||||
}
|
||||
68
scripts/update.sh
Normal file
68
scripts/update.sh
Normal file
@@ -0,0 +1,68 @@
|
||||
#TODO
|
||||
# - version checks before updating
|
||||
|
||||
update_check(){
|
||||
read_local_commit
|
||||
read_remote_commit
|
||||
}
|
||||
|
||||
update_kiauh(){
|
||||
if [ $KIAUH_UPDATE_AVAIL = 1 ]; then
|
||||
status_msg "Updating KIAUH ..."
|
||||
cd ${HOME}/kiauh
|
||||
git pull && ok_msg "Update complete! Please restart KIAUH."; echo
|
||||
fi
|
||||
}
|
||||
|
||||
update_klipper(){
|
||||
stop_klipper
|
||||
if [ ! -d $KLIPPER_DIR ]; then
|
||||
cd ${HOME} && git clone $KLIPPER_REPO
|
||||
else
|
||||
bb4u "klipper"
|
||||
read_branch
|
||||
save_klipper_state
|
||||
status_msg "Updating $GET_BRANCH"
|
||||
#fetching origin/master -> error
|
||||
#rewriting origin/master to origin
|
||||
if [ "$GET_BRANCH" == "origin/master" ]; then
|
||||
FETCH_BRANCH="origin"
|
||||
else
|
||||
FETCH_BRANCH=$(echo "$GET_BRANCH" | cut -d "/" -f1)
|
||||
fi
|
||||
status_msg "Fetching from $FETCH_BRANCH"
|
||||
git fetch $FETCH_BRANCH -q && ok_msg "Fetch successfull!"
|
||||
status_msg "Checking out $GET_BRANCH"
|
||||
git checkout $GET_BRANCH -q && ok_msg "Checkout successfull!" && echo; ok_msg "Update complete!"
|
||||
fi
|
||||
start_klipper; echo
|
||||
}
|
||||
|
||||
update_dwc2fk(){
|
||||
stop_klipper
|
||||
bb4u "dwc2"
|
||||
if [ ! -d $DWC2FK_DIR ]; then
|
||||
cd ${HOME} && git clone $DWC2FK_REPO
|
||||
else
|
||||
cd $DWC2FK_DIR && git pull
|
||||
#create a web_dwc2.py symlink if not already existing
|
||||
if [ -d $KLIPPER_DIR/klippy/extras ] && [ ! -e $WEB_DWC2 ]; then
|
||||
status_msg "Creating web_dwc2.py Symlink ..."
|
||||
ln -s $DWC2FK_DIR/web_dwc2.py $WEB_DWC2 && ok_msg "Symlink created!"
|
||||
fi
|
||||
fi
|
||||
start_klipper
|
||||
}
|
||||
|
||||
update_dwc2(){
|
||||
bb4u "dwc2"
|
||||
install_dwc2
|
||||
}
|
||||
|
||||
update_mainsail(){
|
||||
stop_klipper
|
||||
bb4u "mainsail"
|
||||
status_msg "Updating Mainsail ..."
|
||||
install_mainsail
|
||||
start_klipper
|
||||
}
|
||||
Reference in New Issue
Block a user