mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-23 15:53:36 +05:00
Compare commits
28 Commits
8f793bbfd8
...
5fa32a1c24
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5fa32a1c24 | ||
|
|
be5f345a7c | ||
|
|
948927cfd3 | ||
|
|
34ebe5d15e | ||
|
|
3bef6ecb85 | ||
|
|
099d47df2f | ||
|
|
ba1cdb3739 | ||
|
|
8e7d4db988 | ||
|
|
8f960495ba | ||
|
|
095823bf28 | ||
|
|
397038e43e | ||
|
|
061e222664 | ||
|
|
3f5ff50d69 | ||
|
|
5ebe941125 | ||
|
|
f5eb9486cc | ||
|
|
7a9e752f9c | ||
|
|
30bc56b198 | ||
|
|
b2567995de | ||
|
|
6fcd7a3f08 | ||
|
|
25dfbb83df | ||
|
|
899b204dc7 | ||
|
|
5cf4b018fc | ||
|
|
ae9d1b98da | ||
|
|
16d3388ff2 | ||
|
|
b88d0085ba | ||
|
|
0b6613e464 | ||
|
|
d99cda544a | ||
|
|
a50dce20de |
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@@ -9,4 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl
|
|||||||
liberapay: # Replace with a single Liberapay username
|
liberapay: # Replace with a single Liberapay username
|
||||||
issuehunt: # Replace with a single IssueHunt username
|
issuehunt: # Replace with a single IssueHunt username
|
||||||
otechie: # Replace with a single Otechie username
|
otechie: # Replace with a single Otechie username
|
||||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
custom: https://paypal.me/dwillner0
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
.idea
|
||||||
.vscode
|
.vscode
|
||||||
.idea
|
.idea
|
||||||
.pytest_cache
|
.pytest_cache
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
### 📋 Prerequisites
|
### 📋 Prerequisites
|
||||||
KIAUH is a script that assists you in installing Klipper on a Linux operating system that has
|
KIAUH is a script that assists you in installing Klipper on a Linux operating system that has
|
||||||
already been flashed to your Raspberry Pi's (or other SBC's) SD card. As a result, you must ensure
|
already been flashed to your Raspberry Pi's (or other SBC's) SD card. As a result, you must ensure
|
||||||
that you have a functional Linux system on hand. `Raspberry Pi OS Lite (32bit)` is a recommended Linux image
|
that you have a functional Linux system on hand. `Raspberry Pi OS Lite (either 32bit or 64bit)` is a recommended Linux image
|
||||||
if you are using a Raspberry Pi. The [official Raspberry Pi Imager](https://www.raspberrypi.com/software/)
|
if you are using a Raspberry Pi. The [official Raspberry Pi Imager](https://www.raspberrypi.com/software/)
|
||||||
is the simplest way to flash an image like this to an SD card.
|
is the simplest way to flash an image like this to an SD card.
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ select `Choose OS -> Raspberry Pi OS (other)`: \
|
|||||||
<img src="https://raw.githubusercontent.com/dw-0/kiauh/master/resources/screenshots/rpi_imager1.png" alt="KIAUH logo" height="350">
|
<img src="https://raw.githubusercontent.com/dw-0/kiauh/master/resources/screenshots/rpi_imager1.png" alt="KIAUH logo" height="350">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
* Then select `Raspberry Pi OS Lite (32bit)`:
|
* Then select `Raspberry Pi OS Lite (32bit)` (or 64bit if you want to use that instead):
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://raw.githubusercontent.com/dw-0/kiauh/master/resources/screenshots/rpi_imager2.png" alt="KIAUH logo" height="350">
|
<img src="https://raw.githubusercontent.com/dw-0/kiauh/master/resources/screenshots/rpi_imager2.png" alt="KIAUH logo" height="350">
|
||||||
</p>
|
</p>
|
||||||
@@ -125,7 +125,7 @@ prompt and confirm by hitting ENTER.
|
|||||||
<tr>
|
<tr>
|
||||||
<th><img src="https://raw.githubusercontent.com/fluidd-core/fluidd/master/docs/assets/images/logo.svg" alt="Fluidd Logo" height="64"></th>
|
<th><img src="https://raw.githubusercontent.com/fluidd-core/fluidd/master/docs/assets/images/logo.svg" alt="Fluidd Logo" height="64"></th>
|
||||||
<th><img src="https://avatars.githubusercontent.com/u/31575189?v=4" alt="jordanruthe avatar" height="64"></th>
|
<th><img src="https://avatars.githubusercontent.com/u/31575189?v=4" alt="jordanruthe avatar" height="64"></th>
|
||||||
<th><img src="https://camo.githubusercontent.com/627be7fc67195b626b298af9b9677d7c58e698c67305e54324cffbe06130d4a4/68747470733a2f2f6f63746f7072696e742e6f72672f6173736574732f696d672f6c6f676f2e706e67" alt="OctoPrint Logo" height="64"></th>
|
<th><img src="https://raw.githubusercontent.com/OctoPrint/OctoPrint/master/docs/images/octoprint-logo.png" alt="OctoPrint Logo" height="64"></th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>by <a href="https://github.com/fluidd-core">fluidd-core</a></th>
|
<th>by <a href="https://github.com/fluidd-core">fluidd-core</a></th>
|
||||||
|
|||||||
2
kiauh.sh
2
kiauh.sh
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -13,4 +13,3 @@ from pathlib import Path
|
|||||||
|
|
||||||
APPLICATION_ROOT = Path(__file__).resolve().parent.parent
|
APPLICATION_ROOT = Path(__file__).resolve().parent.parent
|
||||||
KIAUH_CFG = APPLICATION_ROOT.joinpath("kiauh.cfg")
|
KIAUH_CFG = APPLICATION_ROOT.joinpath("kiauh.cfg")
|
||||||
KIAUH_BACKUP_DIR = Path.home().joinpath("kiauh-backups")
|
|
||||||
|
|||||||
@@ -11,10 +11,13 @@
|
|||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from kiauh.core.backup_manager import BACKUP_ROOT_DIR
|
||||||
|
|
||||||
MODULE_PATH = Path(__file__).resolve().parent
|
MODULE_PATH = Path(__file__).resolve().parent
|
||||||
|
|
||||||
KLIPPER_DIR = Path.home().joinpath("klipper")
|
KLIPPER_DIR = Path.home().joinpath("klipper")
|
||||||
KLIPPER_ENV_DIR = Path.home().joinpath("klippy-env")
|
KLIPPER_ENV_DIR = Path.home().joinpath("klippy-env")
|
||||||
|
KLIPPER_BACKUP_DIR = BACKUP_ROOT_DIR.joinpath("klipper-backups")
|
||||||
KLIPPER_REQUIREMENTS_TXT = KLIPPER_DIR.joinpath("scripts/klippy-requirements.txt")
|
KLIPPER_REQUIREMENTS_TXT = KLIPPER_DIR.joinpath("scripts/klippy-requirements.txt")
|
||||||
DEFAULT_KLIPPER_REPO_URL = "https://github.com/Klipper3D/klipper"
|
DEFAULT_KLIPPER_REPO_URL = "https://github.com/Klipper3D/klipper"
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ import subprocess
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from kiauh.core.instance_manager.base_instance import BaseInstance
|
|
||||||
from kiauh.components.klipper import KLIPPER_DIR, KLIPPER_ENV_DIR, MODULE_PATH
|
from kiauh.components.klipper import KLIPPER_DIR, KLIPPER_ENV_DIR, MODULE_PATH
|
||||||
|
from kiauh.core.instance_manager.base_instance import BaseInstance
|
||||||
from kiauh.utils.constants import SYSTEMD
|
from kiauh.utils.constants import SYSTEMD
|
||||||
from kiauh.utils.logger import Logger
|
from kiauh.utils.logger import Logger
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,10 @@
|
|||||||
import shutil
|
import shutil
|
||||||
from typing import List, Union
|
from typing import List, Union
|
||||||
|
|
||||||
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
|
||||||
from kiauh.components.klipper import KLIPPER_DIR, KLIPPER_ENV_DIR
|
from kiauh.components.klipper import KLIPPER_DIR, KLIPPER_ENV_DIR
|
||||||
from kiauh.components.klipper.klipper import Klipper
|
from kiauh.components.klipper.klipper import Klipper
|
||||||
from kiauh.components.klipper.klipper_dialogs import print_instance_overview
|
from kiauh.components.klipper.klipper_dialogs import print_instance_overview
|
||||||
|
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
||||||
from kiauh.utils.filesystem_utils import remove_file
|
from kiauh.utils.filesystem_utils import remove_file
|
||||||
from kiauh.utils.input_utils import get_selection_input
|
from kiauh.utils.input_utils import get_selection_input
|
||||||
from kiauh.utils.logger import Logger
|
from kiauh.utils.logger import Logger
|
||||||
|
|||||||
@@ -12,9 +12,6 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from kiauh import KIAUH_CFG
|
from kiauh import KIAUH_CFG
|
||||||
from kiauh.core.backup_manager.backup_manager import BackupManager
|
|
||||||
from kiauh.core.config_manager.config_manager import ConfigManager
|
|
||||||
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
|
||||||
from kiauh.components.klipper import (
|
from kiauh.components.klipper import (
|
||||||
EXIT_KLIPPER_SETUP,
|
EXIT_KLIPPER_SETUP,
|
||||||
DEFAULT_KLIPPER_REPO_URL,
|
DEFAULT_KLIPPER_REPO_URL,
|
||||||
@@ -35,9 +32,12 @@ from kiauh.components.klipper.klipper_utils import (
|
|||||||
check_is_single_to_multi_conversion,
|
check_is_single_to_multi_conversion,
|
||||||
update_name_scheme,
|
update_name_scheme,
|
||||||
handle_instance_naming,
|
handle_instance_naming,
|
||||||
|
backup_klipper_dir,
|
||||||
)
|
)
|
||||||
from kiauh.core.repo_manager.repo_manager import RepoManager
|
|
||||||
from kiauh.components.moonraker.moonraker import Moonraker
|
from kiauh.components.moonraker.moonraker import Moonraker
|
||||||
|
from kiauh.core.config_manager.config_manager import ConfigManager
|
||||||
|
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
||||||
|
from kiauh.core.repo_manager.repo_manager import RepoManager
|
||||||
from kiauh.utils.input_utils import get_confirm
|
from kiauh.utils.input_utils import get_confirm
|
||||||
from kiauh.utils.logger import Logger
|
from kiauh.utils.logger import Logger
|
||||||
from kiauh.utils.system_utils import (
|
from kiauh.utils.system_utils import (
|
||||||
@@ -149,9 +149,7 @@ def update_klipper() -> None:
|
|||||||
|
|
||||||
cm = ConfigManager(cfg_file=KIAUH_CFG)
|
cm = ConfigManager(cfg_file=KIAUH_CFG)
|
||||||
if cm.get_value("kiauh", "backup_before_update"):
|
if cm.get_value("kiauh", "backup_before_update"):
|
||||||
bm = BackupManager()
|
backup_klipper_dir()
|
||||||
bm.backup_directory("klipper", KLIPPER_DIR)
|
|
||||||
bm.backup_directory("klippy-env", KLIPPER_ENV_DIR)
|
|
||||||
|
|
||||||
instance_manager = InstanceManager(Klipper)
|
instance_manager = InstanceManager(Klipper)
|
||||||
instance_manager.stop_all_instance()
|
instance_manager.stop_all_instance()
|
||||||
|
|||||||
@@ -9,22 +9,21 @@
|
|||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
|
|
||||||
|
import grp
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import grp
|
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import textwrap
|
import textwrap
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from typing import List, Union, Literal, Dict
|
from typing import List, Union, Literal, Dict
|
||||||
|
|
||||||
from kiauh.core.config_manager.config_manager import ConfigManager
|
from kiauh.components.klipper import (
|
||||||
from kiauh.core.instance_manager.base_instance import BaseInstance
|
MODULE_PATH,
|
||||||
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
KLIPPER_DIR,
|
||||||
from kiauh.core.instance_manager.name_scheme import NameScheme
|
KLIPPER_ENV_DIR,
|
||||||
from kiauh.core.repo_manager.repo_manager import RepoManager
|
KLIPPER_BACKUP_DIR,
|
||||||
from kiauh.components.klipper import MODULE_PATH, KLIPPER_DIR, KLIPPER_ENV_DIR
|
)
|
||||||
from kiauh.components.klipper.klipper import Klipper
|
from kiauh.components.klipper.klipper import Klipper
|
||||||
from kiauh.components.klipper.klipper_dialogs import (
|
from kiauh.components.klipper.klipper_dialogs import (
|
||||||
print_missing_usergroup_dialog,
|
print_missing_usergroup_dialog,
|
||||||
@@ -34,6 +33,12 @@ from kiauh.components.klipper.klipper_dialogs import (
|
|||||||
)
|
)
|
||||||
from kiauh.components.moonraker.moonraker import Moonraker
|
from kiauh.components.moonraker.moonraker import Moonraker
|
||||||
from kiauh.components.moonraker.moonraker_utils import moonraker_to_multi_conversion
|
from kiauh.components.moonraker.moonraker_utils import moonraker_to_multi_conversion
|
||||||
|
from kiauh.core.backup_manager.backup_manager import BackupManager
|
||||||
|
from kiauh.core.config_manager.config_manager import ConfigManager
|
||||||
|
from kiauh.core.instance_manager.base_instance import BaseInstance
|
||||||
|
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
||||||
|
from kiauh.core.instance_manager.name_scheme import NameScheme
|
||||||
|
from kiauh.core.repo_manager.repo_manager import RepoManager
|
||||||
from kiauh.utils.common import get_install_status_common
|
from kiauh.utils.common import get_install_status_common
|
||||||
from kiauh.utils.constants import CURRENT_USER
|
from kiauh.utils.constants import CURRENT_USER
|
||||||
from kiauh.utils.input_utils import get_confirm, get_string_input, get_number_input
|
from kiauh.utils.input_utils import get_confirm, get_string_input, get_number_input
|
||||||
@@ -41,12 +46,10 @@ from kiauh.utils.logger import Logger
|
|||||||
from kiauh.utils.system_utils import mask_system_service
|
from kiauh.utils.system_utils import mask_system_service
|
||||||
|
|
||||||
|
|
||||||
def get_klipper_status() -> (
|
def get_klipper_status() -> Dict[
|
||||||
Dict[
|
Literal["status", "status_code", "instances", "repo", "local", "remote"],
|
||||||
Literal["status", "status_code", "instances", "repo", "local", "remote"],
|
Union[str, int],
|
||||||
Union[str, int],
|
]:
|
||||||
]
|
|
||||||
):
|
|
||||||
status = get_install_status_common(Klipper, KLIPPER_DIR, KLIPPER_ENV_DIR)
|
status = get_install_status_common(Klipper, KLIPPER_DIR, KLIPPER_ENV_DIR)
|
||||||
return {
|
return {
|
||||||
"status": status.get("status"),
|
"status": status.get("status"),
|
||||||
@@ -276,3 +279,9 @@ def create_example_printer_cfg(instance: Klipper) -> None:
|
|||||||
cm.set_value("virtual_sdcard", "path", str(instance.gcodes_dir))
|
cm.set_value("virtual_sdcard", "path", str(instance.gcodes_dir))
|
||||||
cm.write_config()
|
cm.write_config()
|
||||||
Logger.print_ok(f"Example printer.cfg created in '{instance.cfg_dir}'")
|
Logger.print_ok(f"Example printer.cfg created in '{instance.cfg_dir}'")
|
||||||
|
|
||||||
|
|
||||||
|
def backup_klipper_dir() -> None:
|
||||||
|
bm = BackupManager()
|
||||||
|
bm.backup_directory("klipper", source=KLIPPER_DIR, target=KLIPPER_BACKUP_DIR)
|
||||||
|
bm.backup_directory("klippy-env", source=KLIPPER_ENV_DIR, target=KLIPPER_BACKUP_DIR)
|
||||||
|
|||||||
@@ -11,9 +11,9 @@
|
|||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
|
from kiauh.components.klipper import klipper_remove
|
||||||
from kiauh.core.menus import BACK_HELP_FOOTER
|
from kiauh.core.menus import BACK_HELP_FOOTER
|
||||||
from kiauh.core.menus.base_menu import BaseMenu
|
from kiauh.core.menus.base_menu import BaseMenu
|
||||||
from kiauh.components.klipper import klipper_remove
|
|
||||||
from kiauh.utils.constants import RESET_FORMAT, COLOR_RED, COLOR_CYAN
|
from kiauh.utils.constants import RESET_FORMAT, COLOR_RED, COLOR_CYAN
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,14 +9,13 @@
|
|||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
|
|
||||||
from typing import List
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import List
|
||||||
|
|
||||||
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
|
||||||
from kiauh.components.klipper.klipper import Klipper
|
from kiauh.components.klipper.klipper import Klipper
|
||||||
from kiauh.components.log_uploads import LogFile
|
from kiauh.components.log_uploads import LogFile
|
||||||
|
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
||||||
from kiauh.utils.logger import Logger
|
from kiauh.utils.logger import Logger
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,10 +11,10 @@
|
|||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
|
from kiauh.components.log_uploads.log_upload_utils import get_logfile_list
|
||||||
|
from kiauh.components.log_uploads.log_upload_utils import upload_logfile
|
||||||
from kiauh.core.menus import BACK_FOOTER
|
from kiauh.core.menus import BACK_FOOTER
|
||||||
from kiauh.core.menus.base_menu import BaseMenu
|
from kiauh.core.menus.base_menu import BaseMenu
|
||||||
from kiauh.components.log_uploads.log_upload_utils import upload_logfile
|
|
||||||
from kiauh.components.log_uploads.log_upload_utils import get_logfile_list
|
|
||||||
from kiauh.utils.constants import RESET_FORMAT, COLOR_YELLOW
|
from kiauh.utils.constants import RESET_FORMAT, COLOR_YELLOW
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,10 +11,13 @@
|
|||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from kiauh.core.backup_manager import BACKUP_ROOT_DIR
|
||||||
|
|
||||||
MODULE_PATH = Path(__file__).resolve().parent
|
MODULE_PATH = Path(__file__).resolve().parent
|
||||||
MAINSAIL_DIR = Path(Path.home(), "mainsail")
|
MAINSAIL_DIR = Path.home().joinpath("mainsail")
|
||||||
MAINSAIL_CONFIG_DIR = Path(Path.home(), "mainsail-config")
|
MAINSAIL_BACKUP_DIR = BACKUP_ROOT_DIR.joinpath("mainsail-backups")
|
||||||
MAINSAIL_CONFIG_JSON = Path(MAINSAIL_DIR, "config.json")
|
MAINSAIL_CONFIG_DIR = Path.home().joinpath("mainsail-config")
|
||||||
|
MAINSAIL_CONFIG_JSON = MAINSAIL_DIR.joinpath("config.json")
|
||||||
MAINSAIL_URL = (
|
MAINSAIL_URL = (
|
||||||
"https://github.com/mainsail-crew/mainsail/releases/latest/download/mainsail.zip"
|
"https://github.com/mainsail-crew/mainsail/releases/latest/download/mainsail.zip"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ import subprocess
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from kiauh.core.config_manager.config_manager import ConfigManager
|
|
||||||
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
|
||||||
from kiauh.components.klipper.klipper import Klipper
|
from kiauh.components.klipper.klipper import Klipper
|
||||||
from kiauh.components.mainsail import MAINSAIL_DIR, MAINSAIL_CONFIG_DIR
|
from kiauh.components.mainsail import MAINSAIL_DIR, MAINSAIL_CONFIG_DIR
|
||||||
from kiauh.components.mainsail.mainsail_utils import backup_config_json
|
from kiauh.components.mainsail.mainsail_utils import backup_config_json
|
||||||
from kiauh.components.moonraker.moonraker import Moonraker
|
from kiauh.components.moonraker.moonraker import Moonraker
|
||||||
|
from kiauh.core.config_manager.config_manager import ConfigManager
|
||||||
|
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
||||||
from kiauh.utils import NGINX_SITES_AVAILABLE, NGINX_SITES_ENABLED
|
from kiauh.utils import NGINX_SITES_AVAILABLE, NGINX_SITES_ENABLED
|
||||||
from kiauh.utils.filesystem_utils import remove_file
|
from kiauh.utils.filesystem_utils import remove_file
|
||||||
from kiauh.utils.logger import Logger
|
from kiauh.utils.logger import Logger
|
||||||
|
|||||||
@@ -14,9 +14,6 @@ from pathlib import Path
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from kiauh import KIAUH_CFG
|
from kiauh import KIAUH_CFG
|
||||||
from kiauh.core.config_manager.config_manager import ConfigManager
|
|
||||||
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
|
||||||
from kiauh.core.repo_manager.repo_manager import RepoManager
|
|
||||||
from kiauh.components.klipper.klipper import Klipper
|
from kiauh.components.klipper.klipper import Klipper
|
||||||
from kiauh.components.mainsail import (
|
from kiauh.components.mainsail import (
|
||||||
MAINSAIL_URL,
|
MAINSAIL_URL,
|
||||||
@@ -38,6 +35,9 @@ from kiauh.components.mainsail.mainsail_utils import (
|
|||||||
symlink_webui_nginx_log,
|
symlink_webui_nginx_log,
|
||||||
)
|
)
|
||||||
from kiauh.components.moonraker.moonraker import Moonraker
|
from kiauh.components.moonraker.moonraker import Moonraker
|
||||||
|
from kiauh.core.config_manager.config_manager import ConfigManager
|
||||||
|
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
||||||
|
from kiauh.core.repo_manager.repo_manager import RepoManager
|
||||||
from kiauh.utils import NGINX_SITES_AVAILABLE, NGINX_SITES_ENABLED
|
from kiauh.utils import NGINX_SITES_AVAILABLE, NGINX_SITES_ENABLED
|
||||||
from kiauh.utils.common import check_install_dependencies
|
from kiauh.utils.common import check_install_dependencies
|
||||||
from kiauh.utils.filesystem_utils import (
|
from kiauh.utils.filesystem_utils import (
|
||||||
|
|||||||
@@ -11,13 +11,18 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import shutil
|
import shutil
|
||||||
import requests
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from kiauh.core.backup_manager.backup_manager import BackupManager
|
import requests
|
||||||
|
|
||||||
from kiauh.components.klipper.klipper import Klipper
|
from kiauh.components.klipper.klipper import Klipper
|
||||||
from kiauh.components.mainsail import MAINSAIL_CONFIG_JSON, MAINSAIL_DIR
|
from kiauh.components.mainsail import (
|
||||||
|
MAINSAIL_CONFIG_JSON,
|
||||||
|
MAINSAIL_DIR,
|
||||||
|
MAINSAIL_BACKUP_DIR,
|
||||||
|
)
|
||||||
|
from kiauh.core.backup_manager.backup_manager import BackupManager
|
||||||
from kiauh.utils import NGINX_SITES_AVAILABLE, NGINX_CONFD
|
from kiauh.utils import NGINX_SITES_AVAILABLE, NGINX_CONFD
|
||||||
from kiauh.utils.common import get_install_status_webui
|
from kiauh.utils.common import get_install_status_webui
|
||||||
from kiauh.utils.logger import Logger
|
from kiauh.utils.logger import Logger
|
||||||
@@ -37,9 +42,9 @@ def backup_config_json(is_temp=False) -> None:
|
|||||||
bm = BackupManager()
|
bm = BackupManager()
|
||||||
if is_temp:
|
if is_temp:
|
||||||
fn = Path.home().joinpath("config.json.kiauh.bak")
|
fn = Path.home().joinpath("config.json.kiauh.bak")
|
||||||
bm.backup_file([MAINSAIL_CONFIG_JSON], custom_filename=fn)
|
bm.backup_file(MAINSAIL_CONFIG_JSON, custom_filename=fn)
|
||||||
else:
|
else:
|
||||||
bm.backup_file([MAINSAIL_CONFIG_JSON])
|
bm.backup_file(MAINSAIL_CONFIG_JSON)
|
||||||
|
|
||||||
|
|
||||||
def restore_config_json() -> None:
|
def restore_config_json() -> None:
|
||||||
@@ -97,3 +102,12 @@ def get_mainsail_remote_version() -> str:
|
|||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
data = json.loads(response.text)
|
data = json.loads(response.text)
|
||||||
return data[0]["name"]
|
return data[0]["name"]
|
||||||
|
|
||||||
|
|
||||||
|
def backup_mainsail_data() -> None:
|
||||||
|
with open(MAINSAIL_DIR.joinpath(".version"), "r") as v:
|
||||||
|
version = v.readlines()[0]
|
||||||
|
bm = BackupManager()
|
||||||
|
bm.backup_directory(f"mainsail-{version}", MAINSAIL_DIR, MAINSAIL_BACKUP_DIR)
|
||||||
|
bm.backup_file(MAINSAIL_CONFIG_JSON, MAINSAIL_BACKUP_DIR)
|
||||||
|
bm.backup_file(NGINX_SITES_AVAILABLE.joinpath("mainsail"), MAINSAIL_BACKUP_DIR)
|
||||||
|
|||||||
@@ -11,9 +11,9 @@
|
|||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
|
from kiauh.components.mainsail import mainsail_remove
|
||||||
from kiauh.core.menus import BACK_HELP_FOOTER
|
from kiauh.core.menus import BACK_HELP_FOOTER
|
||||||
from kiauh.core.menus.base_menu import BaseMenu
|
from kiauh.core.menus.base_menu import BaseMenu
|
||||||
from kiauh.components.mainsail import mainsail_remove
|
|
||||||
from kiauh.utils.constants import RESET_FORMAT, COLOR_RED, COLOR_CYAN
|
from kiauh.utils.constants import RESET_FORMAT, COLOR_RED, COLOR_CYAN
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,10 +11,14 @@
|
|||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from kiauh.core.backup_manager import BACKUP_ROOT_DIR
|
||||||
|
|
||||||
MODULE_PATH = Path(__file__).resolve().parent
|
MODULE_PATH = Path(__file__).resolve().parent
|
||||||
|
|
||||||
MOONRAKER_DIR = Path.home().joinpath("moonraker")
|
MOONRAKER_DIR = Path.home().joinpath("moonraker")
|
||||||
MOONRAKER_ENV_DIR = Path.home().joinpath("moonraker-env")
|
MOONRAKER_ENV_DIR = Path.home().joinpath("moonraker-env")
|
||||||
|
MOONRAKER_BACKUP_DIR = BACKUP_ROOT_DIR.joinpath("moonraker-backups")
|
||||||
|
MOONRAKER_DB_BACKUP_DIR = BACKUP_ROOT_DIR.joinpath("moonraker-db-backups")
|
||||||
MOONRAKER_REQUIREMENTS_TXT = MOONRAKER_DIR.joinpath(
|
MOONRAKER_REQUIREMENTS_TXT = MOONRAKER_DIR.joinpath(
|
||||||
"scripts/moonraker-requirements.txt"
|
"scripts/moonraker-requirements.txt"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -11,9 +11,9 @@
|
|||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
|
from kiauh.components.moonraker import moonraker_remove
|
||||||
from kiauh.core.menus import BACK_HELP_FOOTER
|
from kiauh.core.menus import BACK_HELP_FOOTER
|
||||||
from kiauh.core.menus.base_menu import BaseMenu
|
from kiauh.core.menus.base_menu import BaseMenu
|
||||||
from kiauh.components.moonraker import moonraker_remove
|
|
||||||
from kiauh.utils.constants import RESET_FORMAT, COLOR_RED, COLOR_CYAN
|
from kiauh.utils.constants import RESET_FORMAT, COLOR_RED, COLOR_CYAN
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ import subprocess
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Union
|
from typing import List, Union
|
||||||
|
|
||||||
|
from kiauh.components.moonraker import MOONRAKER_DIR, MOONRAKER_ENV_DIR, MODULE_PATH
|
||||||
from kiauh.core.config_manager.config_manager import ConfigManager
|
from kiauh.core.config_manager.config_manager import ConfigManager
|
||||||
from kiauh.core.instance_manager.base_instance import BaseInstance
|
from kiauh.core.instance_manager.base_instance import BaseInstance
|
||||||
from kiauh.components.moonraker import MOONRAKER_DIR, MOONRAKER_ENV_DIR, MODULE_PATH
|
|
||||||
from kiauh.utils.constants import SYSTEMD
|
from kiauh.utils.constants import SYSTEMD
|
||||||
from kiauh.utils.logger import Logger
|
from kiauh.utils.logger import Logger
|
||||||
|
|
||||||
@@ -34,9 +34,13 @@ class Moonraker(BaseInstance):
|
|||||||
self.port = self._get_port()
|
self.port = self._get_port()
|
||||||
self.backup_dir = self.data_dir.joinpath("backup")
|
self.backup_dir = self.data_dir.joinpath("backup")
|
||||||
self.certs_dir = self.data_dir.joinpath("certs")
|
self.certs_dir = self.data_dir.joinpath("certs")
|
||||||
self.db_dir = self.data_dir.joinpath("database")
|
self._db_dir = self.data_dir.joinpath("database")
|
||||||
self.log = self.log_dir.joinpath("moonraker.log")
|
self.log = self.log_dir.joinpath("moonraker.log")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def db_dir(self) -> Path:
|
||||||
|
return self._db_dir
|
||||||
|
|
||||||
def create(self, create_example_cfg: bool = False) -> None:
|
def create(self, create_example_cfg: bool = False) -> None:
|
||||||
Logger.print_status("Creating new Moonraker Instance ...")
|
Logger.print_status("Creating new Moonraker Instance ...")
|
||||||
service_template_path = MODULE_PATH.joinpath("assets/moonraker.service")
|
service_template_path = MODULE_PATH.joinpath("assets/moonraker.service")
|
||||||
@@ -46,7 +50,7 @@ class Moonraker(BaseInstance):
|
|||||||
env_file_target = self.sysd_dir.joinpath("moonraker.env")
|
env_file_target = self.sysd_dir.joinpath("moonraker.env")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.create_folders([self.backup_dir, self.certs_dir, self.db_dir])
|
self.create_folders([self.backup_dir, self.certs_dir, self._db_dir])
|
||||||
self.write_service_file(
|
self.write_service_file(
|
||||||
service_template_path, service_file_target, env_file_target
|
service_template_path, service_file_target, env_file_target
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -12,9 +12,9 @@
|
|||||||
import textwrap
|
import textwrap
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from kiauh.core.menus.base_menu import print_back_footer
|
|
||||||
from kiauh.components.klipper.klipper import Klipper
|
from kiauh.components.klipper.klipper import Klipper
|
||||||
from kiauh.components.moonraker.moonraker import Moonraker
|
from kiauh.components.moonraker.moonraker import Moonraker
|
||||||
|
from kiauh.core.menus.base_menu import print_back_footer
|
||||||
from kiauh.utils.constants import COLOR_GREEN, RESET_FORMAT, COLOR_YELLOW, COLOR_CYAN
|
from kiauh.utils.constants import COLOR_GREEN, RESET_FORMAT, COLOR_YELLOW, COLOR_CYAN
|
||||||
|
|
||||||
|
|
||||||
@@ -39,11 +39,11 @@ def print_moonraker_overview(
|
|||||||
dialog += "| |\n"
|
dialog += "| |\n"
|
||||||
|
|
||||||
instance_map = {
|
instance_map = {
|
||||||
k.get_service_file_name(): k.get_service_file_name().replace(
|
k.get_service_file_name(): (
|
||||||
"klipper", "moonraker"
|
k.get_service_file_name().replace("klipper", "moonraker")
|
||||||
|
if k.suffix in [m.suffix for m in moonraker_instances]
|
||||||
|
else ""
|
||||||
)
|
)
|
||||||
if k.suffix in [m.suffix for m in moonraker_instances]
|
|
||||||
else ""
|
|
||||||
for k in klipper_instances
|
for k in klipper_instances
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ import shutil
|
|||||||
import subprocess
|
import subprocess
|
||||||
from typing import List, Union
|
from typing import List, Union
|
||||||
|
|
||||||
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
|
||||||
from kiauh.components.klipper.klipper_dialogs import print_instance_overview
|
from kiauh.components.klipper.klipper_dialogs import print_instance_overview
|
||||||
from kiauh.components.moonraker import MOONRAKER_DIR, MOONRAKER_ENV_DIR
|
from kiauh.components.moonraker import MOONRAKER_DIR, MOONRAKER_ENV_DIR
|
||||||
from kiauh.components.moonraker.moonraker import Moonraker
|
from kiauh.components.moonraker.moonraker import Moonraker
|
||||||
|
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
||||||
from kiauh.utils.filesystem_utils import remove_file
|
from kiauh.utils.filesystem_utils import remove_file
|
||||||
from kiauh.utils.input_utils import get_selection_input
|
from kiauh.utils.input_utils import get_selection_input
|
||||||
from kiauh.utils.logger import Logger
|
from kiauh.utils.logger import Logger
|
||||||
|
|||||||
@@ -15,12 +15,8 @@ from pathlib import Path
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from kiauh import KIAUH_CFG
|
from kiauh import KIAUH_CFG
|
||||||
from kiauh.core.backup_manager.backup_manager import BackupManager
|
|
||||||
from kiauh.core.config_manager.config_manager import ConfigManager
|
|
||||||
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
|
||||||
from kiauh.components.klipper.klipper import Klipper
|
from kiauh.components.klipper.klipper import Klipper
|
||||||
from kiauh.components.klipper.klipper_dialogs import print_instance_overview
|
from kiauh.components.klipper.klipper_dialogs import print_instance_overview
|
||||||
from kiauh.core.repo_manager.repo_manager import RepoManager
|
|
||||||
from kiauh.components.mainsail import MAINSAIL_DIR
|
from kiauh.components.mainsail import MAINSAIL_DIR
|
||||||
from kiauh.components.mainsail.mainsail_utils import enable_mainsail_remotemode
|
from kiauh.components.mainsail.mainsail_utils import enable_mainsail_remotemode
|
||||||
from kiauh.components.moonraker import (
|
from kiauh.components.moonraker import (
|
||||||
@@ -36,7 +32,13 @@ from kiauh.components.moonraker import (
|
|||||||
)
|
)
|
||||||
from kiauh.components.moonraker.moonraker import Moonraker
|
from kiauh.components.moonraker.moonraker import Moonraker
|
||||||
from kiauh.components.moonraker.moonraker_dialogs import print_moonraker_overview
|
from kiauh.components.moonraker.moonraker_dialogs import print_moonraker_overview
|
||||||
from kiauh.components.moonraker.moonraker_utils import create_example_moonraker_conf
|
from kiauh.components.moonraker.moonraker_utils import (
|
||||||
|
create_example_moonraker_conf,
|
||||||
|
backup_moonraker_dir,
|
||||||
|
)
|
||||||
|
from kiauh.core.config_manager.config_manager import ConfigManager
|
||||||
|
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
||||||
|
from kiauh.core.repo_manager.repo_manager import RepoManager
|
||||||
from kiauh.utils.filesystem_utils import check_file_exist
|
from kiauh.utils.filesystem_utils import check_file_exist
|
||||||
from kiauh.utils.input_utils import (
|
from kiauh.utils.input_utils import (
|
||||||
get_confirm,
|
get_confirm,
|
||||||
@@ -206,9 +208,7 @@ def update_moonraker() -> None:
|
|||||||
|
|
||||||
cm = ConfigManager(cfg_file=KIAUH_CFG)
|
cm = ConfigManager(cfg_file=KIAUH_CFG)
|
||||||
if cm.get_value("kiauh", "backup_before_update"):
|
if cm.get_value("kiauh", "backup_before_update"):
|
||||||
bm = BackupManager()
|
backup_moonraker_dir()
|
||||||
bm.backup_directory("moonraker", MOONRAKER_DIR)
|
|
||||||
bm.backup_directory("moonraker-env", MOONRAKER_ENV_DIR)
|
|
||||||
|
|
||||||
instance_manager = InstanceManager(Moonraker)
|
instance_manager = InstanceManager(Moonraker)
|
||||||
instance_manager.stop_all_instance()
|
instance_manager.stop_all_instance()
|
||||||
|
|||||||
@@ -12,9 +12,6 @@
|
|||||||
import shutil
|
import shutil
|
||||||
from typing import Dict, Literal, List, Union
|
from typing import Dict, Literal, List, Union
|
||||||
|
|
||||||
from kiauh.core.config_manager.config_manager import ConfigManager
|
|
||||||
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
|
||||||
from kiauh.core.repo_manager.repo_manager import RepoManager
|
|
||||||
from kiauh.components.mainsail import MAINSAIL_DIR
|
from kiauh.components.mainsail import MAINSAIL_DIR
|
||||||
from kiauh.components.mainsail.mainsail_utils import enable_mainsail_remotemode
|
from kiauh.components.mainsail.mainsail_utils import enable_mainsail_remotemode
|
||||||
from kiauh.components.moonraker import (
|
from kiauh.components.moonraker import (
|
||||||
@@ -22,8 +19,14 @@ from kiauh.components.moonraker import (
|
|||||||
MODULE_PATH,
|
MODULE_PATH,
|
||||||
MOONRAKER_DIR,
|
MOONRAKER_DIR,
|
||||||
MOONRAKER_ENV_DIR,
|
MOONRAKER_ENV_DIR,
|
||||||
|
MOONRAKER_BACKUP_DIR,
|
||||||
|
MOONRAKER_DB_BACKUP_DIR,
|
||||||
)
|
)
|
||||||
from kiauh.components.moonraker.moonraker import Moonraker
|
from kiauh.components.moonraker.moonraker import Moonraker
|
||||||
|
from kiauh.core.backup_manager.backup_manager import BackupManager
|
||||||
|
from kiauh.core.config_manager.config_manager import ConfigManager
|
||||||
|
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
||||||
|
from kiauh.core.repo_manager.repo_manager import RepoManager
|
||||||
from kiauh.utils.common import get_install_status_common
|
from kiauh.utils.common import get_install_status_common
|
||||||
from kiauh.utils.logger import Logger
|
from kiauh.utils.logger import Logger
|
||||||
from kiauh.utils.system_utils import (
|
from kiauh.utils.system_utils import (
|
||||||
@@ -31,12 +34,10 @@ from kiauh.utils.system_utils import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_moonraker_status() -> (
|
def get_moonraker_status() -> Dict[
|
||||||
Dict[
|
Literal["status", "status_code", "instances", "repo", "local", "remote"],
|
||||||
Literal["status", "status_code", "instances", "repo", "local", "remote"],
|
Union[str, int],
|
||||||
Union[str, int],
|
]:
|
||||||
]
|
|
||||||
):
|
|
||||||
status = get_install_status_common(Moonraker, MOONRAKER_DIR, MOONRAKER_ENV_DIR)
|
status = get_install_status_common(Moonraker, MOONRAKER_DIR, MOONRAKER_ENV_DIR)
|
||||||
return {
|
return {
|
||||||
"status": status.get("status"),
|
"status": status.get("status"),
|
||||||
@@ -132,3 +133,23 @@ def moonraker_to_multi_conversion(new_name: str) -> None:
|
|||||||
# if mainsail is installed, we enable mainsails remote mode
|
# if mainsail is installed, we enable mainsails remote mode
|
||||||
if MAINSAIL_DIR.exists() and len(im.instances) > 1:
|
if MAINSAIL_DIR.exists() and len(im.instances) > 1:
|
||||||
enable_mainsail_remotemode()
|
enable_mainsail_remotemode()
|
||||||
|
|
||||||
|
|
||||||
|
def backup_moonraker_dir():
|
||||||
|
bm = BackupManager()
|
||||||
|
bm.backup_directory("moonraker", source=MOONRAKER_DIR, target=MOONRAKER_BACKUP_DIR)
|
||||||
|
bm.backup_directory(
|
||||||
|
"moonraker-env", source=MOONRAKER_ENV_DIR, target=MOONRAKER_BACKUP_DIR
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def backup_moonraker_db_dir() -> None:
|
||||||
|
im = InstanceManager(Moonraker)
|
||||||
|
instances: List[Moonraker] = im.instances
|
||||||
|
bm = BackupManager()
|
||||||
|
|
||||||
|
for instance in instances:
|
||||||
|
name = f"database-{instance.data_dir_name}"
|
||||||
|
bm.backup_directory(
|
||||||
|
name, source=instance.db_dir, target=MOONRAKER_DB_BACKUP_DIR
|
||||||
|
)
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# ======================================================================= #
|
||||||
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
|
# #
|
||||||
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
|
# https://github.com/dw-0/kiauh #
|
||||||
|
# #
|
||||||
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
|
# ======================================================================= #
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
BACKUP_ROOT_DIR = Path.home().joinpath("kiauh-backups")
|
||||||
|
|||||||
@@ -13,15 +13,17 @@ import shutil
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from kiauh import KIAUH_BACKUP_DIR
|
from kiauh.core.backup_manager import BACKUP_ROOT_DIR
|
||||||
from kiauh.utils.common import get_current_date
|
from kiauh.utils.common import get_current_date
|
||||||
from kiauh.utils.logger import Logger
|
from kiauh.utils.logger import Logger
|
||||||
|
|
||||||
|
|
||||||
|
# noinspection PyUnusedLocal
|
||||||
# noinspection PyMethodMayBeStatic
|
# noinspection PyMethodMayBeStatic
|
||||||
class BackupManager:
|
class BackupManager:
|
||||||
def __init__(self, backup_root_dir: Path = KIAUH_BACKUP_DIR):
|
def __init__(self, backup_root_dir: Path = BACKUP_ROOT_DIR):
|
||||||
self._backup_root_dir = backup_root_dir
|
self._backup_root_dir = backup_root_dir
|
||||||
|
self._ignore_folders = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def backup_root_dir(self) -> Path:
|
def backup_root_dir(self) -> Path:
|
||||||
@@ -31,32 +33,38 @@ class BackupManager:
|
|||||||
def backup_root_dir(self, value: Path):
|
def backup_root_dir(self, value: Path):
|
||||||
self._backup_root_dir = value
|
self._backup_root_dir = value
|
||||||
|
|
||||||
def backup_file(
|
@property
|
||||||
self, files: List[Path] = None, target: Path = None, custom_filename=None
|
def ignore_folders(self) -> List[str]:
|
||||||
):
|
return self._ignore_folders
|
||||||
if not files:
|
|
||||||
raise ValueError("Parameter 'files' cannot be None or an empty List!")
|
@ignore_folders.setter
|
||||||
|
def ignore_folders(self, value: List[str]):
|
||||||
|
self._ignore_folders = value
|
||||||
|
|
||||||
|
def backup_file(self, file: Path = None, target: Path = None, custom_filename=None):
|
||||||
|
if not file:
|
||||||
|
raise ValueError("Parameter 'file' cannot be None!")
|
||||||
|
|
||||||
target = self.backup_root_dir if target is None else target
|
target = self.backup_root_dir if target is None else target
|
||||||
for file in files:
|
|
||||||
Logger.print_status(f"Creating backup of {file} ...")
|
Logger.print_status(f"Creating backup of {file} ...")
|
||||||
if Path(file).is_file():
|
if Path(file).is_file():
|
||||||
date = get_current_date().get("date")
|
date = get_current_date().get("date")
|
||||||
time = get_current_date().get("time")
|
time = get_current_date().get("time")
|
||||||
filename = f"{file.stem}-{date}-{time}{file.suffix}"
|
filename = f"{file.stem}-{date}-{time}{file.suffix}"
|
||||||
filename = custom_filename if custom_filename is not None else filename
|
filename = custom_filename if custom_filename is not None else filename
|
||||||
try:
|
try:
|
||||||
Path(target).mkdir(exist_ok=True)
|
Path(target).mkdir(exist_ok=True)
|
||||||
shutil.copyfile(file, target.joinpath(filename))
|
shutil.copyfile(file, target.joinpath(filename))
|
||||||
except OSError as e:
|
Logger.print_ok("Backup successfull!")
|
||||||
Logger.print_error(f"Unable to backup '{file}':\n{e}")
|
except OSError as e:
|
||||||
continue
|
Logger.print_error(f"Unable to backup '{file}':\n{e}")
|
||||||
else:
|
else:
|
||||||
Logger.print_info(f"File '{file}' not found ...")
|
Logger.print_info(f"File '{file}' not found ...")
|
||||||
|
|
||||||
def backup_directory(self, name: str, source: Path, target: Path = None) -> None:
|
def backup_directory(self, name: str, source: Path, target: Path = None) -> None:
|
||||||
if source is None or not Path(source).exists():
|
if source is None or not Path(source).exists():
|
||||||
raise OSError
|
raise OSError("Parameter 'source' is None or Path does not exist!")
|
||||||
|
|
||||||
target = self.backup_root_dir if target is None else target
|
target = self.backup_root_dir if target is None else target
|
||||||
try:
|
try:
|
||||||
@@ -64,9 +72,19 @@ class BackupManager:
|
|||||||
Logger.print_status(log)
|
Logger.print_status(log)
|
||||||
date = get_current_date().get("date")
|
date = get_current_date().get("date")
|
||||||
time = get_current_date().get("time")
|
time = get_current_date().get("time")
|
||||||
shutil.copytree(source, target.joinpath(f"{name}-{date}-{time}"))
|
shutil.copytree(
|
||||||
|
source,
|
||||||
|
target.joinpath(f"{name.lower()}-{date}-{time}"),
|
||||||
|
ignore=self.ignore_folders_func,
|
||||||
|
)
|
||||||
|
Logger.print_ok("Backup successfull!")
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
Logger.print_error(f"Unable to backup directory '{source}':\n{e}")
|
Logger.print_error(f"Unable to backup directory '{source}':\n{e}")
|
||||||
return
|
return
|
||||||
|
|
||||||
Logger.print_ok("Backup successfull!")
|
def ignore_folders_func(self, dirpath, filenames):
|
||||||
|
return (
|
||||||
|
[f for f in filenames if f in self._ignore_folders]
|
||||||
|
if self._ignore_folders is not None
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ from kiauh.core.instance_manager.base_instance import BaseInstance
|
|||||||
from kiauh.utils.constants import SYSTEMD
|
from kiauh.utils.constants import SYSTEMD
|
||||||
from kiauh.utils.logger import Logger
|
from kiauh.utils.logger import Logger
|
||||||
|
|
||||||
|
|
||||||
I = TypeVar(name="I", bound=BaseInstance, covariant=True)
|
I = TypeVar(name="I", bound=BaseInstance, covariant=True)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
89
kiauh/core/menus/backup_menu.py
Normal file
89
kiauh/core/menus/backup_menu.py
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# ======================================================================= #
|
||||||
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
|
# #
|
||||||
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
|
# https://github.com/dw-0/kiauh #
|
||||||
|
# #
|
||||||
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
|
# ======================================================================= #
|
||||||
|
|
||||||
|
import textwrap
|
||||||
|
|
||||||
|
from kiauh.components.klipper.klipper_utils import backup_klipper_dir
|
||||||
|
from kiauh.components.mainsail.mainsail_utils import backup_mainsail_data
|
||||||
|
from kiauh.components.moonraker.moonraker_utils import (
|
||||||
|
backup_moonraker_dir,
|
||||||
|
backup_moonraker_db_dir,
|
||||||
|
)
|
||||||
|
from kiauh.core.menus import BACK_FOOTER
|
||||||
|
from kiauh.core.menus.base_menu import BaseMenu
|
||||||
|
from kiauh.utils.common import backup_printer_config_dir
|
||||||
|
from kiauh.utils.constants import COLOR_CYAN, RESET_FORMAT, COLOR_YELLOW
|
||||||
|
|
||||||
|
|
||||||
|
# noinspection PyUnusedLocal
|
||||||
|
# noinspection PyMethodMayBeStatic
|
||||||
|
class BackupMenu(BaseMenu):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(
|
||||||
|
header=True,
|
||||||
|
options={
|
||||||
|
"1": self.backup_klipper,
|
||||||
|
"2": self.backup_moonraker,
|
||||||
|
"3": self.backup_printer_config,
|
||||||
|
"4": self.backup_moonraker_db,
|
||||||
|
"5": self.backup_mainsail,
|
||||||
|
},
|
||||||
|
footer_type=BACK_FOOTER,
|
||||||
|
)
|
||||||
|
|
||||||
|
def print_menu(self):
|
||||||
|
header = " [ Backup Menu ] "
|
||||||
|
line1 = f"{COLOR_YELLOW}INFO: Backups are located in '~/kiauh-backups'{RESET_FORMAT}"
|
||||||
|
color = COLOR_CYAN
|
||||||
|
count = 62 - len(color) - len(RESET_FORMAT)
|
||||||
|
menu = textwrap.dedent(
|
||||||
|
f"""
|
||||||
|
/=======================================================\\
|
||||||
|
| {color}{header:~^{count}}{RESET_FORMAT} |
|
||||||
|
|-------------------------------------------------------|
|
||||||
|
| {line1:^62} |
|
||||||
|
|-------------------------------------------------------|
|
||||||
|
| Klipper & Moonraker API: | Touchscreen GUI: |
|
||||||
|
| 1) [Klipper] | 7) [KlipperScreen] |
|
||||||
|
| 2) [Moonraker] | |
|
||||||
|
| 3) [Config Folder] | Other: |
|
||||||
|
| 4) [Moonraker Database] | 9) [Telegram Bot] |
|
||||||
|
| | |
|
||||||
|
| Klipper Webinterface: | |
|
||||||
|
| 5) [Mainsail] | |
|
||||||
|
| 6) [Fluidd] | |
|
||||||
|
"""
|
||||||
|
)[1:]
|
||||||
|
print(menu, end="")
|
||||||
|
|
||||||
|
def backup_klipper(self, **kwargs):
|
||||||
|
backup_klipper_dir()
|
||||||
|
|
||||||
|
def backup_moonraker(self, **kwargs):
|
||||||
|
backup_moonraker_dir()
|
||||||
|
|
||||||
|
def backup_printer_config(self, **kwargs):
|
||||||
|
backup_printer_config_dir()
|
||||||
|
|
||||||
|
def backup_moonraker_db(self, **kwargs):
|
||||||
|
backup_moonraker_db_dir()
|
||||||
|
|
||||||
|
def backup_mainsail(self, **kwargs):
|
||||||
|
backup_mainsail_data()
|
||||||
|
|
||||||
|
def backup_fluidd(self, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def backup_klipperscreen(self, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def backup_telegram_bot(self, **kwargs):
|
||||||
|
pass
|
||||||
@@ -13,7 +13,7 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
from abc import abstractmethod, ABC
|
from abc import abstractmethod, ABC
|
||||||
from typing import Dict, Any, Literal, Union, Callable, Type
|
from typing import Dict, Any, Literal, Union, Callable
|
||||||
|
|
||||||
from kiauh.core.menus import QUIT_FOOTER, BACK_FOOTER, BACK_HELP_FOOTER
|
from kiauh.core.menus import QUIT_FOOTER, BACK_FOOTER, BACK_HELP_FOOTER
|
||||||
from kiauh.utils.constants import (
|
from kiauh.utils.constants import (
|
||||||
|
|||||||
@@ -9,10 +9,10 @@
|
|||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
|
|
||||||
import json
|
|
||||||
import textwrap
|
|
||||||
import importlib
|
import importlib
|
||||||
import inspect
|
import inspect
|
||||||
|
import json
|
||||||
|
import textwrap
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Dict
|
from typing import List, Dict
|
||||||
|
|
||||||
|
|||||||
@@ -11,11 +11,11 @@
|
|||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from kiauh.core.menus import BACK_FOOTER
|
|
||||||
from kiauh.core.menus.base_menu import BaseMenu
|
|
||||||
from kiauh.components.klipper import klipper_setup
|
from kiauh.components.klipper import klipper_setup
|
||||||
from kiauh.components.mainsail import mainsail_setup
|
from kiauh.components.mainsail import mainsail_setup
|
||||||
from kiauh.components.moonraker import moonraker_setup
|
from kiauh.components.moonraker import moonraker_setup
|
||||||
|
from kiauh.core.menus import BACK_FOOTER
|
||||||
|
from kiauh.core.menus.base_menu import BaseMenu
|
||||||
from kiauh.utils.constants import COLOR_GREEN, RESET_FORMAT
|
from kiauh.utils.constants import COLOR_GREEN, RESET_FORMAT
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,18 +11,19 @@
|
|||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
|
from kiauh.components.klipper.klipper_utils import get_klipper_status
|
||||||
|
from kiauh.components.log_uploads.menus.log_upload_menu import LogUploadMenu
|
||||||
|
from kiauh.components.mainsail.mainsail_utils import get_mainsail_status
|
||||||
|
from kiauh.components.moonraker.moonraker_utils import get_moonraker_status
|
||||||
from kiauh.core.menus import QUIT_FOOTER
|
from kiauh.core.menus import QUIT_FOOTER
|
||||||
from kiauh.core.menus.advanced_menu import AdvancedMenu
|
from kiauh.core.menus.advanced_menu import AdvancedMenu
|
||||||
|
from kiauh.core.menus.backup_menu import BackupMenu
|
||||||
from kiauh.core.menus.base_menu import BaseMenu
|
from kiauh.core.menus.base_menu import BaseMenu
|
||||||
from kiauh.core.menus.extensions_menu import ExtensionsMenu
|
from kiauh.core.menus.extensions_menu import ExtensionsMenu
|
||||||
from kiauh.core.menus.install_menu import InstallMenu
|
from kiauh.core.menus.install_menu import InstallMenu
|
||||||
from kiauh.core.menus.remove_menu import RemoveMenu
|
from kiauh.core.menus.remove_menu import RemoveMenu
|
||||||
from kiauh.core.menus.settings_menu import SettingsMenu
|
from kiauh.core.menus.settings_menu import SettingsMenu
|
||||||
from kiauh.core.menus.update_menu import UpdateMenu
|
from kiauh.core.menus.update_menu import UpdateMenu
|
||||||
from kiauh.components.klipper.klipper_utils import get_klipper_status
|
|
||||||
from kiauh.components.log_uploads.menus.log_upload_menu import LogUploadMenu
|
|
||||||
from kiauh.components.mainsail.mainsail_utils import get_mainsail_status
|
|
||||||
from kiauh.components.moonraker.moonraker_utils import get_moonraker_status
|
|
||||||
from kiauh.utils.constants import (
|
from kiauh.utils.constants import (
|
||||||
COLOR_MAGENTA,
|
COLOR_MAGENTA,
|
||||||
COLOR_CYAN,
|
COLOR_CYAN,
|
||||||
@@ -33,6 +34,7 @@ from kiauh.utils.constants import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# noinspection PyMethodMayBeStatic
|
||||||
class MainMenu(BaseMenu):
|
class MainMenu(BaseMenu):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(
|
super().__init__(
|
||||||
@@ -43,7 +45,7 @@ class MainMenu(BaseMenu):
|
|||||||
"2": UpdateMenu,
|
"2": UpdateMenu,
|
||||||
"3": RemoveMenu,
|
"3": RemoveMenu,
|
||||||
"4": AdvancedMenu,
|
"4": AdvancedMenu,
|
||||||
"5": None,
|
"5": BackupMenu,
|
||||||
"e": ExtensionsMenu,
|
"e": ExtensionsMenu,
|
||||||
"s": SettingsMenu,
|
"s": SettingsMenu,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,11 +11,11 @@
|
|||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from kiauh.core.menus import BACK_FOOTER
|
|
||||||
from kiauh.core.menus.base_menu import BaseMenu
|
|
||||||
from kiauh.components.klipper.menus.klipper_remove_menu import KlipperRemoveMenu
|
from kiauh.components.klipper.menus.klipper_remove_menu import KlipperRemoveMenu
|
||||||
from kiauh.components.mainsail.menus.mainsail_remove_menu import MainsailRemoveMenu
|
from kiauh.components.mainsail.menus.mainsail_remove_menu import MainsailRemoveMenu
|
||||||
from kiauh.components.moonraker.menus.moonraker_remove_menu import MoonrakerRemoveMenu
|
from kiauh.components.moonraker.menus.moonraker_remove_menu import MoonrakerRemoveMenu
|
||||||
|
from kiauh.core.menus import BACK_FOOTER
|
||||||
|
from kiauh.core.menus.base_menu import BaseMenu
|
||||||
from kiauh.utils.constants import COLOR_RED, RESET_FORMAT
|
from kiauh.utils.constants import COLOR_RED, RESET_FORMAT
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,6 @@
|
|||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from kiauh.core.menus import BACK_FOOTER
|
|
||||||
from kiauh.core.menus.base_menu import BaseMenu
|
|
||||||
from kiauh.components.klipper.klipper_setup import update_klipper
|
from kiauh.components.klipper.klipper_setup import update_klipper
|
||||||
from kiauh.components.klipper.klipper_utils import (
|
from kiauh.components.klipper.klipper_utils import (
|
||||||
get_klipper_status,
|
get_klipper_status,
|
||||||
@@ -24,6 +22,8 @@ from kiauh.components.mainsail.mainsail_utils import (
|
|||||||
)
|
)
|
||||||
from kiauh.components.moonraker.moonraker_setup import update_moonraker
|
from kiauh.components.moonraker.moonraker_setup import update_moonraker
|
||||||
from kiauh.components.moonraker.moonraker_utils import get_moonraker_status
|
from kiauh.components.moonraker.moonraker_utils import get_moonraker_status
|
||||||
|
from kiauh.core.menus import BACK_FOOTER
|
||||||
|
from kiauh.core.menus.base_menu import BaseMenu
|
||||||
from kiauh.utils.constants import COLOR_GREEN, RESET_FORMAT, COLOR_YELLOW, COLOR_WHITE
|
from kiauh.utils.constants import COLOR_GREEN, RESET_FORMAT, COLOR_YELLOW, COLOR_WHITE
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
EXT_MODULE_NAME = "gcode_shell_command.py"
|
EXT_MODULE_NAME = "gcode_shell_command.py"
|
||||||
MODULE_PATH = Path(__file__).resolve().parent
|
MODULE_PATH = Path(__file__).resolve().parent
|
||||||
MODULE_ASSETS = MODULE_PATH.joinpath("assets")
|
MODULE_ASSETS = MODULE_PATH.joinpath("assets")
|
||||||
|
|||||||
@@ -3,27 +3,31 @@
|
|||||||
# Copyright (C) 2019 Eric Callahan <arksine.code@gmail.com>
|
# Copyright (C) 2019 Eric Callahan <arksine.code@gmail.com>
|
||||||
#
|
#
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import shlex
|
import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
import logging
|
|
||||||
|
|
||||||
class ShellCommand:
|
class ShellCommand:
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.name = config.get_name().split()[-1]
|
self.name = config.get_name().split()[-1]
|
||||||
self.printer = config.get_printer()
|
self.printer = config.get_printer()
|
||||||
self.gcode = self.printer.lookup_object('gcode')
|
self.gcode = self.printer.lookup_object("gcode")
|
||||||
cmd = config.get('command')
|
cmd = config.get("command")
|
||||||
cmd = os.path.expanduser(cmd)
|
cmd = os.path.expanduser(cmd)
|
||||||
self.command = shlex.split(cmd)
|
self.command = shlex.split(cmd)
|
||||||
self.timeout = config.getfloat('timeout', 2., above=0.)
|
self.timeout = config.getfloat("timeout", 2.0, above=0.0)
|
||||||
self.verbose = config.getboolean('verbose', True)
|
self.verbose = config.getboolean("verbose", True)
|
||||||
self.proc_fd = None
|
self.proc_fd = None
|
||||||
self.partial_output = ""
|
self.partial_output = ""
|
||||||
self.gcode.register_mux_command(
|
self.gcode.register_mux_command(
|
||||||
"RUN_SHELL_COMMAND", "CMD", self.name,
|
"RUN_SHELL_COMMAND",
|
||||||
|
"CMD",
|
||||||
|
self.name,
|
||||||
self.cmd_RUN_SHELL_COMMAND,
|
self.cmd_RUN_SHELL_COMMAND,
|
||||||
desc=self.cmd_RUN_SHELL_COMMAND_help)
|
desc=self.cmd_RUN_SHELL_COMMAND_help,
|
||||||
|
)
|
||||||
|
|
||||||
def _process_output(self, eventime):
|
def _process_output(self, eventime):
|
||||||
if self.proc_fd is None:
|
if self.proc_fd is None:
|
||||||
@@ -33,11 +37,11 @@ class ShellCommand:
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
data = self.partial_output + data.decode()
|
data = self.partial_output + data.decode()
|
||||||
if '\n' not in data:
|
if "\n" not in data:
|
||||||
self.partial_output = data
|
self.partial_output = data
|
||||||
return
|
return
|
||||||
elif data[-1] != '\n':
|
elif data[-1] != "\n":
|
||||||
split = data.rfind('\n') + 1
|
split = data.rfind("\n") + 1
|
||||||
self.partial_output = data[split:]
|
self.partial_output = data[split:]
|
||||||
data = data[:split]
|
data = data[:split]
|
||||||
else:
|
else:
|
||||||
@@ -45,16 +49,19 @@ class ShellCommand:
|
|||||||
self.gcode.respond_info(data)
|
self.gcode.respond_info(data)
|
||||||
|
|
||||||
cmd_RUN_SHELL_COMMAND_help = "Run a linux shell command"
|
cmd_RUN_SHELL_COMMAND_help = "Run a linux shell command"
|
||||||
|
|
||||||
def cmd_RUN_SHELL_COMMAND(self, params):
|
def cmd_RUN_SHELL_COMMAND(self, params):
|
||||||
gcode_params = params.get('PARAMS','')
|
gcode_params = params.get("PARAMS", "")
|
||||||
gcode_params = shlex.split(gcode_params)
|
gcode_params = shlex.split(gcode_params)
|
||||||
reactor = self.printer.get_reactor()
|
reactor = self.printer.get_reactor()
|
||||||
try:
|
try:
|
||||||
proc = subprocess.Popen(
|
proc = subprocess.Popen(
|
||||||
self.command + gcode_params, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
self.command + gcode_params,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.STDOUT,
|
||||||
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
logging.exception(
|
logging.exception("shell_command: Command {%s} failed" % (self.name))
|
||||||
"shell_command: Command {%s} failed" % (self.name))
|
|
||||||
raise self.gcode.error("Error running command {%s}" % (self.name))
|
raise self.gcode.error("Error running command {%s}" % (self.name))
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
self.proc_fd = proc.stdout.fileno()
|
self.proc_fd = proc.stdout.fileno()
|
||||||
@@ -64,7 +71,7 @@ class ShellCommand:
|
|||||||
endtime = eventtime + self.timeout
|
endtime = eventtime + self.timeout
|
||||||
complete = False
|
complete = False
|
||||||
while eventtime < endtime:
|
while eventtime < endtime:
|
||||||
eventtime = reactor.pause(eventtime + .05)
|
eventtime = reactor.pause(eventtime + 0.05)
|
||||||
if proc.poll() is not None:
|
if proc.poll() is not None:
|
||||||
complete = True
|
complete = True
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ class GcodeShellCmdExtension(BaseExtension):
|
|||||||
bm = BackupManager()
|
bm = BackupManager()
|
||||||
for instance in instances:
|
for instance in instances:
|
||||||
bm.backup_file(
|
bm.backup_file(
|
||||||
[instance.cfg_file],
|
instance.cfg_file,
|
||||||
custom_filename=f"{instance.suffix}.printer.cfg",
|
custom_filename=f"{instance.suffix}.printer.cfg",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,11 @@
|
|||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from kiauh.core.backup_manager import BACKUP_ROOT_DIR
|
||||||
|
|
||||||
MODULE_PATH = Path(__file__).resolve().parent
|
MODULE_PATH = Path(__file__).resolve().parent
|
||||||
INVALID_CHOICE = "Invalid choice. Please select a valid value."
|
INVALID_CHOICE = "Invalid choice. Please select a valid value."
|
||||||
|
PRINTER_CFG_BACKUP_DIR = BACKUP_ROOT_DIR.joinpath("printer-cfg-backups")
|
||||||
|
|
||||||
# ================== NGINX =====================#
|
# ================== NGINX =====================#
|
||||||
NGINX_SITES_AVAILABLE = Path("/etc/nginx/sites-available")
|
NGINX_SITES_AVAILABLE = Path("/etc/nginx/sites-available")
|
||||||
|
|||||||
@@ -13,8 +13,10 @@ from datetime import datetime
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Dict, Literal, List, Type, Union
|
from typing import Dict, Literal, List, Type, Union
|
||||||
|
|
||||||
|
from kiauh.components.klipper.klipper import Klipper
|
||||||
from kiauh.core.instance_manager.base_instance import BaseInstance
|
from kiauh.core.instance_manager.base_instance import BaseInstance
|
||||||
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
||||||
|
from kiauh.utils import PRINTER_CFG_BACKUP_DIR
|
||||||
from kiauh.utils.constants import (
|
from kiauh.utils.constants import (
|
||||||
COLOR_CYAN,
|
COLOR_CYAN,
|
||||||
RESET_FORMAT,
|
RESET_FORMAT,
|
||||||
@@ -116,3 +118,20 @@ def get_install_status_webui(
|
|||||||
return f"{COLOR_RED}Not installed!{RESET_FORMAT}"
|
return f"{COLOR_RED}Not installed!{RESET_FORMAT}"
|
||||||
else:
|
else:
|
||||||
return f"{COLOR_YELLOW}Incomplete!{RESET_FORMAT}"
|
return f"{COLOR_YELLOW}Incomplete!{RESET_FORMAT}"
|
||||||
|
|
||||||
|
|
||||||
|
def backup_printer_config_dir():
|
||||||
|
# local import to prevent circular import
|
||||||
|
from kiauh.core.backup_manager.backup_manager import BackupManager
|
||||||
|
|
||||||
|
im = InstanceManager(Klipper)
|
||||||
|
instances: List[Klipper] = im.instances
|
||||||
|
bm = BackupManager()
|
||||||
|
|
||||||
|
for instance in instances:
|
||||||
|
name = f"config-{instance.data_dir_name}"
|
||||||
|
bm.backup_directory(
|
||||||
|
name,
|
||||||
|
source=instance.cfg_dir,
|
||||||
|
target=PRINTER_CFG_BACKUP_DIR,
|
||||||
|
)
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ def download_progress(block_num, block_size, total_size) -> None:
|
|||||||
mb = 1024 * 1024
|
mb = 1024 * 1024
|
||||||
progress = int(percent / 5)
|
progress = int(percent / 5)
|
||||||
remaining = "-" * (20 - progress)
|
remaining = "-" * (20 - progress)
|
||||||
dl = f"\rDownloading: [{'#' * progress}{remaining}]{percent:.2f}% ({downloaded/mb:.2f}/{total_size/mb:.2f}MB)"
|
dl = f"\rDownloading: [{'#' * progress}{remaining}]{percent:.2f}% ({downloaded / mb:.2f}/{total_size / mb:.2f}MB)"
|
||||||
sys.stdout.write(dl)
|
sys.stdout.write(dl)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
[mcu]
|
[mcu]
|
||||||
serial: /dev/serial/by-id/<your-mcu-id>
|
serial: /dev/serial/by-id/<your-mcu-id>
|
||||||
|
|
||||||
|
[virtual_sdcard]
|
||||||
|
path: %GCODES_DIR%
|
||||||
|
on_error_gcode: CANCEL_PRINT
|
||||||
|
|
||||||
[printer]
|
[printer]
|
||||||
kinematics: none
|
kinematics: none
|
||||||
max_velocity: 1000
|
max_velocity: 1000
|
||||||
max_accel: 1000
|
max_accel: 1000
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -33,23 +33,25 @@ function backup_before_update() {
|
|||||||
|
|
||||||
function backup_config_dir() {
|
function backup_config_dir() {
|
||||||
check_for_backup_dir
|
check_for_backup_dir
|
||||||
local current_date instance_names config_pathes
|
local current_date config_pathes
|
||||||
|
|
||||||
config_pathes=$(get_config_folders)
|
config_pathes=$(get_config_folders)
|
||||||
readarray -t -d" " instance_names < <(get_multi_instance_names)
|
|
||||||
|
|
||||||
if [[ -n "${config_pathes}" ]]; then
|
if [[ -n "${config_pathes}" ]]; then
|
||||||
current_date=$(get_date)
|
current_date=$(get_date)
|
||||||
status_msg "Timestamp: ${current_date}"
|
status_msg "Timestamp: ${current_date}"
|
||||||
|
|
||||||
local i=0 folder
|
local i=0 folder folder_name target_dir
|
||||||
for folder in ${config_pathes}; do
|
for folder in ${config_pathes}; do
|
||||||
local folder_name="${instance_names[${i}]}"
|
|
||||||
status_msg "Create backup of ${folder} ..."
|
status_msg "Create backup of ${folder} ..."
|
||||||
mkdir -p "${BACKUP_DIR}/configs/${current_date}/${folder_name}"
|
|
||||||
cp -r "${folder}" "${_}"
|
folder_name=$(echo "${folder}" | rev | cut -d"/" -f2 | rev)
|
||||||
ok_msg "Backup created in:\n${BACKUP_DIR}/configs/${current_date}/${folder_name}"
|
target_dir="${BACKUP_DIR}/configs/${current_date}/${folder_name}"
|
||||||
|
mkdir -p "${target_dir}"
|
||||||
|
cp -r "${folder}" "${target_dir}"
|
||||||
i=$(( i + 1 ))
|
i=$(( i + 1 ))
|
||||||
|
|
||||||
|
ok_msg "Backup created in:\n${target_dir}"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
ok_msg "No config directory found! Skipping backup ..."
|
ok_msg "No config directory found! Skipping backup ..."
|
||||||
@@ -61,20 +63,22 @@ function backup_moonraker_database() {
|
|||||||
local current_date db_pathes
|
local current_date db_pathes
|
||||||
|
|
||||||
db_pathes=$(get_instance_folder_path "database")
|
db_pathes=$(get_instance_folder_path "database")
|
||||||
readarray -t -d" " instance_names < <(get_multi_instance_names)
|
|
||||||
|
|
||||||
if [[ -n ${db_pathes} ]]; then
|
if [[ -n ${db_pathes} ]]; then
|
||||||
current_date=$(get_date)
|
current_date=$(get_date)
|
||||||
status_msg "Timestamp: ${current_date}"
|
status_msg "Timestamp: ${current_date}"
|
||||||
|
|
||||||
local i=0 database
|
local i=0 database folder_name target_dir
|
||||||
for database in ${db_pathes}; do
|
for database in ${db_pathes}; do
|
||||||
local folder_name="${instance_names[${i}]}"
|
|
||||||
status_msg "Create backup of ${database} ..."
|
status_msg "Create backup of ${database} ..."
|
||||||
mkdir -p "${BACKUP_DIR}/moonraker_databases/${current_date}/${folder_name}"
|
|
||||||
cp -r "${database}" "${_}"
|
folder_name=$(echo "${database}" | rev | cut -d"/" -f2 | rev)
|
||||||
ok_msg "Backup created in:\n${BACKUP_DIR}/moonraker_databases/${current_date}/${folder_name}"
|
target_dir="${BACKUP_DIR}/moonraker_databases/${current_date}/${folder_name}"
|
||||||
|
mkdir -p "${target_dir}"
|
||||||
|
cp -r "${database}" "${target_dir}"
|
||||||
i=$(( i + 1 ))
|
i=$(( i + 1 ))
|
||||||
|
|
||||||
|
ok_msg "Backup created in:\n${target_dir}"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
print_error "No Moonraker database found! Skipping backup ..."
|
print_error "No Moonraker database found! Skipping backup ..."
|
||||||
@@ -191,3 +195,19 @@ function backup_telegram_bot() {
|
|||||||
print_error "Can't back up MoonrakerTelegramBot directory!\n Not found!"
|
print_error "Can't back up MoonrakerTelegramBot directory!\n Not found!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function backup_octoeverywhere() {
|
||||||
|
local current_date
|
||||||
|
|
||||||
|
if [[ -d ${OCTOEVERYWHERE_DIR} ]] ; then
|
||||||
|
status_msg "Creating OctoEverywhere backup ..."
|
||||||
|
check_for_backup_dir
|
||||||
|
current_date=$(get_date)
|
||||||
|
status_msg "Timestamp: ${current_date}"
|
||||||
|
mkdir -p "${BACKUP_DIR}/OctoEverywhere-backups/${current_date}"
|
||||||
|
cp -r "${OCTOEVERYWHERE_DIR}" "${_}" && cp -r "${OCTOEVERYWHERE_ENV}" "${_}"
|
||||||
|
print_confirm "OctoEverywhere backup complete!"
|
||||||
|
else
|
||||||
|
print_error "Can't back up OctoEverywhere directory!\n Not found!"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -52,16 +52,57 @@ function init_flash_process() {
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
### step 2: select how the mcu is connected to the host
|
### step 2: select how the mcu is flashed (flash/serialflash)
|
||||||
|
select_flash_command
|
||||||
|
|
||||||
|
### step 3: select how the mcu is connected to the host
|
||||||
select_mcu_connection
|
select_mcu_connection
|
||||||
|
|
||||||
### step 3: select which detected mcu should be flashed
|
### step 4: select which detected mcu should be flashed
|
||||||
select_mcu_id "${method}"
|
select_mcu_id "${method}"
|
||||||
}
|
}
|
||||||
|
|
||||||
#================================================#
|
#================================================#
|
||||||
#=================== STEP 2 =====================#
|
#=================== STEP 2 =====================#
|
||||||
#================================================#
|
#================================================#
|
||||||
|
function select_flash_command() {
|
||||||
|
unset flash_command
|
||||||
|
|
||||||
|
top_border
|
||||||
|
echo -e "| How to flash MCU? |"
|
||||||
|
echo -e "| 1) make flash (default) |"
|
||||||
|
echo -e "| 2) make serialflash (stm32flash) |"
|
||||||
|
blank_line
|
||||||
|
back_help_footer
|
||||||
|
|
||||||
|
local choice
|
||||||
|
while true; do
|
||||||
|
read -p "${cyan}###### Flashing command:${white} " -i "1" -e choice
|
||||||
|
case "${choice}" in
|
||||||
|
1)
|
||||||
|
select_msg "Selected 'make flash' command"
|
||||||
|
flash_command="flash"
|
||||||
|
break;;
|
||||||
|
2)
|
||||||
|
select_msg "Selected 'make serialflash' command"
|
||||||
|
flash_command="serialflash"
|
||||||
|
break;;
|
||||||
|
B|b)
|
||||||
|
advanced_menu
|
||||||
|
break;;
|
||||||
|
H|h)
|
||||||
|
clear && print_header
|
||||||
|
show_mcu_flash_command_help
|
||||||
|
break;;
|
||||||
|
*)
|
||||||
|
error_msg "Invalid command!";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
#================================================#
|
||||||
|
#=================== STEP 3 =====================#
|
||||||
|
#================================================#
|
||||||
function select_mcu_connection() {
|
function select_mcu_connection() {
|
||||||
top_border
|
top_border
|
||||||
echo -e "| ${yellow}Make sure that the controller board is connected now!${white} |"
|
echo -e "| ${yellow}Make sure that the controller board is connected now!${white} |"
|
||||||
@@ -112,7 +153,6 @@ function print_detected_mcu_to_screen() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
for mcu in "${mcu_list[@]}"; do
|
for mcu in "${mcu_list[@]}"; do
|
||||||
mcu=$(echo "${mcu}" | rev | cut -d"/" -f1 | rev)
|
|
||||||
echo -e " ● MCU #${i}: ${cyan}${mcu}${white}"
|
echo -e " ● MCU #${i}: ${cyan}${mcu}${white}"
|
||||||
i=$(( i + 1 ))
|
i=$(( i + 1 ))
|
||||||
done
|
done
|
||||||
@@ -120,7 +160,7 @@ function print_detected_mcu_to_screen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#================================================#
|
#================================================#
|
||||||
#=================== STEP 3 =====================#
|
#=================== STEP 4 =====================#
|
||||||
#================================================#
|
#================================================#
|
||||||
function select_mcu_id() {
|
function select_mcu_id() {
|
||||||
local i=0 sel_index=0 method=${1}
|
local i=0 sel_index=0 method=${1}
|
||||||
@@ -195,7 +235,7 @@ function start_flash_mcu() {
|
|||||||
local device=${1}
|
local device=${1}
|
||||||
do_action_service "stop" "klipper"
|
do_action_service "stop" "klipper"
|
||||||
|
|
||||||
if make flash FLASH_DEVICE="${device}"; then
|
if make ${flash_command} FLASH_DEVICE="${device}"; then
|
||||||
ok_msg "Flashing successfull!"
|
ok_msg "Flashing successfull!"
|
||||||
else
|
else
|
||||||
warn_msg "Flashing failed!"
|
warn_msg "Flashing failed!"
|
||||||
@@ -387,6 +427,36 @@ function show_flash_method_help() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function show_mcu_flash_command_help() {
|
||||||
|
top_border
|
||||||
|
echo -e "| ~~~~~~~~ < ? > Help: Flash MCU < ? > ~~~~~~~~ |"
|
||||||
|
hr
|
||||||
|
echo -e "| ${cyan}make flash:${white} |"
|
||||||
|
echo -e "| The default command to flash controller board, it |"
|
||||||
|
echo -e "| will detect selected microcontroller and use suitable |"
|
||||||
|
echo -e "| tool for flashing it. |"
|
||||||
|
blank_line
|
||||||
|
echo -e "| ${cyan}make serialflash:${white} |"
|
||||||
|
echo -e "| Special command to flash STM32 microcontrollers in |"
|
||||||
|
echo -e "| DFU mode but connected via serial. stm32flash command |"
|
||||||
|
echo -e "| will be used internally. |"
|
||||||
|
blank_line
|
||||||
|
back_footer
|
||||||
|
|
||||||
|
local choice
|
||||||
|
while true; do
|
||||||
|
read -p "${cyan}###### Please select:${white} " choice
|
||||||
|
case "${choice}" in
|
||||||
|
B|b)
|
||||||
|
clear && print_header
|
||||||
|
select_flash_command
|
||||||
|
break;;
|
||||||
|
*)
|
||||||
|
error_msg "Invalid command!";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
function show_mcu_connection_help() {
|
function show_mcu_connection_help() {
|
||||||
top_border
|
top_border
|
||||||
echo -e "| ~~~~~~~~ < ? > Help: Flash MCU < ? > ~~~~~~~~ |"
|
echo -e "| ~~~~~~~~ < ? > Help: Flash MCU < ? > ~~~~~~~~ |"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -244,6 +244,7 @@ function run_klipper_setup() {
|
|||||||
|
|
||||||
### finalizing the setup with writing instance names to the kiauh.ini
|
### finalizing the setup with writing instance names to the kiauh.ini
|
||||||
set_multi_instance_names
|
set_multi_instance_names
|
||||||
|
mask_disrupting_services
|
||||||
|
|
||||||
print_confirm "${confirm}" && return
|
print_confirm "${confirm}" && return
|
||||||
}
|
}
|
||||||
@@ -333,6 +334,7 @@ function create_klipper_service() {
|
|||||||
|
|
||||||
local printer_data
|
local printer_data
|
||||||
local cfg_dir
|
local cfg_dir
|
||||||
|
local gcodes_dir
|
||||||
local cfg
|
local cfg
|
||||||
local log
|
local log
|
||||||
local klippy_serial
|
local klippy_serial
|
||||||
@@ -345,6 +347,7 @@ function create_klipper_service() {
|
|||||||
|
|
||||||
printer_data="${HOME}/${instance_name}_data"
|
printer_data="${HOME}/${instance_name}_data"
|
||||||
cfg_dir="${printer_data}/config"
|
cfg_dir="${printer_data}/config"
|
||||||
|
gcodes_dir="${printer_data}/gcodes"
|
||||||
cfg="${cfg_dir}/printer.cfg"
|
cfg="${cfg_dir}/printer.cfg"
|
||||||
log="${printer_data}/logs/klippy.log"
|
log="${printer_data}/logs/klippy.log"
|
||||||
klippy_serial="${printer_data}/comms/klippy.serial"
|
klippy_serial="${printer_data}/comms/klippy.serial"
|
||||||
@@ -375,18 +378,20 @@ function create_klipper_service() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -f ${cfg} ]]; then
|
if [[ ! -f ${cfg} ]]; then
|
||||||
write_example_printer_cfg "${cfg}"
|
write_example_printer_cfg "${cfg}" "${gcodes_dir}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function write_example_printer_cfg() {
|
function write_example_printer_cfg() {
|
||||||
local cfg=${1}
|
local cfg=${1}
|
||||||
|
local gcodes_dir=${2}
|
||||||
local cfg_template
|
local cfg_template
|
||||||
|
|
||||||
cfg_template="${KIAUH_SRCDIR}/resources/example.printer.cfg"
|
cfg_template="${KIAUH_SRCDIR}/resources/example.printer.cfg"
|
||||||
|
|
||||||
status_msg "Creating minimal example printer.cfg ..."
|
status_msg "Creating minimal example printer.cfg ..."
|
||||||
if cp "${cfg_template}" "${cfg}"; then
|
if cp "${cfg_template}" "${cfg}"; then
|
||||||
|
sed -i "s|%GCODES_DIR%|${gcodes_dir}|" "${cfg}"
|
||||||
ok_msg "Minimal example printer.cfg created!"
|
ok_msg "Minimal example printer.cfg created!"
|
||||||
else
|
else
|
||||||
error_msg "Couldn't create minimal example printer.cfg!"
|
error_msg "Couldn't create minimal example printer.cfg!"
|
||||||
@@ -625,3 +630,34 @@ function get_klipper_python_ver() {
|
|||||||
version=$("${KLIPPY_ENV}"/bin/python --version 2>&1 | cut -d" " -f2 | cut -d"." -f1)
|
version=$("${KLIPPY_ENV}"/bin/python --version 2>&1 | cut -d" " -f2 | cut -d"." -f1)
|
||||||
echo "${version}"
|
echo "${version}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mask_disrupting_services() {
|
||||||
|
local brltty="false"
|
||||||
|
local brltty_udev="false"
|
||||||
|
local modem_manager="false"
|
||||||
|
|
||||||
|
[[ $(dpkg -s brltty 2>/dev/null | grep "Status") = *\ installed ]] && brltty="true"
|
||||||
|
[[ $(dpkg -s brltty-udev 2>/dev/null | grep "Status") = *\ installed ]] && brltty_udev="true"
|
||||||
|
[[ $(dpkg -s ModemManager 2>/dev/null | grep "Status") = *\ installed ]] && modem_manager="true"
|
||||||
|
|
||||||
|
status_msg "Installed brltty package detected, masking brltty service ..."
|
||||||
|
if [[ ${brltty} == "true" ]]; then
|
||||||
|
sudo systemctl stop brltty
|
||||||
|
sudo systemctl mask brltty
|
||||||
|
fi
|
||||||
|
ok_msg "brltty service masked!"
|
||||||
|
|
||||||
|
status_msg "Installed brltty-udev package detected, masking brltty-udev service ..."
|
||||||
|
if [[ ${brltty_udev} == "true" ]]; then
|
||||||
|
sudo systemctl stop brltty-udev
|
||||||
|
sudo systemctl mask brltty-udev
|
||||||
|
fi
|
||||||
|
ok_msg "brltty-udev service masked!"
|
||||||
|
|
||||||
|
status_msg "Installed ModemManager package detected, masking ModemManager service ..."
|
||||||
|
if [[ ${modem_manager} == "true" ]]; then
|
||||||
|
sudo systemctl stop ModemManager
|
||||||
|
sudo systemctl mask ModemManager
|
||||||
|
fi
|
||||||
|
ok_msg "ModemManager service masked!"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -119,6 +119,8 @@ function update_klipperscreen() {
|
|||||||
old_md5=$(md5sum "${KLIPPERSCREEN_DIR}/scripts/KlipperScreen-requirements.txt" | cut -d " " -f1)
|
old_md5=$(md5sum "${KLIPPERSCREEN_DIR}/scripts/KlipperScreen-requirements.txt" | cut -d " " -f1)
|
||||||
|
|
||||||
do_action_service "stop" "KlipperScreen"
|
do_action_service "stop" "KlipperScreen"
|
||||||
|
backup_before_update "klipperscreen"
|
||||||
|
|
||||||
cd "${KLIPPERSCREEN_DIR}"
|
cd "${KLIPPERSCREEN_DIR}"
|
||||||
git pull origin master -q && ok_msg "Fetch successfull!"
|
git pull origin master -q && ok_msg "Fetch successfull!"
|
||||||
git checkout -f master && ok_msg "Checkout successfull"
|
git checkout -f master && ok_msg "Checkout successfull"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -63,7 +63,7 @@ function obico_server_url_prompt() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function moonraker_obico_setup_dialog() {
|
function moonraker_obico_setup_dialog() {
|
||||||
status_msg "Initializing Moonraker-obico installation ..."
|
status_msg "Initializing Obico installation ..."
|
||||||
|
|
||||||
local moonraker_count
|
local moonraker_count
|
||||||
local moonraker_names
|
local moonraker_names
|
||||||
@@ -73,7 +73,7 @@ function moonraker_obico_setup_dialog() {
|
|||||||
if (( moonraker_count == 0 )); then
|
if (( moonraker_count == 0 )); then
|
||||||
### return early if moonraker is not installed
|
### return early if moonraker is not installed
|
||||||
local error="Moonraker not installed! Please install Moonraker first!"
|
local error="Moonraker not installed! Please install Moonraker first!"
|
||||||
log_error "Moonraker-obico setup started without Moonraker being installed. Aborting setup."
|
log_error "Obico setup started without Moonraker being installed. Aborting setup."
|
||||||
print_error "${error}" && return
|
print_error "${error}" && return
|
||||||
elif (( moonraker_count > 1 )); then
|
elif (( moonraker_count > 1 )); then
|
||||||
# moonraker_names is valid only in case of multi-instance
|
# moonraker_names is valid only in case of multi-instance
|
||||||
@@ -90,10 +90,10 @@ function moonraker_obico_setup_dialog() {
|
|||||||
if (( allowed_moonraker_obico_count == 0 && moonraker_count > 0 )) && [[ $(get_moonraker_obico_status) != "Not linked!" ]]; then
|
if (( allowed_moonraker_obico_count == 0 && moonraker_count > 0 )) && [[ $(get_moonraker_obico_status) != "Not linked!" ]]; then
|
||||||
local yn
|
local yn
|
||||||
while true; do
|
while true; do
|
||||||
echo "${yellow}Obico for Klipper is already installed.${white}"
|
echo "${yellow}Obico is already installed.${white}"
|
||||||
echo "It is safe to run the install again to repair any issues."
|
echo "It is safe to run the install again to repair any issues."
|
||||||
echo ""
|
echo ""
|
||||||
local question="Do you want to reinstall Obico for Klipper?"
|
local question="Do you want to reinstall Obico?"
|
||||||
read -p "${cyan}###### ${question} (Y/n):${white} " yn
|
read -p "${cyan}###### ${question} (Y/n):${white} " yn
|
||||||
case "${yn}" in
|
case "${yn}" in
|
||||||
Y|y|Yes|yes|"")
|
Y|y|Yes|yes|"")
|
||||||
@@ -101,7 +101,7 @@ function moonraker_obico_setup_dialog() {
|
|||||||
break;;
|
break;;
|
||||||
N|n|No|no)
|
N|n|No|no)
|
||||||
select_msg "No"
|
select_msg "No"
|
||||||
abort_msg "Exiting Obico for Klipper installation...\n"
|
abort_msg "Exiting Obico installation...\n"
|
||||||
return;;
|
return;;
|
||||||
*)
|
*)
|
||||||
error_msg "Invalid Input!";;
|
error_msg "Invalid Input!";;
|
||||||
@@ -126,31 +126,30 @@ function moonraker_obico_setup_dialog() {
|
|||||||
done
|
done
|
||||||
blank_line
|
blank_line
|
||||||
if (( existing_moonraker_obico_count > 0 )); then
|
if (( existing_moonraker_obico_count > 0 )); then
|
||||||
printf "|${green}%-55s${white}|\n" " ${existing_moonraker_obico_count} Moonraker-obico instances already installed!"
|
printf "|${green}%-55s${white}|\n" " ${existing_moonraker_obico_count} Obico instances already installed!"
|
||||||
for svc in ${moonraker_obico_services}; do
|
for svc in ${moonraker_obico_services}; do
|
||||||
printf "|${cyan}%-57s${white}|\n" " ● moonraker-obco-$(get_instance_name "${svc}")"
|
printf "|${cyan}%-57s${white}|\n" " ● moonraker-obco-$(get_instance_name "${svc}")"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
blank_line
|
blank_line
|
||||||
echo -e "| The setup will apply the same names to |"
|
echo -e "| The setup will apply the same names to Obico! |"
|
||||||
echo -e "| Moonraker-obico! |"
|
|
||||||
blank_line
|
blank_line
|
||||||
echo -e "| Please select the number of Moonraker-obico instances |"
|
echo -e "| Please select the number of Obico instances |"
|
||||||
echo -e "| to install. Usually one Moonraker-obico instance per |"
|
echo -e "| to install. Usually one Obico instance per |"
|
||||||
echo -e "| Moonraker instance is required, but you may not |"
|
echo -e "| Moonraker instance is required, but you may not |"
|
||||||
echo -e "| install more Moonraker-obico instances than available |"
|
echo -e "| install more Obico instances than available |"
|
||||||
echo -e "| Moonraker instances. |"
|
echo -e "| Moonraker instances. |"
|
||||||
bottom_border
|
bottom_border
|
||||||
|
|
||||||
### ask for amount of instances
|
### ask for amount of instances
|
||||||
local re="^[1-9][0-9]*$"
|
local re="^[1-9][0-9]*$"
|
||||||
while [[ ! ${new_moonraker_obico_count} =~ ${re} || ${new_moonraker_obico_count} -gt ${allowed_moonraker_obico_count} ]]; do
|
while [[ ! ${new_moonraker_obico_count} =~ ${re} || ${new_moonraker_obico_count} -gt ${allowed_moonraker_obico_count} ]]; do
|
||||||
read -p "${cyan}###### Number of new Moonraker-obico instances to set up:${white} " -i "${allowed_moonraker_obico_count}" -e new_moonraker_obico_count
|
read -p "${cyan}###### Number of new Obico instances to set up:${white} " -i "${allowed_moonraker_obico_count}" -e new_moonraker_obico_count
|
||||||
### break if input is valid
|
### break if input is valid
|
||||||
[[ ${new_moonraker_obico_count} =~ ${re} && ${new_moonraker_obico_count} -le ${allowed_moonraker_obico_count} ]] && break
|
[[ ${new_moonraker_obico_count} =~ ${re} && ${new_moonraker_obico_count} -le ${allowed_moonraker_obico_count} ]] && break
|
||||||
### conditional error messages
|
### conditional error messages
|
||||||
[[ ! ${new_moonraker_obico_count} =~ ${re} ]] && error_msg "Input not a number"
|
[[ ! ${new_moonraker_obico_count} =~ ${re} ]] && error_msg "Input not a number"
|
||||||
(( new_moonraker_obico_count > allowed_moonraker_obico_count )) && error_msg "Number of Moonraker-obico instances larger than installed Moonraker instances"
|
(( new_moonraker_obico_count > allowed_moonraker_obico_count )) && error_msg "Number of Obico instances larger than installed Moonraker instances"
|
||||||
done && select_msg "${new_moonraker_obico_count}"
|
done && select_msg "${new_moonraker_obico_count}"
|
||||||
else
|
else
|
||||||
log_error "Internal error. moonraker_count of '${moonraker_count}' not equal or grather than one!"
|
log_error "Internal error. moonraker_count of '${moonraker_count}' not equal or grather than one!"
|
||||||
@@ -160,8 +159,8 @@ function moonraker_obico_setup_dialog() {
|
|||||||
### Step 2: Confirm instance amount
|
### Step 2: Confirm instance amount
|
||||||
local yn
|
local yn
|
||||||
while true; do
|
while true; do
|
||||||
(( new_moonraker_obico_count == 1 )) && local question="Install Moonraker-obico?"
|
(( new_moonraker_obico_count == 1 )) && local question="Install Obico?"
|
||||||
(( new_moonraker_obico_count > 1 )) && local question="Install ${new_moonraker_obico_count} Moonraker-obico instances?"
|
(( new_moonraker_obico_count > 1 )) && local question="Install ${new_moonraker_obico_count} Obico instances?"
|
||||||
read -p "${cyan}###### ${question} (Y/n):${white} " yn
|
read -p "${cyan}###### ${question} (Y/n):${white} " yn
|
||||||
case "${yn}" in
|
case "${yn}" in
|
||||||
Y|y|Yes|yes|"")
|
Y|y|Yes|yes|"")
|
||||||
@@ -169,7 +168,7 @@ function moonraker_obico_setup_dialog() {
|
|||||||
break;;
|
break;;
|
||||||
N|n|No|no)
|
N|n|No|no)
|
||||||
select_msg "No"
|
select_msg "No"
|
||||||
abort_msg "Exiting Moonraker-obico setup ...\n"
|
abort_msg "Exiting Obico setup ...\n"
|
||||||
return;;
|
return;;
|
||||||
*)
|
*)
|
||||||
error_msg "Invalid Input!";;
|
error_msg "Invalid Input!";;
|
||||||
@@ -191,8 +190,8 @@ function moonraker_obico_setup_dialog() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
(( new_moonraker_obico_count > 1 )) && status_msg "Installing ${new_moonraker_obico_count} Moonraker-obico instances ..."
|
(( new_moonraker_obico_count > 1 )) && status_msg "Installing ${new_moonraker_obico_count} Obico instances ..."
|
||||||
(( new_moonraker_obico_count == 1 )) && status_msg "Installing Moonraker-obico ..."
|
(( new_moonraker_obico_count == 1 )) && status_msg "Installing Obico ..."
|
||||||
|
|
||||||
### Step 5: Clone the moonraker-obico repo
|
### Step 5: Clone the moonraker-obico repo
|
||||||
clone_moonraker_obico "${MOONRAKER_OBICO_REPO}"
|
clone_moonraker_obico "${MOONRAKER_OBICO_REPO}"
|
||||||
@@ -244,17 +243,16 @@ function moonraker_obico_setup_dialog() {
|
|||||||
if (( ${#not_linked_instances[@]} > 0 )); then
|
if (( ${#not_linked_instances[@]} > 0 )); then
|
||||||
top_border
|
top_border
|
||||||
if (( moonraker_count == 1 )); then
|
if (( moonraker_count == 1 )); then
|
||||||
printf "|${green}%-55s${white}|\n" " Moonraker-obico not linked to the server!"
|
printf "|${green}%-55s${white}|\n" " Obico not linked to the server!"
|
||||||
else
|
else
|
||||||
printf "|${green}%-55s${white}|\n" " ${#not_linked_instances[@]} Moonraker-obico instances not linked to the server!"
|
printf "|${green}%-55s${white}|\n" " ${#not_linked_instances[@]} Obico instances not linked to the server!"
|
||||||
for i in "${not_linked_instances[@]}"; do
|
for i in "${not_linked_instances[@]}"; do
|
||||||
printf "|${cyan}%-57s${white}|\n" " ● moonraker-obico-${moonraker_names[${i}]}"
|
printf "|${cyan}%-57s${white}|\n" " ● moonraker-obico-${moonraker_names[${i}]}"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
blank_line
|
blank_line
|
||||||
echo -e "| To link to your Obico Server account, you need to |"
|
echo -e "| It will take only 10 seconds to link printer to Obico.|"
|
||||||
echo -e "| obtain the 6-digit verification code in the Obico |"
|
echo -e "| For more information, visit: |"
|
||||||
echo -e "| mobile or web app. For more information, visit: |"
|
|
||||||
echo -e "| https://www.obico.io/docs/user-guides/klipper-setup/ |"
|
echo -e "| https://www.obico.io/docs/user-guides/klipper-setup/ |"
|
||||||
blank_line
|
blank_line
|
||||||
echo -e "| If you don't want to link the printer now, you can |"
|
echo -e "| If you don't want to link the printer now, you can |"
|
||||||
@@ -272,7 +270,7 @@ function moonraker_obico_setup_dialog() {
|
|||||||
break;;
|
break;;
|
||||||
N|n|No|no)
|
N|n|No|no)
|
||||||
select_msg "No"
|
select_msg "No"
|
||||||
abort_msg "Exiting Moonraker-obico setup ...\n"
|
abort_msg "Exiting Obico setup ...\n"
|
||||||
return;;
|
return;;
|
||||||
*)
|
*)
|
||||||
error_msg "Invalid Input!";;
|
error_msg "Invalid Input!";;
|
||||||
@@ -295,13 +293,13 @@ function moonraker_obico_setup_dialog() {
|
|||||||
function clone_moonraker_obico() {
|
function clone_moonraker_obico() {
|
||||||
local repo=${1}
|
local repo=${1}
|
||||||
|
|
||||||
status_msg "Cloning Moonraker-obico from ${repo} ..."
|
status_msg "Cloning Obico from ${repo} ..."
|
||||||
### force remove existing Moonraker-obico dir
|
### force remove existing Obico dir
|
||||||
[[ -d "${MOONRAKER_OBICO_DIR}" ]] && rm -rf "${MOONRAKER_OBICO_DIR}"
|
[[ -d "${MOONRAKER_OBICO_DIR}" ]] && rm -rf "${MOONRAKER_OBICO_DIR}"
|
||||||
|
|
||||||
cd "${HOME}" || exit 1
|
cd "${HOME}" || exit 1
|
||||||
if ! git clone "${repo}" "${MOONRAKER_OBICO_DIR}"; then
|
if ! git clone "${repo}" "${MOONRAKER_OBICO_DIR}"; then
|
||||||
print_error "Cloning Moonraker-obico from\n ${repo}\n failed!"
|
print_error "Cloning Obico from\n ${repo}\n failed!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -316,7 +314,7 @@ function moonraker_obico_install() {
|
|||||||
|
|
||||||
function remove_moonraker_obico_systemd() {
|
function remove_moonraker_obico_systemd() {
|
||||||
[[ -z $(moonraker_obico_systemd) ]] && return
|
[[ -z $(moonraker_obico_systemd) ]] && return
|
||||||
status_msg "Removing Moonraker-obico Systemd Services ..."
|
status_msg "Removing Obico Systemd Services ..."
|
||||||
|
|
||||||
for service in $(moonraker_obico_systemd | cut -d"/" -f5); do
|
for service in $(moonraker_obico_systemd | cut -d"/" -f5); do
|
||||||
status_msg "Removing ${service} ..."
|
status_msg "Removing ${service} ..."
|
||||||
@@ -329,7 +327,7 @@ function remove_moonraker_obico_systemd() {
|
|||||||
### reloading units
|
### reloading units
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
sudo systemctl reset-failed
|
sudo systemctl reset-failed
|
||||||
ok_msg "Moonraker-obico Services removed!"
|
ok_msg "Obico Services removed!"
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_moonraker_obico_logs() {
|
function remove_moonraker_obico_logs() {
|
||||||
@@ -361,7 +359,7 @@ function remove_legacy_moonraker_obico_logs() {
|
|||||||
function remove_moonraker_obico_dir() {
|
function remove_moonraker_obico_dir() {
|
||||||
[[ ! -d ${MOONRAKER_OBICO_DIR} ]] && return
|
[[ ! -d ${MOONRAKER_OBICO_DIR} ]] && return
|
||||||
|
|
||||||
status_msg "Removing Moonraker-obico directory ..."
|
status_msg "Removing Obico directory ..."
|
||||||
rm -rf "${MOONRAKER_OBICO_DIR}"
|
rm -rf "${MOONRAKER_OBICO_DIR}"
|
||||||
ok_msg "Directory removed!"
|
ok_msg "Directory removed!"
|
||||||
}
|
}
|
||||||
@@ -380,7 +378,7 @@ function remove_moonraker_obico() {
|
|||||||
remove_moonraker_obico_dir
|
remove_moonraker_obico_dir
|
||||||
remove_moonraker_obico_env
|
remove_moonraker_obico_env
|
||||||
|
|
||||||
print_confirm "Moonraker-obico was successfully removed!"
|
print_confirm "Obico was successfully removed!"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -394,7 +392,7 @@ function update_moonraker_obico() {
|
|||||||
if [[ ! -d ${MOONRAKER_OBICO_DIR} ]]; then
|
if [[ ! -d ${MOONRAKER_OBICO_DIR} ]]; then
|
||||||
clone_moonraker_obico "${MOONRAKER_OBICO_REPO}"
|
clone_moonraker_obico "${MOONRAKER_OBICO_REPO}"
|
||||||
else
|
else
|
||||||
status_msg "Updating Moonraker-obico ..."
|
status_msg "Updating Obico ..."
|
||||||
cd "${MOONRAKER_OBICO_DIR}" && git pull
|
cd "${MOONRAKER_OBICO_DIR}" && git pull
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -77,10 +77,12 @@ function change_klipper_repo_menu() {
|
|||||||
error_msg "Invalid command!";;
|
error_msg "Invalid command!";;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
break
|
||||||
else
|
else
|
||||||
status_msg "Set custom Klipper repository to:\n ● Repository: ${repos[${option}]}\n ● Branch: ${branches[${option}]}"
|
status_msg "Set custom Klipper repository to:\n ● Repository: ${repos[${option}]}\n ● Branch: ${branches[${option}]}"
|
||||||
set_custom_klipper_repo "${repos[${option}]}" "${branches[${option}]}"
|
set_custom_klipper_repo "${repos[${option}]}" "${branches[${option}]}"
|
||||||
ok_msg "This repo will now be used for new Klipper installations!\n"
|
ok_msg "This repo will now be used for new Klipper installations!\n"
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
elif [[ ${option} =~ ${back} ]]; then
|
elif [[ ${option} =~ ${back} ]]; then
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -25,7 +25,7 @@ function backup_ui() {
|
|||||||
echo -e "| | |"
|
echo -e "| | |"
|
||||||
echo -e "| Klipper Webinterface: | Other: |"
|
echo -e "| Klipper Webinterface: | Other: |"
|
||||||
echo -e "| 5) [Mainsail] | 9) [Telegram Bot] |"
|
echo -e "| 5) [Mainsail] | 9) [Telegram Bot] |"
|
||||||
echo -e "| 6) [Fluidd] | |"
|
echo -e "| 6) [Fluidd] | 10) [OctoEverywhere] |"
|
||||||
back_footer
|
back_footer
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,6 +54,8 @@ function backup_menu() {
|
|||||||
do_action "backup_octoprint" "backup_ui";;
|
do_action "backup_octoprint" "backup_ui";;
|
||||||
9)
|
9)
|
||||||
do_action "backup_telegram_bot" "backup_ui";;
|
do_action "backup_telegram_bot" "backup_ui";;
|
||||||
|
10)
|
||||||
|
do_action "backup_octoeverywhere" "backup_ui";;
|
||||||
B|b)
|
B|b)
|
||||||
clear; main_menu; break;;
|
clear; main_menu; break;;
|
||||||
*)
|
*)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -35,7 +35,7 @@ function install_ui() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function install_menu() {
|
function install_menu() {
|
||||||
clear -x && sudo -v && clear -x # (re)cache sudo credentials so password prompt doesn't bork ui
|
clear -x && sudo true && clear -x # (re)cache sudo credentials so password prompt doesn't bork ui
|
||||||
print_header
|
print_header
|
||||||
install_ui
|
install_ui
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -57,7 +57,7 @@ function print_status() {
|
|||||||
elif [[ ${status} == "Incomplete!" ]]; then
|
elif [[ ${status} == "Incomplete!" ]]; then
|
||||||
status="${yellow}${status}${white}"
|
status="${yellow}${status}${white}"
|
||||||
elif [[ ${status} == "Not linked!" ]]; then
|
elif [[ ${status} == "Not linked!" ]]; then
|
||||||
### "Not linked!" is only required for Moonraker-obico
|
### "Not linked!" is only required for Obico for Klipper
|
||||||
status="${yellow}${status}${white}"
|
status="${yellow}${status}${white}"
|
||||||
else
|
else
|
||||||
status="${green}${status}${white}"
|
status="${green}${status}${white}"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -41,7 +41,7 @@ function update_ui() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function update_menu() {
|
function update_menu() {
|
||||||
clear -x && sudo -v && clear -x # (re)cache sudo credentials so password prompt doesn't bork ui
|
clear -x && sudo true && clear -x # (re)cache sudo credentials so password prompt doesn't bork ui
|
||||||
do_action "" "update_ui"
|
do_action "" "update_ui"
|
||||||
|
|
||||||
local action
|
local action
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
Reference in New Issue
Block a user