Compare commits

..

565 Commits
v2.0.0 ... v3

Author SHA1 Message Date
th33xitus
4bf9e8f0a8 fix(moonraker.conf): typos in cors domains 2022-05-10 20:15:50 +02:00
th33xitus
dd58229fee fix: bug in remove_klipperscreen() 2022-03-06 11:56:31 +01:00
Alex Zellner
6c4635fa4e fix(gcode_shell_command): py3 virtual env compatibility (#175) 2022-02-26 19:28:06 +01:00
th33xitus
4517415e9d fix: CRLF to LF 2022-02-26 19:17:22 +01:00
th33xitus
5c45bc7617 readme: fix link to user profile 2022-02-26 17:46:47 +01:00
th33xitus
d8ce465126 readme: add shields to readme 2022-02-26 17:44:59 +01:00
th33xitus
2f8c95a8c7 readme: update readme 2022-02-26 17:24:02 +01:00
th33xitus
4c083ceade fix: broken set_klipper_cfg_path function (#163) 2022-02-26 16:51:43 +01:00
th33xitus
259a6919f0 fix: link for theme data csv 2022-02-10 09:14:44 +01:00
th33xitus
4f7a49d85a fix: bug not updating all when selecting to do so.
* also make the confirm message more verbose and make it clear that KIAUH won't update any held back packages or any dist upgrades.
2022-02-07 14:47:36 +01:00
th33xitus
005a5061a7 chore: apply changes made in mainsailOS 0.6.1 2022-02-03 16:57:55 +01:00
th33xitus
634d795557 fix: bug not successfully copying new upstreams.conf and common_vars.conf 2022-01-31 12:00:57 +01:00
th33xitus
a14e321df9 fix: apply required changes due to introduction of PolicyKit and PackageKit in Moonraker 2022-01-29 23:06:02 +01:00
th33xitus
1682642e47 fix: revert 7e9d18b
Due to some investigations made in #158, the default IPv6 configuration will be removed again
2022-01-11 08:51:32 +01:00
th33xitus
7e9d18b54c script: add webui ipv6 listen directive (fixes #158) 2022-01-08 22:16:38 +01:00
th33xitus
d049d4c770 script: remove unused functions 2022-01-08 21:48:38 +01:00
th33xitus
108cda3cd6 shellcheck: apply fixes for SC2086 2022-01-08 21:45:55 +01:00
th33xitus
d7de58f538 feat: check for apache2 and prompt for action 2022-01-08 20:57:47 +01:00
th33xitus
572afa0396 fix: typo in bug_report.yml 2021-12-30 19:52:22 +01:00
th33xitus
63a5e1e323 update bug_report.yml 2021-12-30 19:49:14 +01:00
th33xitus
8c68eaa995 doc: update changelog.md 2021-12-30 19:26:28 +01:00
th33xitus
e8c0b3cf39 fix: formatting / add INFO prefix 2021-12-26 12:18:45 +01:00
th33xitus
cfad7a1fb0 fix: add check for membership of group 'tty'
It's possible that being part of group 'tty' is also needed to be able to flash an MCU
2021-12-25 00:52:08 +01:00
th33xitus
4113732daa fix: check if group dialout exists
first check if group dialout exists on the system. then check if the current user is not part of it. only then ask for adding the user to that group
2021-12-24 23:33:05 +01:00
th33xitus
95808a0d5b shellcheck: apply several fixes
apply fix for SC2219, SC2086, SC2236
2021-12-24 23:02:38 +01:00
th33xitus
e551c02507 chore: remove unused code 2021-12-24 22:52:21 +01:00
th33xitus
1f40686ea1 fix: improve moonraker service detection (fixes #156) 2021-12-24 22:50:50 +01:00
th33xitus
9b3d96545b refactor: improve error message 2021-12-24 16:22:46 +01:00
th33xitus
a632fae8f6 fix: check if user is in group "dialout" before starting flash or build+flash routine 2021-12-24 16:17:07 +01:00
th33xitus
4e3a701db4 fix: warn_msg should be status_msg 2021-12-24 14:49:23 +01:00
th33xitus
0c760b5aa2 fix: check membership of "video" usergroup (should fix #135) 2021-12-24 14:36:30 +01:00
th33xitus
3bc2f3b498 doc: document passing parameters to gcode_shell_commands 2021-12-24 01:08:09 +01:00
th33xitus
b92cfc3984 fix: klipper_cfg_loc was an empty string
if the config location wasn't already set before installing mjpg-streamer, klipper_cfg_loc was empty, even after calling the check_klipper_cfg_path function beforehand

moonraker.conf: set refresh_interval to 24hrs
2021-12-24 00:22:15 +01:00
th33xitus
01790b5c11 moonraker.conf: pre-configure clients for pre-release updates
moonraker.conf: set refresh_interval to 24hrs
2021-12-23 17:17:48 +01:00
th33xitus
8c7891e360 fix: libjpeg dependencies for ubuntu
chore: several shellcheck fixes
2021-12-23 16:50:48 +01:00
th33xitus
852f7c056a fix: wrong logic in if condition 2021-12-23 16:45:06 +01:00
th33xitus
8cffd07aef fix: klipper service detection
refactor: move $INSTANCE_COUNT into setup function

refactor: creating $PKGLIST

script: add short description to the dialog for selecting the amount of klipper instances

chore: several shellcheck fixes
2021-12-23 15:03:52 +01:00
th33xitus
40745e90df refactor: move $INSTANCE_COUNT into setup function 2021-12-23 14:19:06 +01:00
th33xitus
a43645cca0 refactor: better klipper service detection 2021-12-23 10:35:18 +01:00
th33xitus
4d834db5df refactor: unlink moonraker install from klipper instances
chore: several shellcheck fixes
2021-12-23 10:35:09 +01:00
th33xitus
771191ab69 chore: update .gitignore 2021-12-22 22:39:17 +01:00
th33xitus
7afe943ecc shellcheck: apply fix for SC2086 2021-12-19 17:14:24 +01:00
th33xitus
b06c17c184 fix: confirm flash condition (fixes #155) 2021-12-19 17:05:41 +01:00
Pedro Lamas
3af46b45ee github: adds GitHub issue templates (#150)
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
2021-12-05 14:37:08 +01:00
th33xitus
b58e79634c fix: update URLs 2021-11-29 11:13:47 +01:00
Yoshito Komatsu
1ef9b0f58f fix: use [[:digit:]] instead of \d (#146) 2021-11-29 11:09:24 +01:00
th33xitus
8333ae1dc4 fix: also get pre-release versions
previous endpoint didn't allow kiauh to get pre-release versions of mainsail/fluidd
2021-11-20 15:17:21 +01:00
th33xitus
e0ae312a9e fix: missing declaration for OctoPrint backup (fixes #143) 2021-11-17 18:30:33 +01:00
th33xitus
4ce1ce72d3 chore: update moonraker.conf template 2021-11-14 11:29:14 +01:00
th33xitus
60842a330d chore: update webui links 2021-11-14 11:21:34 +01:00
th33xitus
05a59e9261 fix: correct ls command to find kiauh_macros.cfg 2021-11-11 14:15:00 +01:00
th33xitus
36a8757cfd chore: use ls to look for webcamd installation 2021-11-11 13:26:01 +01:00
th33xitus
fe4625d3e1 chore: refactor how moonraker is detected 2021-11-11 13:21:57 +01:00
th33xitus
19ddf3e023 fix: silence grep 2021-11-11 13:02:36 +01:00
th33xitus
ba888b1f97 chore: use ls within remove_nginx method 2021-11-11 12:51:09 +01:00
th33xitus
0284a36e7f chore: use ls to look for nginx installation 2021-11-11 12:43:13 +01:00
th33xitus
22f705e06c chore: manage moonraker service enable/start with do_action_service method 2021-11-11 12:28:20 +01:00
th33xitus
4c34245da0 chore: refactor how klipper services are count 2021-11-11 12:12:43 +01:00
th33xitus
f7cb3d6c97 script: refactor exit code evaluation in flash_mcu.sh 2021-10-31 13:53:22 +01:00
th33xitus
aaf4f7dd5c script: add logrotate rule for webcam service (#127) 2021-10-31 11:23:48 +01:00
Noah Pan
26bac791aa service: remove webcamd service restart interval. (#132) 2021-10-31 10:52:22 +01:00
th33xitus
aa4bdfc7b2 fix: invalid command bug in rollback UI (fixes #131) 2021-10-29 14:04:39 +02:00
th33xitus
311f3be864 fix: wrong check for moonraker multi-instance
The previous command also counted an available `moonraker-telegram-bot.service` and caused further issues with enabling the mainsail remoteMode accidentially.
2021-10-26 20:55:31 +02:00
th33xitus
511df1a889 fix: use correct themes.csv url 2021-10-25 22:22:32 +02:00
th33xitus
8d3ddc273a fix: allow non-single digit instance counts containing a 0 #129 2021-10-22 23:52:58 +02:00
th33xitus
f231fa9c69 gcode_shell_command: make RUN_SHELL_COMMAND accept optional parameters
Thanks @lixxbox for that code
2021-10-17 20:13:48 +02:00
th33xitus
9b6925e9c4 fix: add missing function call in install_webui 2021-10-02 11:26:43 +02:00
th33xitus
7f8ee7939c script: move nginx functions from install_moonraker.sh to install_klipper_webui.sh
nginx was removed as a dependency from moonraker. moonraker didn't make use of it, only mainsail/fluidd do. so moving all nginx related functions to  is reasonable
2021-10-01 23:58:03 +02:00
th33xitus
4d4c49d4c9 script: only display dialogs if files/service not found 2021-10-01 22:53:32 +02:00
th33xitus
7692227946 fix: function setup_moonraker_nginx_cfg 2021-10-01 21:51:33 +02:00
th33xitus
3da993a67c fix: breaking bug 2021-09-29 18:55:13 +02:00
th33xitus
6b74c59d15 script: add function to match nginx configurations
this should fix a common issue where mainsail/fluidd was installed with a more up2date nginx config which didn't match with a previously configured upstreams.conf.
this should also cover cases where the upstreams.conf is more up2date than the corresponding interface configs.
2021-09-29 14:44:01 +02:00
th33xitus
9cd27f7052 fix: backup nginx configs now works correctly 2021-09-28 18:22:50 +02:00
th33xitus
fc4fe130cd script: read webui ports from nginx config, write them to kiauh.ini 2021-09-28 18:22:50 +02:00
th33xitus
2a46b00cda Updating README.md / changelog.md 2021-09-28 17:25:40 +02:00
th33xitus
560186a40b chore: little UI tweaks, renaming "MTelegramBot" to "Telegram Bot" 2021-09-28 17:24:52 +02:00
th33xitus
75bca847f8 fix: remove telegram bot log also from ~/klipper_logs upon removal 2021-09-28 16:56:17 +02:00
Evgenii Shavrin
bb1f2eadca feat: add moonraker-telegram-bot by nlef (#117)
Adds installation and removing feature for https://github.com/nlef/moonraker-telegram-bot
2021-09-28 16:52:59 +02:00
Richard Mitchell
6d87716b1d gcode_shell_command: Fix issue with partial lines being repeated (#118)
Without clearing the partial line on a full line being sent the self.partial_output was repeated for every subsequent line.
2021-09-27 17:44:11 +02:00
th33xitus
1e8c379623 Create FUNDING.yml 2021-09-24 12:21:30 +02:00
th33xitus
6a8991d51e Update changelog.md 2021-09-24 12:19:41 +02:00
th33xitus
fb4367bb41 script: refactoring of the flash routine
script: uart devices can be detected/selected now

script: first implementation of a little help page
2021-09-24 11:59:50 +02:00
th33xitus
9463b719e4 script: update klipper github repository URL 2021-09-24 08:31:11 +02:00
th33xitus
65bf3d5251 fix: fix of previous commit and small refactor 2021-09-12 20:46:39 +02:00
AKA "Thom Wiley
68327262fc chore: change submenu "quit" to "back"
Changing the "Quit" option to "Back" as it is more intuitive, causes less confusion and is in fact the more fitting description of what is happening.
2021-09-12 20:41:27 +02:00
th33xitus
14ef39b87c fix: typo and missing function call for PrettyGCode 2021-08-25 10:14:05 +02:00
th33xitus
969d3b5dab script: add --allow-releaseinfo-change option to apt-get update 2021-08-25 10:05:31 +02:00
th33xitus
05842f8e1d feat: add PrettyGCode for Klipper 2021-08-10 12:25:05 +02:00
th33xitus
39219c105e script: add additional dependency check - should fix #97
Before starting the firmware building process, check for dependencies again.
2021-07-25 18:42:22 +02:00
th33xitus
7984c28fe5 script: add more default trusted_clients to moonraker.conf template
the previous method of adding the host network range was too unreliable in some cases and didn't cover some popular usecases
2021-07-11 19:13:37 +02:00
th33xitus
b44e855a98 script: simplify python dependency installation during klipper and moonraker update 2021-07-11 14:45:58 +02:00
th33xitus
52ab909ba5 script: update moonraker.conf, apply recent changes to the update manager section 2021-07-10 09:27:13 +02:00
th33xitus
4d7e10e5c3 script: update nginx configurations 2021-07-10 09:22:43 +02:00
th33xitus
d3726733e5 fix: small flash routine rework + user input validation 2021-07-04 20:09:25 +02:00
th33xitus
765f016ea2 fix: menu action for removing mainsail theme was missing 2021-07-01 21:38:14 +02:00
th33xitus
5deb987b8a script: patch log_path to moonraker.conf if missing 2021-06-29 22:58:21 +02:00
th33xitus
47d1321979 script: mainsail theme installer overhaul 2021-06-22 17:12:38 +02:00
th33xitus
b47a9cf7ed feat: add voron toolhead theme to mainsail theme installer 2021-06-22 12:07:27 +02:00
th33xitus
a9f23e9b23 script: remove else statement from do_action_service
Caused spamming of error messages when starting from a complete new Pi image.
2021-06-21 20:43:01 +02:00
th33xitus
814acbe92a script: add virtualenv to the moonraker dependency check #95 2021-06-21 08:44:37 +02:00
th33xitus
991dd79d01 script: add simple check for DietPi distro when creating the klipper dependency array 2021-06-18 18:28:27 +02:00
th33xitus
40875dfe49 script: simplify service action methods 2021-06-18 18:03:47 +02:00
th33xitus
806c6fd275 Update changelog.md 2021-06-15 17:36:08 +02:00
th33xitus
e9706b52d8 Update changelog.md 2021-06-15 17:22:39 +02:00
th33xitus
412e084d6d script: add short changelog url to kiauh update message 2021-06-15 16:40:10 +02:00
th33xitus
3ebee823ad script: remove KlipperScreen.log symlink dialog. 2021-06-15 16:12:58 +02:00
th33xitus
72312422e3 fix: performance improvement for loading the advanced menu ui 2021-06-15 15:56:13 +02:00
th33xitus
54089582e4 script: rewrite the auto mainsailOS/fluiddPi migration function
No auto update anymore when updating Klipper. The user now must start this function. It's available in the Advanced Menu.
2021-06-15 15:56:13 +02:00
th33xitus
9fd3f930df script: advanced_menu.sh, switch version becomes switch branch 2021-06-15 15:56:13 +02:00
th33xitus
98f0aa4b8f script: update log-upload function 2021-06-15 15:56:13 +02:00
th33xitus
19b37e4dc4 script: update klipper.service raw file link 2021-06-15 15:56:13 +02:00
th33xitus
d344b1c5f6 feat: auto mainsailOS / fluiddPi migration
script: make use of moonrakers new log_path configuration option

script: create webui nginx log symlinks upon installation/update
2021-06-15 15:56:13 +02:00
jordanruthe
f804fcb65d update: Fix detached head on KlipperScreen update (#93) 2021-06-13 17:39:12 +02:00
th33xitus
0edfc746d4 script: improve dependency checks on klipper/moonraker update 2021-06-08 17:55:40 +02:00
th33xitus
02ef0578e3 script: reading klipper/moonraker dependencies from their respective install scripts 2021-06-08 17:54:23 +02:00
th33xitus
5d11cd212a script: update install_moonraker.sh (#89) 2021-06-04 14:01:54 +02:00
cron410
bf33c77db7 script: install_klipper.sh prompt phrasing (#90) 2021-06-04 13:55:05 +02:00
th33xitus
0815d7778c feat: add cyberpunk theme to mainsail theme installer 2021-05-25 18:53:07 +02:00
th33xitus
9a3814f480 fix: typo in SYSTEMDDIR variable 2021-05-25 18:49:45 +02:00
th33xitus
a83585fb06 fix: improve pattern matching 2021-05-25 18:39:37 +02:00
th33xitus
dc27fe47e1 Merge branch 'b3tuning-install-mjpg-steamer-fix' 2021-05-25 12:16:27 +02:00
th33xitus
11b3d7a961 fix: replace config dir in webcamd file 2021-05-25 12:15:01 +02:00
th33xitus
9e0cdb0715 fix: remove webcamd file when removing mjpgstreamer 2021-05-25 12:13:36 +02:00
th33xitus
8abda56749 fix: typo in WEBCAM_TXT_SRC 2021-05-25 12:04:13 +02:00
James Hildebrand
cf20fc3c48 Issue 85 fix 2021-05-24 16:57:21 -07:00
th33xitus
6c8845d7b4 script: show found services in error message 2021-05-23 11:38:32 +02:00
th33xitus
fb0a30814d fix: validate user input for amount of Klipper instances to install 2021-05-23 10:44:51 +02:00
th33xitus
87f229c62d Update README.md 2021-05-23 10:08:16 +02:00
th33xitus
5b1da45688 fix: typo in dialog of get_mcu_id 2021-05-23 09:58:34 +02:00
th33xitus
545b978e80 update kiauh_macros.cfg
Update macros to reflect recent changes to Klipper

f10247a498
2021-05-21 08:55:11 +02:00
th33xitus
44f5609de6 script: remove deprecated moonraker.conf entries 2021-04-20 21:53:13 +02:00
th33xitus
f2a26d9b3d fix: false positive error message during klipper setup
add fix some status.sh functions too
2021-04-15 13:03:36 +02:00
Evgenii Shavrin
bb2cdab02b script: better moonraker service detection (#79)
More accurate service search
2021-04-13 12:21:16 +02:00
th33xitus
d6596d0a3d script: change kiauh update notification to a dialog 2021-04-08 18:07:30 +02:00
th33xitus
865fbc07dc script: updating webui nginx config and moonraker.conf template 2021-04-05 08:59:19 +02:00
th33xitus
40ba33eb19 fix: fix a bug that potentially caused writing a wrong config directory path to the moonraker.service file under special conditions 2021-04-03 19:29:59 +02:00
th33xitus
49b77162b0 fix: typo 2021-03-31 10:06:11 +02:00
th33xitus
adf087e3e5 script: activate [history] in moonraker.conf template 2021-03-31 09:16:31 +02:00
th33xitus
8220647564 script: rework mjpg-streamer service setup 2021-03-28 17:00:25 +02:00
th33xitus
57075ff525 script: rework klipper service setup 2021-03-28 16:45:16 +02:00
th33xitus
2f9de620bc script: rework moonraker service setup 2021-03-28 15:51:50 +02:00
th33xitus
d658c3a4cd fix: update nginx config 2021-03-28 15:46:48 +02:00
th33xitus
67f6a2c599 fix: broken update menu 2021-03-27 00:04:25 +01:00
th33xitus
f369c132d2 fix #74 - remove leftovers 2021-03-26 21:48:12 +01:00
th33xitus
cce6ac3c88 feat: add system upgrade 2021-03-26 18:36:05 +01:00
th33xitus
b9fe29068d script: apt-get update before apt-get install in dependency_check() 2021-03-25 21:40:16 +01:00
th33xitus
104089ea3d feat: add mjpg-streamer installer 2021-03-25 21:35:24 +01:00
th33xitus
48d97dab01 feat: backup moonraker database 2021-03-24 11:19:50 +01:00
th33xitus
e4a56564a1 fix: command for removing .octoprint dirs while uninstalling OctoPrint 2021-03-24 11:04:43 +01:00
th33xitus
6de8ce3278 script: add database_path to moonraker.conf template 2021-03-22 22:04:27 +01:00
th33xitus
b46457328f feat: followup to 7c7dd4e 2021-03-22 13:34:52 +01:00
th33xitus
7c7dd4ec3c feat: add mainsail theme installer 2021-03-22 10:55:24 +01:00
th33xitus
749293dde0 fix: visual bug 2021-03-17 16:13:53 +01:00
th33xitus
85f8ab4f24 fix: typo 2021-03-17 16:11:56 +01:00
th33xitus
e894496a6e script: add [history] to moonraker.conf template 2021-03-14 21:30:03 +01:00
th33xitus
19b220b772 fix: #71 2021-03-14 21:15:02 +01:00
th33xitus
a4eaa8952a script: remove unnecessary cors domains from moonraker.conf template 2021-03-12 11:20:38 +01:00
th33xitus
74a9bf783b script: deactivate moonrakers debug logging in moonraker.conf template 2021-03-11 22:08:05 +01:00
th33xitus
7597e999a1 fix: add 'octoprint_compat' entry to moonraker.conf template to enable slicer uploads 2021-03-05 09:12:00 +01:00
th33xitus
64d73ca86a refactor: determine installed services, combine single and multi remove into one step 2021-02-19 11:09:46 +01:00
th33xitus
d3283f7ab7 fix: try to fix a bug where the script errors out, telling that there is already a moonraker service installed but actually there isn't 2021-02-19 11:05:43 +01:00
th33xitus
cb443f6fee fix: rework remove processes 2021-02-17 20:50:36 +01:00
th33xitus
7162256e3f fix: remove klipperscreen log from tmp and user defined config folder 2021-02-17 20:31:26 +01:00
th33xitus
938b9d24f5 feature: add sdcard updates 2021-02-06 14:56:57 +01:00
th33xitus
38a3517c89 fix: autocommit.sh example uses .version files for getting mainsail and fluidd version 2021-02-06 12:16:04 +01:00
th33xitus
0b15cd0d9b fix: delete doubled status_msg in gcode_shell_command extension setup 2021-02-06 12:16:04 +01:00
th33xitus
9d7752a6c5 fix: typo in example pause macro 2021-02-04 19:36:57 +01:00
th33xitus
d1dff4d3b5 fix: logic error in build+flash function 2021-02-01 20:48:05 +01:00
th33xitus
49b7fe395b fix: detect an existing "legacy" klipper init.d installation 2021-01-31 18:34:05 +01:00
th33xitus
51469d8992 Update screenshot for KIAUH v3.0 2021-01-31 16:28:43 +01:00
th33xitus
16e6dde998 publish KIAUH v3.0 2021-01-31 16:20:52 +01:00
th33xitus
431f58af4b fix: code cleanup 2021-01-31 16:16:44 +01:00
th33xitus
c3af82745b Update docs 2021-01-31 16:09:00 +01:00
th33xitus
26eecbc94b fix: refactor main menu, add dwc and octoprint commands 2021-01-31 15:59:50 +01:00
th33xitus
fa8a9ff7ba fix: don't use systemctl commands anymore for reading the status if a service is installed and how much instances. instead only count the service files in /etc/systemd/system. this significantly improves performance of the script on low power hardware like a pi zero 2021-01-31 14:04:23 +01:00
th33xitus
dc08d8e7e3 fix: should fix #65 2021-01-31 13:32:16 +01:00
th33xitus
d0b895a469 fix.: make warning more clear 2021-01-30 20:42:32 +01:00
th33xitus
5aaebc2bec fix: add new cors domain to allow other ports than 80 only too. 2021-01-30 19:34:41 +01:00
th33xitus
538c179671 fix: visual bug in the webui installer 2021-01-30 19:33:38 +01:00
th33xitus
dc6fea8c3b fix: enable mainsail remoteMode if its already installed before moonraker 2021-01-30 18:19:49 +01:00
th33xitus
82227f8d0b fix: bug while creating the kiauh_macros.cfg 2021-01-30 16:13:20 +01:00
th33xitus
31c3f344e5 fix: add dialog: ask user to remove moonraker after klipper 2021-01-30 15:54:28 +01:00
th33xitus
a7b7b362f3 fix: typo in moonraker instance count status 2021-01-30 15:43:59 +01:00
th33xitus
5f142da1b6 fix: activate remoteMode for mainsail when moonraker multi-instances are found 2021-01-30 14:57:38 +01:00
th33xitus
99209f97de fix: refactor webui installer 2021-01-30 14:19:51 +01:00
th33xitus
8a64fe495e fix: add inactive klipperscreen entry to moonraker.conf 2021-01-30 12:52:58 +01:00
th33xitus
c3468c04e4 fix: bug when creating the local network ip range for moonraker.conf 2021-01-30 10:15:24 +01:00
th33xitus
2ef3273b74 fix: make remove function now also remove disabled octoprint services 2021-01-29 20:23:55 +01:00
th33xitus
47cf96ef74 fix: more verbose error message 2021-01-29 20:12:53 +01:00
th33xitus
17524bf49b fix: lock changing config folder function until klipper was installed through kiauh. 2021-01-29 20:10:04 +01:00
th33xitus
0d29bf9f31 fix: wording, description dialog 2021-01-29 18:00:47 +01:00
th33xitus
6105122467 fix: better explanation in the macro dialog 2021-01-29 17:13:19 +01:00
th33xitus
55dad5ffb6 fix: switch back to stephans repo, PR was merged. 2021-01-29 15:14:13 +01:00
th33xitus
53aa86d138 fix: missed updating a file name 2021-01-29 13:28:10 +01:00
th33xitus
a0e53655bd fix: bug with sourcing the kiauh.ini and improve config change function 2021-01-29 12:17:42 +01:00
th33xitus
69d134d9d1 fix: rework .octoprint folder remove function to be able to remove multiple instances 2021-01-28 23:42:38 +01:00
th33xitus
7224040f8a fix: check for multiple installed and enabled octoprint services 2021-01-28 23:41:54 +01:00
th33xitus
1570fd588e fix: display disabled octoprint services as installed, and show the number of instances 2021-01-28 23:40:37 +01:00
th33xitus
0eb2d066be fix: rework dwc and octoprint service handling 2021-01-28 23:39:42 +01:00
th33xitus
61d1c46694 fix: dependency check was missing for moonraker installation 2021-01-28 22:57:35 +01:00
Keith Sachs
18e85235c1 Update install_moonraker.sh (#64)
added libjpeg-dev and zlib1g-dev to moonraker dependencies, this makes kiauh work for armbian
2021-01-28 22:48:14 +01:00
th33xitus
04f204e4c7 fix: re-arrange mainsail and fluidd 2021-01-28 18:56:11 +01:00
th33xitus
f8aa88f480 fix: rework menus and UI 2021-01-28 18:54:02 +01:00
th33xitus
0c4f1a5378 fix: rework/refactor remove functions 2021-01-28 18:52:53 +01:00
th33xitus
4652e5c177 fix: added one more cors domain and changed ip-range for local network 2021-01-28 18:02:21 +01:00
th33xitus
a6156ebdf3 fix: make kiauh.ini a hidden file in users home folder 2021-01-28 17:56:23 +01:00
th33xitus
1c92987b42 fix: logic error 2021-01-28 17:50:35 +01:00
th33xitus
d01140638a fix: some typos when creating minimal cfg 2021-01-28 16:48:36 +01:00
th33xitus
254e1b8244 fix: create mainsail or fluidd nginx config from template 2021-01-28 16:45:12 +01:00
th33xitus
19aed15db0 fix: typos 2021-01-28 16:44:05 +01:00
th33xitus
b2b19f446b fix: use $klipper_cfg_loc in klipperscreen system check 2021-01-28 16:25:25 +01:00
th33xitus
8ad7f5d47c fix: remove update manager question. thanks to the recent changes to the update manager, mainsail and fluidd can be supported at the same time. 2021-01-28 16:21:24 +01:00
th33xitus
69eb96d006 fix: typo in moonraker backup function 2021-01-28 16:20:35 +01:00
th33xitus
e233d8435a fix: new date format, fix a typo, restructure backup.sh 2021-01-27 19:57:19 +01:00
th33xitus
fb52c7e4ab fix: relocate the kiauh.ini file to ~/.config to keep values even after reinstalling kiauh. 2021-01-27 18:51:48 +01:00
th33xitus
bc53de626f fix: version comparing and displaying issues 2021-01-27 18:13:21 +01:00
th33xitus
f10a604f97 fix: small clean-up 2021-01-25 19:09:30 +01:00
th33xitus
1527d7a25d Merge remote-tracking branch 'origin/master' into kiauh-rework 2021-01-25 19:01:55 +01:00
th33xitus
65062bdfda fix: update the macros used for pause, cancel resume by mainsail and fluidd to better ones 2021-01-25 18:51:31 +01:00
th33xitus
e3d242017d fix: update a comment in nginx configs 2021-01-25 18:50:49 +01:00
th33xitus
c14289a8a6 fix: add the new update manager entries to moonraker.conf 2021-01-25 18:50:25 +01:00
th33xitus
d12554d2b7 fix: apply a force reset --hard before updating KIAUH. Fix for #63 2021-01-23 22:52:41 +01:00
th33xitus
036fb08132 fix: remove upload limit of 200M in NGINX configs for mainsail and fluidd 2021-01-23 22:51:44 +01:00
th33xitus
d9e697216f fix: small dwc2 related fixes 2021-01-21 23:47:29 +01:00
th33xitus
d958c1ba2a fix: prepare for possible multi instance capabilities of dwc2-for-klipper-socket 2021-01-21 23:34:25 +01:00
th33xitus
fb1d3a8cd9 fix: dwc installer rework, only for single instance atm. multi instance tbd... 2021-01-21 17:38:21 +01:00
th33xitus
7eb0fe24f8 fix: some typos in moonraker installer 2021-01-21 17:35:21 +01:00
th33xitus
738269adae fix: make use of the delivered .version files to read mainsail and fluidd version 2021-01-21 11:28:31 +01:00
th33xitus
d098eef08e fix: rename files to their correct name 2021-01-21 10:28:04 +01:00
th33xitus
598c106c3a fix: correct mainsail url 2021-01-21 10:23:08 +01:00
th33xitus
8bf20aa059 Merge pull request #60 from jordanruthe/klipperscreen_fix
klipperscreen: update to fix an exit problem
2021-01-20 23:12:34 +01:00
Jordan Ruthe
748a700c36 klipperscreen: update to fix an exit problem 2021-01-20 17:07:30 -05:00
th33xitus
51207e2eb9 fix: remove file, config.yaml gets dynamically created now 2021-01-20 20:25:48 +01:00
th33xitus
ee252d185a fix: update octoprint installer for multi instances 2021-01-20 20:24:24 +01:00
th33xitus
cf1e37fb2a fix: rework octoprint remove function for removing multi instances 2021-01-20 20:23:55 +01:00
th33xitus
3d9722f877 fix: rename array 2021-01-20 20:19:53 +01:00
th33xitus
1ef67fa05c fix: insert blank lines in output 2021-01-20 15:16:41 +01:00
th33xitus
db856de8e5 fix: fix shell command installation 2021-01-20 15:16:22 +01:00
th33xitus
4748c15424 fix: update UI nginx configs 2021-01-20 15:00:12 +01:00
th33xitus
ab9d73b5b5 fix: minimal cfg 2021-01-20 14:55:20 +01:00
th33xitus
6c33282d43 fix: refactor main_menu 2021-01-17 14:50:55 +01:00
th33xitus
e71f1b9dfd fix: refactor install_menu 2021-01-17 14:44:10 +01:00
th33xitus
e24afa42ac fix: made log upload function multi instance capable 2021-01-17 14:29:36 +01:00
th33xitus
2fa975e3c2 fix: missed closing an if statement 2021-01-17 14:29:06 +01:00
th33xitus
feb912da8a fix: make adding the kiauh_macros optional 2021-01-17 12:58:25 +01:00
th33xitus
e5ce642018 fix: reorder the klippy_uds to the bottom 2021-01-17 12:44:42 +01:00
th33xitus
7a4ccfe4df fix: remove the functionality of patching an old/existing moonraker.conf only for making it compatible again. it will be way easier now to simply re-install moonraker and let those configs be created from scratch. 2021-01-17 11:50:20 +01:00
th33xitus
6b2175e439 fix: make klipperscreen installer use the klipper_cfg_loc variable for the printer config directory 2021-01-17 11:28:14 +01:00
th33xitus
dd2a26e2d0 del: remove now unused moonraker.conf template from resources 2021-01-17 11:23:26 +01:00
th33xitus
cd1489f0e5 fix: move the update manager function to the webinterface installations 2021-01-17 11:20:57 +01:00
th33xitus
d705a043c9 fix: add more trusted clients, cors domains, auto create a config folder if missing for whatever reason 2021-01-17 11:19:22 +01:00
th33xitus
c1a21c52b6 fix: create cfg directories if they are missing for whatever reason. 2021-01-17 11:18:09 +01:00
th33xitus
94762727ae fix: rename webui_macros.cfg to kiauh_macros.cfg 2021-01-17 11:17:37 +01:00
th33xitus
9cde005e08 fix: better default park position for printers with less than 230mm on x and y 2021-01-15 20:10:19 +01:00
th33xitus
86e7f37f7b fix: bigger refactoring of the klipper webui installer 2021-01-15 19:52:56 +01:00
th33xitus
4d2eb49e85 fix: big refactoring of the moonraker installer 2021-01-15 17:52:04 +01:00
th33xitus
715ab5f4e2 fix: display instance count in main menu status 2021-01-15 17:50:43 +01:00
th33xitus
146586f894 fix: correct mjpgstreamer port 2021-01-13 18:04:36 +01:00
th33xitus
bd78fa8ef7 add: quick and simple solution to start, stop, restart klipper/moonraker from within the main menu 2021-01-10 13:05:58 +01:00
th33xitus
b12d344b40 fix: update the config folder change function (its more like a "rename only" function now and should be plenty sufficient?) 2021-01-10 12:55:24 +01:00
th33xitus
9ea29bf995 fix: introduce new/better folder structure for multi instance setups 2021-01-09 23:17:45 +01:00
th33xitus
d066999d0b fix: little UI fixes 2021-01-09 18:02:59 +01:00
th33xitus
1ab681e71a fix: enable python3 check again, display moonraker IP at the end of the setup 2021-01-09 16:49:10 +01:00
th33xitus
f782a32e9c fix: bug in assigning correct port to instances 2021-01-09 16:08:29 +01:00
th33xitus
7dc1bc6cc8 fix: add full range of local network to auto-created moonraker.conf files 2021-01-08 20:02:58 +01:00
th33xitus
2a29716bb9 fix: make mcu ids verbose again for easier copy pasting into configs 2021-01-08 20:02:18 +01:00
th33xitus
33a9fef676 fix: check via md5sum of requirements text file if an update of the python env is necessary. if yes, do that update automatically. no user interaction anymore. 2021-01-08 14:57:51 +01:00
th33xitus
88afa55268 feat: support flashing of multiple connected mcus 2021-01-08 13:56:36 +01:00
th33xitus
65ec2e5e1a fix: bugs 2021-01-07 17:03:14 +01:00
th33xitus
08c1807cc7 fix: forgot to stop services first 2021-01-07 16:40:52 +01:00
th33xitus
218700b63d fix: add remove method for init.d moonraker service 2021-01-07 16:27:51 +01:00
th33xitus
bb1c5c4900 fix: add remove method for removing old init.d klipper service 2021-01-07 16:25:31 +01:00
th33xitus
43a724b80e fix: add disable command 2021-01-07 16:22:20 +01:00
th33xitus
08ae57d349 initial commit of a bigger kiauh rework to make multi instance installations possible 2021-01-07 15:26:19 +01:00
th33xitus
61dfab5683 feat: klipper config backup function 2021-01-07 15:24:25 +01:00
th33xitus
8ee277fe2c fix: set the correct port 8080 for mjpgstreamer 2021-01-03 16:18:37 +01:00
th33xitus
a44ae4c2b9 fix: followup to 240746e. kiauh now also tries to identify the branch from the commit SHA if the HEAD was detached at a single commit, if the other method does not give a usefull output. 2020-12-22 21:58:20 +01:00
th33xitus
240746e1b6 fix: a fix for the detached HEAD issue when updating klipper that was introduced in a past commit. the user now gets a warn message that he needs to force update klipper. behind the scenes he will be brought back onto the branch and head gets reattached. 2020-12-22 20:39:12 +01:00
th33xitus
1fd839bc7a fix: add "v" to versions, add kiauh version to bottom left corner in main menu 2020-12-21 21:00:27 +01:00
th33xitus
a6bfb30235 fix: add missing fluidd backup function 2020-12-21 19:08:26 +01:00
th33xitus
7854fe3d95 fix: fix #50 2020-12-20 19:25:13 +01:00
th33xitus
1eda775571 fix: previous klipper updates resulted in a detached head state. fixed update routine and other stuff relaying on the read_branch function/GET_BRANCH variable 2020-12-20 18:41:42 +01:00
th33xitus
06eb86efd7 fix: grep pattern changed to read fluidd version again 2020-12-20 16:23:03 +01:00
th33xitus
0339f3f4f5 fix: update script
there is a new way of grabbing the mainsail and fluidd version without reading them from a version file kiauh created in the past.
2020-12-04 19:38:40 +01:00
domi
3032356f89 fix: bug that caused the script to hang because the file that was searched for was not found 2020-12-04 16:43:51 +01:00
th33xitus
f1289504bf fix: few moonraker update changes
- change in the description
- option 1 only does a git pull again when rebuilding venv/deps is not necessary
2020-12-02 21:39:16 +01:00
th33xitus
d3b7c923bd fix: followup to 1b7b8a1 2020-12-01 18:53:30 +01:00
th33xitus
194b8a54cc Merge pull request #47 from th33xitus/rework-display-version
Rework how versions are displayed and fetched
2020-11-29 14:57:15 +01:00
domi
1b7b8a1cf9 fix: new way of getting mainsail and fluidd version 2020-11-29 14:57:24 +01:00
domi
e6dde2cf23 fix: different way of displaying versions 2020-11-28 23:15:29 +01:00
domi
94926d5985 Update README.md 2020-11-28 18:04:14 +01:00
domi
acf8a817d8 Update changelog.md 2020-11-28 17:46:37 +01:00
domi
10558103a5 fix: fix some UI stuff 2020-11-28 17:42:36 +01:00
th33xitus
c61e101627 fix: fix typo 2020-11-28 16:46:43 +01:00
th33xitus
ddcaee0838 Merge pull request #44 from jordanruthe/master
Add KlipperScreen to kiauh
2020-11-28 16:45:47 +01:00
Jordan Ruthe
622e8251a3 Fixing typos 2020-11-28 10:37:04 -05:00
Jordan
b2556641ac Fix symlinks 2020-11-27 13:50:19 +00:00
Jordan
93f8e5e265 Add KlipperScreen to kiauh 2020-11-27 13:44:06 +00:00
domi
dde5812c6b fix: add check for dbus dependency (fix #43) 2020-11-26 15:23:16 +01:00
domi
42a5a0b6d8 fix: fix typo, should fix #42 2020-11-26 11:00:05 +01:00
domi
d95b8ac763 fix: reset to default foreground color 2020-11-21 21:17:24 +01:00
domi
865177d0fd fix: highlight note in moonraker update menu 2020-11-21 16:45:00 +01:00
domi
8923620414 fix: issue with displaying longer version numbers 2020-11-21 16:39:19 +01:00
th33xitus
ecc349e550 Merge pull request #40 from th33xitus/work-moonraker
fix: rework moonraker update function
2020-11-20 14:06:02 +01:00
domi
bc35a82cc8 fix: rework moonraker update function 2020-11-20 13:14:01 +01:00
domi
4fe964e886 fix: a bit better python3 check for moonraker 2020-11-20 11:18:29 +01:00
th33xitus
8371a014a0 fix: restart nginx with systemctl 2020-11-19 13:47:26 +01:00
th33xitus
90af76402b fix: add messages to ongoing process 2020-11-19 13:43:33 +01:00
th33xitus
25b911e867 fix: followup to d3a12f7d 2020-11-19 12:40:47 +01:00
th33xitus
4e9776cac3 Merge pull request #38 from th33xitus/work-fluidd
Fix KIAUH for update to Fluidd
2020-11-18 18:05:01 +01:00
th33xitus
2e3975374a Update Docs 2020-11-18 18:03:41 +01:00
th33xitus
ed9b8d844b fix: must restart moonraker after changes to moonraker.conf 2020-11-18 17:48:19 +01:00
th33xitus
d3a12f7db7 fix: add a patch due to recent changes to fluidd 2020-11-18 17:37:54 +01:00
th33xitus
3b74bb0b77 fix: add python check to moonraker installer 2020-11-13 21:20:48 +01:00
th33xitus
4f7ac68af6 fix: better moonraker service status check 2020-11-13 21:17:17 +01:00
th33xitus
e22c6be490 fix: cleanup 2020-11-13 20:49:10 +01:00
th33xitus
3fd9f95da3 fix: littel rework for dwc2 installer etc. 2020-11-13 20:48:57 +01:00
th33xitus
065786fea7 fix: forgot to disable nginx test during fluidd install 2020-11-07 10:00:20 +01:00
th33xitus
e370c54739 fix: add dependency check into klipper & moonraker update function 2020-11-06 17:56:30 +01:00
th33xitus
88fd83638c fix: disable error-prone api checks 2020-11-06 17:53:39 +01:00
th33xitus
3d065c0f1b add: example script for autocommits 2020-10-30 16:49:27 +01:00
th33xitus
d98151cfef fix: little typo (but it breaks stuff) 2020-10-30 12:50:51 +01:00
th33xitus
41d2dd80a7 Merge pull request #34 from th33xitus/work-webui
Work webui
2020-10-30 00:13:26 +01:00
th33xitus
7ff1d972b4 Update README.md, changelog.md, features.md 2020-10-30 00:11:20 +01:00
th33xitus
efe482ea58 fix: upload new image 2020-10-30 00:10:40 +01:00
th33xitus
8ba6aee952 fix: add fluidd to ui message 2020-10-29 23:32:24 +01:00
th33xitus
9ecf7068f1 fix: rework of writing to configs 2020-10-29 22:28:24 +01:00
th33xitus
74a6b04762 Merge branch 'work-webui' of https://github.com/th33xitus/kiauh into work-webui 2020-10-29 18:32:01 +01:00
th33xitus
55382b1ecb fix: followup to 9fc7f41 2020-10-29 18:31:07 +01:00
th33xitus
b48319e24d fix: rework klipper webui installers 2020-10-29 18:31:07 +01:00
th33xitus
8b03b27902 Merge remote-tracking branch 'origin/master' into work-webui 2020-10-29 18:30:14 +01:00
th33xitus
be2734e640 fix: little rework and fixes of shell command extension installation 2020-10-29 18:27:22 +01:00
th33xitus
7431124d87 fix: formatting 2020-10-29 17:32:48 +01:00
th33xitus
4ae696857f fix: followup to 9fc7f41 2020-10-28 23:16:24 +01:00
th33xitus
9fc7f4120a Merge branch 'moonraker-rework' into work-webui 2020-10-28 21:29:53 +01:00
th33xitus
dc32470a7c Merge pull request #33 from th33xitus/klipper-systemd
Support installation for klipper as systemd service
2020-10-28 21:24:22 +01:00
th33xitus
d91d01ae2c fix: rework klipper webui installers 2020-10-28 20:39:34 +01:00
th33xitus
62b0f2afd6 fix: convert test echo into status_msg 2020-10-28 13:03:21 +01:00
th33xitus
6ce475e27a fix: revert default selection for log creation question 2020-10-28 12:10:38 +01:00
th33xitus
e6d5a73a79 fix: followup to 5fd19ae to support klipper systemd service 2020-10-28 12:09:15 +01:00
th33xitus
5fd19aef0b add: support to install klipper as systemd service 2020-10-28 12:08:02 +01:00
th33xitus
911d0d37e5 fix: invert default selections during klipper install 2020-10-26 17:59:52 +01:00
th33xitus
cbffa1b31a fix: formatting 2020-10-21 21:40:21 +02:00
th33xitus
32c176bf2f fix: add missing function call and simplify function to set hostname 2020-10-21 21:15:30 +02:00
th33xitus
b4fc691da1 fix: possible fix for #24 2020-10-20 10:32:55 +02:00
th33xitus
6129f15386 Merge pull request #28 from th33xitus/work-ini
fix: #24 - .gitignore for kiauh.ini
2020-10-13 11:59:35 +02:00
th33xitus
759cc8e196 fix: whitespaces 2020-10-13 11:58:05 +02:00
th33xitus
dec1c0e83c fix: addition to b20cda1 2020-10-13 11:55:01 +02:00
th33xitus
b20cda1d15 fix: new function to fix #26 2020-10-13 11:41:57 +02:00
th33xitus
2c522e717f add: .gitignore for kiauh.ini 2020-10-13 11:02:42 +02:00
th33xitus
c06aa0457f bugfix: fix typo 2020-10-10 16:55:47 +02:00
th33xitus
253f4e1bf9 Merge pull request #25 from th33xitus/work-logupload
Add: log upload function
2020-10-10 16:42:19 +02:00
th33xitus
29e3d8b3d2 add: log update function 2020-10-10 16:41:00 +02:00
th33xitus
e0b7a75116 fix: update_all ui 2020-10-10 09:46:45 +02:00
th33xitus
083ca8b7fd fix: fetching correct download url + more status messages 2020-10-10 09:37:06 +02:00
th33xitus
4e2c6aa2cc fix: fluidd update function not existing 2020-10-10 09:35:40 +02:00
th33xitus
a4a85b1045 func: drop support for switching to moonraker klipper branch (it's obsolete) 2020-10-10 01:22:08 +02:00
th33xitus
ccf5b003fe fix: more verbose ok_msg 2020-10-09 19:00:59 +02:00
th33xitus
0027886f4f Update changelog.md 2020-10-06 22:48:07 +02:00
th33xitus
26599d734d Update README.md 2020-10-06 22:37:08 +02:00
th33xitus
d58841a269 Merge pull request #22 from th33xitus/work-fluidd
Installer for Fluidd and several other fixes
2020-10-06 22:31:41 +02:00
th33xitus
ab6fa29bd2 Update README.md 2020-10-06 22:29:03 +02:00
th33xitus
6142c0c18f bugfix: typos 2020-10-06 21:58:25 +02:00
th33xitus
fb14d9c717 bugfix: fix typos 2020-10-06 21:14:56 +02:00
th33xitus
bc658f38bc fix: UI 2020-10-06 21:04:35 +02:00
th33xitus
976d9cb5a9 fix: add gzip to fluidd nginx config 2020-10-06 20:34:45 +02:00
th33xitus
029127bf00 fix: nginx port stuff on all interface installers 2020-10-06 20:19:37 +02:00
th33xitus
9b424c8343 bugfix: add missing removal actions 2020-10-06 18:33:02 +02:00
th33xitus
3658137a1c bugfix: fix introduced bug in fe941f4 2020-10-06 18:18:40 +02:00
th33xitus
4e38e85962 bugfix: add greater delay to test_api to let cpu usage settle on slower devices 2020-10-06 17:55:24 +02:00
th33xitus
fe941f4227 feature: initial commit to add installer for Fluidd + rewrite nginx related stuff 2020-10-06 15:03:54 +02:00
th33xitus
9a4ca4114c fix: more verbose kiauh update message 2020-10-05 14:30:52 +02:00
th33xitus
1c41abe40f bugfix: fix the wrong displaying of color codes in windows-consoles 2020-10-05 14:14:26 +02:00
th33xitus
3257c845ee remove branding removal function for mainsail 2020-09-21 23:48:25 +02:00
th33xitus
3d6b4bec95 Update mainsail_macros.cfg
Bring mainsail_macros.cfg in line with the macro examples from the mainsail instructions: https://github.com/meteyou/mainsail/blob/master/docs/macros.md
2020-09-20 11:02:11 +02:00
th33xitus
c55a010bcd Update README.md 2020-09-18 09:00:32 +02:00
th33xitus
78dcc0a1ad fix: concatenate with && again 2020-09-18 08:58:46 +02:00
th33xitus
2a2bc6b377 Update README.md 2020-09-17 23:29:06 +02:00
th33xitus
1159d74748 Update README.md
update image url
2020-09-17 21:37:03 +02:00
th33xitus
40f34f26ea Merge pull request #18 from th33xitus/work17092020
add: update all function
2020-09-17 21:36:00 +02:00
th33xitus
668331e7ea add: update all function 2020-09-17 21:23:26 +02:00
th33xitus
d2bdf6b089 start/restart/stop services with systemctl 2020-09-17 19:31:33 +02:00
th33xitus
10f75268ab Update README.md 2020-09-17 19:05:04 +02:00
th33xitus
46e6b7d40a Update changelog.md 2020-09-17 19:02:43 +02:00
th33xitus
bd876c744d remove: update check for branch dev-2.0
abandon the dev-2.0 branch
2020-09-17 18:49:58 +02:00
th33xitus
db0a4b4e03 fix: adresses #17 2020-09-16 22:19:14 +02:00
th33xitus
efa67b5843 Update README.md
add link to a gitbook with more detailed instructions for installing klipper and mainsail
2020-09-16 10:16:35 +02:00
th33xitus
d393b0a9e9 Merge pull request #16 from tumbleweedlabs/master, fixes #15
Update mainsail_macros.cfg, fixes #15
2020-09-16 09:52:21 +02:00
tumbleweedlabs
85f0c26215 Update mainsail_macros.cfg
Per meteyou, the last G91 in the resume macro is erroneous and can be eliminated.

https://discordapp.com/channels/431557959978450984/704747457795588100/755540226843345038
2020-09-15 20:39:13 -07:00
tumbleweedlabs
35dcf10c9a Update mainsail_macros.cfg
Pull request to fix issue 15: https://github.com/th33xitus/kiauh/issues/15
2020-09-15 17:30:25 -07:00
th33xitus
64b6d6b26a fix: stop/start dwc service when updating 2020-09-14 22:54:01 +02:00
th33xitus
a2201ab3f7 Merge pull request #13 from th33xitus/work-13092020
Work 13092020
2020-09-13 12:25:14 +02:00
th33xitus
63a2f95cc0 Update README.md 2020-09-13 12:24:02 +02:00
th33xitus
043f09aeeb Delete core_functions.md 2020-09-13 12:23:04 +02:00
th33xitus
1fa1636f75 Update features.md 2020-09-13 12:21:54 +02:00
th33xitus
3770f0fd7a Update README.md 2020-09-13 12:12:33 +02:00
th33xitus
ecd9e7f489 Update README.md 2020-09-13 12:11:52 +02:00
th33xitus
125eea921f add: some docs 2020-09-13 11:57:03 +02:00
th33xitus
2e9be1adc5 fix: typos 2020-09-13 11:47:01 +02:00
th33xitus
3e35be5681 add: user choice for dwc service (init.d or systemd) 2020-09-13 11:25:46 +02:00
th33xitus
d9d3006be4 fix: correct ExecStart parameter 2020-09-13 11:25:13 +02:00
th33xitus
6abab9fb06 fix: remove a sudo command from removal process 2020-09-12 12:31:14 +02:00
th33xitus
ef4b6b092f Update README.md 2020-09-12 09:45:22 +02:00
th33xitus
b2a8c52995 Merge branch 'dev-2.0' 2020-09-12 09:32:24 +02:00
th33xitus
9bfce238d7 add: support for new dwc-for-klipper-socket by @Stephan3
This will replace the previous installer for dwc2-for-klipper without substitution. dwc2-for-klipper won't be maintained anymore.
2020-09-12 09:31:40 +02:00
th33xitus
d0ac497a60 add: dwc2-for-klipper-socket installer scripts 2020-09-12 08:48:33 +02:00
th33xitus
4c44b8714a Update moonraker.conf
Update the default moonraker.conf to be mostly in sync with https://github.com/Arksine/moonraker/blob/master/docs/installation.md#moonraker-configuration-moonrakerconf
2020-09-11 16:17:03 +02:00
th33xitus
da1820a7da Merge branch 'dev-2.0' 2020-09-11 14:34:28 +02:00
th33xitus
b576491320 fix: rework dialogues to display invalid input 2020-09-11 14:12:49 +02:00
th33xitus
0c9e967ebe fix: invert default selection
invert the pre-selected option from yes to no.
2020-09-11 12:55:34 +02:00
th33xitus
4d53a92c83 Merge branch 'master' into dev-2.0 2020-09-11 12:35:42 +02:00
th33xitus
0b474514b1 fix: bug introduced with c98584d 2020-09-11 12:34:47 +02:00
th33xitus
9b7bde7da0 fix: bug introduced in previous commit 2020-09-11 12:20:31 +02:00
th33xitus
fc61f17297 Merge branch 'dev-2.0' of https://github.com/th33xitus/kiauh into dev-2.0 2020-09-11 12:04:41 +02:00
th33xitus
3a4fbdbd61 fix: tweak moonraker/mainsail install process 2020-09-11 12:04:35 +02:00
th33xitus
1ec269969b fix: tweak moonraker/mainsail install process 2020-09-11 11:31:53 +02:00
th33xitus
fa669a8690 fix: do not automatically remove moonraker.conf 2020-09-11 11:31:04 +02:00
th33xitus
599b85c47d fix: issue #12 2020-09-11 10:26:15 +02:00
th33xitus
83e9618a75 fix: cleaner nginx removal process 2020-09-11 10:25:38 +02:00
th33xitus
c98584dde8 bugfix: kiauh status check prevents kiauh from starting if no kiauh .git directory present 2020-09-06 11:16:34 +02:00
th33xitus
53f4b9a9f5 Merge pull request #11 from leifbladt/patch-1
Simplify installation instructions
2020-09-04 11:31:15 +02:00
Leif Bladt
a23fb6b79e Simplify installation instructions
As you're already in the kiauh directory, the `chmod` command can be simplified.
2020-09-04 09:26:29 +02:00
th33xitus
262e489d1a fix: moonraker update function - check for patched klipper sysfile 2020-09-03 09:55:37 +02:00
th33xitus
9e13c2d0ea fix: wrong include path in default mainsail printer.cfg 2020-09-02 23:20:25 +02:00
th33xitus
34162c4b65 fix: bug in moonraker system check for printer.cfg 2020-09-02 23:18:47 +02:00
th33xitus
7384ed8a0e fix: tweak mainsail setup 2020-09-02 23:16:01 +02:00
th33xitus
8899275022 function: re-enable the branding removal function 2020-09-02 22:22:10 +02:00
th33xitus
03c3c3d50f fix: Mainsail update function not working 2020-09-01 18:01:08 +02:00
th33xitus
45c8b5a33f Merge branch 'dev-2.0' 2020-09-01 14:28:40 +02:00
th33xitus
4a60b9c8ec remove: function to remove voron brandings from mainsail, mainsail has its own logo now (thx @lixxbox). function therefore obsolete 2020-09-01 14:27:53 +02:00
th33xitus
d964523558 fix: make some output silent 2020-09-01 14:22:28 +02:00
th33xitus
49a28cff22 fix: better suited status message 2020-09-01 14:19:36 +02:00
th33xitus
8a5e358a73 fix: remove use of symlinks, also update for mainsail v0.2.0 2020-09-01 13:52:36 +02:00
th33xitus
9ec63be673 fix: rework locate_printer_cfg function 2020-09-01 13:51:51 +02:00
th33xitus
bae0c1f0fd fix: typo and bug, also bring code in place for later moonraker version 2020-08-30 13:59:19 +02:00
th33xitus
fc777ccb96 fix: remove two menu entries 2020-08-30 13:37:49 +02:00
th33xitus
96be30343d fix: rework klipper installation routine 2020-08-30 13:35:14 +02:00
th33xitus
24a59cffb7 Merge branch 'dev-2.0' 2020-08-26 10:47:43 +02:00
th33xitus
dba14aadb6 new function: install shell command extension by Arksine 2020-08-26 08:18:59 +02:00
th33xitus
d51062c5ae fix: use new method to locate printer.cfg, rework depending functions 2020-08-26 08:18:18 +02:00
th33xitus
1b4baad654 fix: status message 2020-08-24 11:48:57 +02:00
th33xitus
5a25bd3686 fix: remove old read branch function 2020-08-23 21:52:18 +02:00
th33xitus
f08d6ecdc2 fix: clean up and restructure menus and ui 2020-08-23 20:48:07 +02:00
th33xitus
be56439587 fix: typo in mainsail installer 2020-08-23 16:31:55 +02:00
th33xitus
dd16a2503b fix: extend description 2020-08-22 23:32:35 +02:00
th33xitus
613e0d779f fix: rollback function 2020-08-22 23:21:26 +02:00
th33xitus
612a4225be fix: recreate deleted variable 2020-08-22 22:20:13 +02:00
th33xitus
35ecf3ae65 fix: kiauh update function (finally?) 2020-08-22 21:58:55 +02:00
th33xitus
e32cc9d3cb fix: remove deprecated main menu entry 2020-08-22 20:29:22 +02:00
th33xitus
9a3e41716e fix: delete a debug msg 2020-08-22 20:05:56 +02:00
th33xitus
09e4c7bea5 fix: bring octoprint installation routine into line with dwc2 and mainsail/moonraker routines 2020-08-22 19:30:35 +02:00
th33xitus
5392e2a9ab add: status message for starting installation 2020-08-22 19:18:27 +02:00
th33xitus
41789fd158 fix: restructuring reverse proxy and hostname functions 2020-08-22 19:18:08 +02:00
th33xitus
2532fc7e4c fix: restructure functions.sh 2020-08-22 19:14:11 +02:00
th33xitus
63f65a02b4 fix: a more verbose dependency check message 2020-08-22 18:23:41 +02:00
th33xitus
f3a139f317 fix: remove_ui 2020-08-22 18:19:33 +02:00
th33xitus
68cb5427b6 fix: rewrite dwc2 installation 2020-08-22 17:49:35 +02:00
th33xitus
2be2ce12c6 add: variable triggered function to disable octoprint service 2020-08-22 17:48:52 +02:00
th33xitus
eb6b2465c7 fix: mainsail/moonraker related 2020-08-22 17:47:47 +02:00
th33xitus
cc1c804730 fix: klipper update function 2020-08-22 09:10:09 +02:00
th33xitus
7dda59649b fix: ui not printing branch 2020-08-22 09:09:28 +02:00
th33xitus
60dc9d623e fix: rollback function 2020-08-22 09:09:00 +02:00
th33xitus
92b4bc41ac fix: move test_api to moonraker install routine 2020-08-20 18:58:57 +02:00
th33xitus
db5b906e5b add: separate install/remove function for mainsail and moonraker 2020-08-20 18:30:56 +02:00
th33xitus
d78670e0ab fix: formatting 2020-08-20 17:38:24 +02:00
th33xitus
716b21a629 feature: new experimental moonraker/mainsail install routine 2020-08-20 16:32:01 +02:00
th33xitus
1a037c687b add: new log location to mainsail remove data_arr 2020-08-20 16:31:28 +02:00
th33xitus
0dc5edfd7b add: mainsail_macros.cfg 2020-08-20 16:30:40 +02:00
th33xitus
c82e21419c fix: change color variables 2020-08-20 16:29:15 +02:00
th33xitus
7b220c6546 fix: wrong path for include config 2020-08-16 12:57:53 +02:00
th33xitus
15c6296e2c fix: all scripts chmod +x 2020-08-16 10:49:53 +02:00
th33xitus
e00d2951a9 fix: bug in klipper version check 2020-08-16 10:19:58 +02:00
th33xitus
68f7c98985 Merge pull request #9 from th33xitus/master
fix: kiauh update function
2020-08-15 20:13:25 +02:00
th33xitus
82408fee2e fix: kiauh update function 2020-08-15 19:27:29 +02:00
th33xitus
3076d400a0 fix: kiauh update check 2020-08-15 19:03:44 +02:00
th33xitus
c91718cfc3 update: mainsail installation routine 2020-08-15 17:11:11 +02:00
th33xitus
9c20ad7d99 fix: read branch error 2020-08-15 17:08:55 +02:00
th33xitus
7614d596ab fix: kiauh update function 2020-08-15 10:01:32 +02:00
th33xitus
5bcd9a73b5 fix: missing quotes in remove_brandings 2020-08-12 19:46:54 +02:00
th33xitus
a06b06eb46 show error message if warning is ignored or no printer connection was found. extend the function to search by path as well if search by id is not successfull 2020-08-12 18:02:31 +02:00
th33xitus
66e9069687 feature: remove voron branding from mainsail ui 2020-08-12 17:34:53 +02:00
th33xitus
a782fecd25 fix missing entry in mainsail nginx cfg 2020-08-12 16:23:26 +02:00
th33xitus
5dda935f58 Merge branch 'master' into dev-2.0 2020-08-09 10:20:21 +02:00
th33xitus
8cfe4a81ef Update README.md 2020-08-09 09:47:07 +02:00
th33xitus
2e4da7f220 fix read branch error 2020-08-05 00:09:18 +02:00
th33xitus
be6a63f95b new kiauh update check 2020-08-05 00:03:54 +02:00
th33xitus
9fcbcfcba8 new way of reading current active klipper branch 2020-08-04 23:27:51 +02:00
th33xitus
3ec26ba319 update mainsail config 2020-08-03 09:40:54 +02:00
th33xitus
188239d7ea fix kiauh update check 2020-07-31 17:05:11 +02:00
th33xitus
b850aa4d96 Fix Bug 2020-07-31 10:30:14 +02:00
th33xitus
2e5e06c1ff remove tornado with DWC2 2020-07-31 10:18:03 +02:00
th33xitus
96c094d36b UI Fix 2020-07-31 10:17:53 +02:00
th33xitus
3be01528d9 Merge branch 'master' of https://github.com/th33xitus/kiauh 2020-07-29 21:29:56 +02:00
th33xitus
6b77070baa one screenshot only 2020-07-29 21:27:12 +02:00
th33xitus
4e2743d587 make backup function usable 2020-07-29 21:25:31 +02:00
th33xitus
1d9cbecbb5 add moonraker update function + ui stuff
add moonraker update function + ui stuff
2020-07-29 21:13:51 +02:00
th33xitus
bd90677cfa add moonraker update function + ui stuff 2020-07-29 21:12:07 +02:00
th33xitus
e75df6d46c kiauh status now checks master branch 2020-07-29 15:58:27 +02:00
th33xitus
b6c07fc357 Merge branch 'dev-2.0' 2020-07-29 15:48:47 +02:00
th33xitus
fce1eb5a8c update script to use mainsail beta - dropping mainsail alpha 2020-07-27 11:26:22 +02:00
th33xitus
82d76b18f0 new rollback feature 2020-07-27 10:29:28 +02:00
th33xitus
dc4cc59038 before updating, save the current klipper commit state in ini 2020-07-26 18:15:36 +02:00
th33xitus
6f30208863 rename INI_DIR to INI_FILE 2020-07-26 18:11:22 +02:00
th33xitus
303c96cbb1 remove hint msg -> useless 2020-07-26 18:10:45 +02:00
th33xitus
da57fe7ccc fix bug 2020-07-26 15:16:29 +02:00
th33xitus
e5e135c68b add confirmation messages 2020-07-26 12:36:05 +02:00
th33xitus
22888f5756 simple startup update check for KIAUH 2020-07-25 20:57:32 +02:00
th33xitus
d84a740f0d Merge branch 'dev-2.0' of https://github.com/th33xitus/kiauh into dev-2.0 2020-07-25 13:16:41 +02:00
th33xitus
64a7dec09d Fix UI stuff 2020-07-25 13:16:37 +02:00
th33xitus
a76cab0fe6 restructure install/update for dwc2 2020-07-25 13:16:04 +02:00
th33xitus
e0b9a1ef3b Update README.md 2020-07-24 23:09:06 +02:00
th33xitus
6c4e6b057e Update README.md 2020-07-24 23:08:12 +02:00
th33xitus
37b23129c0 Update README.md 2020-07-24 23:05:24 +02:00
th33xitus
5651ce2d63 add screenshots 2020-07-24 22:07:52 +02:00
th33xitus
0a0a9f2f93 preconfigure octoprint for use with klipper 2020-07-24 21:44:58 +02:00
th33xitus
876b316af4 change nginx configs listen to ipv4 only 2020-07-24 21:44:30 +02:00
th33xitus
f51ba88f64 advanced menu: change hostname function 2020-07-24 18:00:57 +02:00
th33xitus
02c6a46a78 Fix bugs 2020-07-24 13:21:34 +02:00
th33xitus
84fc849caf UI stuff 2020-07-24 13:12:04 +02:00
th33xitus
87ed15a117 Finish backup functions 2020-07-24 13:11:53 +02:00
th33xitus
2bbf006475 some reverse proxy tweaks 2020-07-23 19:39:12 +02:00
th33xitus
2596e8d08a Fixes 2020-07-23 16:13:33 +02:00
th33xitus
80344ec41c Fixes 2020-07-23 11:04:23 +02:00
th33xitus
a2042ec378 Better tornado install check 2020-07-23 10:50:10 +02:00
th33xitus
734aed1f7b Better dependency check 2020-07-23 10:20:14 +02:00
th33xitus
108b5c7b0c Fixes 2020-07-22 17:50:46 +02:00
th33xitus
3091ce55ad Fix bug 2020-07-22 13:27:41 +02:00
th33xitus
e6b6dbfa74 Merge branch 'dev-2.0' of https://github.com/th33xitus/kiauh into dev-2.0 2020-07-22 10:16:57 +02:00
th33xitus
e22105a728 add dwc2 reverse proxy option 2020-07-22 10:16:52 +02:00
th33xitus
092f2793b3 Update README.md 2020-07-20 11:59:02 +02:00
th33xitus
3ab4244709 Update README.md 2020-07-20 11:50:24 +02:00
th33xitus
7b48061281 Update README.md 2020-07-20 11:02:11 +02:00
th33xitus
2b6dbaab76 remove webcam stuff: i can't test it sufficient enough, users need to install it manually for now 2020-07-20 10:45:04 +02:00
th33xitus
4cb2ba51bd fix remote version checks 2020-07-20 10:09:42 +02:00
th33xitus
8ffdf12a4a add octoprint reverse proxy 2020-07-19 22:38:21 +02:00
th33xitus
28d7a4aeda feature: remove option for tornado and nginx 2020-07-18 20:30:49 +02:00
th33xitus
fed882298e do not remove tornado when removing dwc2fk, will get seperate function 2020-07-18 18:49:55 +02:00
th33xitus
e4cfad4162 new function: allow hostname to be set 2020-07-18 18:33:55 +02:00
th33xitus
b4496603ed Update README.md 2020-07-18 15:17:50 +02:00
th33xitus
1cc94d4874 Fix bugs 2020-07-16 17:01:57 +02:00
th33xitus
d19c4d33cb Fix OctoPrint toggle function 2020-07-16 16:33:44 +02:00
th33xitus
fd71b0ee62 Fixes/Tweaks 2020-07-16 15:54:57 +02:00
th33xitus
49d0a65bcd Merge branch 'dev-2.0' of https://github.com/th33xitus/kiauh into dev-2.0 2020-07-16 15:14:27 +02:00
th33xitus
ba53517f09 fix breaking stuff 2020-07-16 15:14:23 +02:00
th33xitus
1be6cd0a3d remove nginx-purge option 2020-07-16 15:09:28 +02:00
th33xitus
8c0e231ade some "debloating" 2020-07-16 15:07:00 +02:00
th33xitus
1551920fe3 Update README.md 2020-07-15 23:33:20 +02:00
th33xitus
a5155c50cc Fixes/Tweaks 2020-07-15 22:52:23 +02:00
th33xitus
57d86b9ef4 Add checks for octoprint service when installing DWC2/Mainsail 2020-07-15 22:02:42 +02:00
th33xitus
182164af9c Small fixes/tweaks 2020-07-15 21:50:40 +02:00
th33xitus
45fe688f87 Add Octoprint Service toggle function and a new confirm message 2020-07-15 21:41:20 +02:00
th33xitus
fe27d054f8 Add Octoprint installer/remover 2020-07-15 18:57:46 +02:00
th33xitus
21aa2f45e5 Rename mainsail service to moonraker service 2020-07-15 11:50:57 +02:00
th33xitus
eea1f5540e Better error message 2020-07-15 11:25:16 +02:00
th33xitus
2771184e48 Add abort method if not on moonraker fork 2020-07-15 11:17:36 +02:00
th33xitus
2b6abac0c9 Fix missing function call
Fixed a missing function call for creating config entries.
Installing mainsail should work now pretty straight forward.
2020-07-13 21:09:40 +02:00
th33xitus
85a9186c78 Add restart functions 2020-07-13 21:08:31 +02:00
th33xitus
7106994bf6 Deactivate backup menu
Still WIP, has no function at all at them moment.
2020-07-13 18:14:10 +02:00
th33xitus
c57acefc16 Delete status.sh
derp...
2020-07-13 18:10:10 +02:00
th33xitus
e2bb6cd849 Fix visual issue
Fix an UI issue when DWC2 or Mainsail are not installed
2020-07-13 18:09:30 +02:00
th33xitus
f1d9b9c21b Fix visual issue
Fix an UI issue when DWC2 or Mainsail are not installed
2020-07-13 18:07:43 +02:00
th33xitus
6cf253eb8c Fix typo 2020-07-13 17:53:08 +02:00
th33xitus
3f7b454710 Update README.md
add screenshot
2020-07-13 17:42:38 +02:00
th33xitus
50eb2621d7 Update README.md
Update instructions for switching to the dev-2.0 branch.
2020-07-13 17:21:10 +02:00
th33xitus
bf70157a64 Update README.md 2020-07-13 17:15:09 +02:00
61 changed files with 6718 additions and 1546 deletions

12
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
# These are supported funding model platforms
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: th33xitus
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

50
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View File

@@ -0,0 +1,50 @@
name: Bug report
description: Create a report to help us improve
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
This issue form is for reporting bugs only!
If you have a feature request, please use [feature_request](/new?template=feature_request.yml)
- type: textarea
id: distro
attributes:
label: Linux Distribution
description: >-
The linux distribution the issue occured on
validations:
required: true
- type: textarea
id: what-happened
attributes:
label: What happened
description: >-
A clear and concise description of what the bug is.
validations:
required: true
- type: textarea
id: expected-behavior
attributes:
label: What did you expect to happen
description: >-
A clear and concise description of what you expected to happen.
validations:
required: true
- type: textarea
id: repro-steps
attributes:
label: How to reproduce
description: >-
Minimal and precise steps to reproduce this bug.
validations:
required: true
- type: textarea
id: additional-info
attributes:
label: Additional information
description: |
If you have any additional information for us, use the field below.
Please note, you can attach screenshots or screen recordings here, by
dragging and dropping files in the field below.

5
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Klipper Discord
url: https://discord.klipper3d.org/
about: Quickest way to get in contact

View File

@@ -0,0 +1,40 @@
name: Feature request
description: Suggest an idea for this project
labels: ["feature request"]
body:
- type: markdown
attributes:
value: |
This issue form is for feature requests only!
If you've found a bug, please use [bug_report](/new?template=bug_report.yml)
- type: textarea
id: problem-description
attributes:
label: Is your feature request related to a problem? Please describe
description: >-
A clear and concise description of what the problem is.
validations:
required: true
- type: textarea
id: solution-description
attributes:
label: Describe the solution you'd like
description: >-
A clear and concise description of what you want to happen.
validations:
required: true
- type: textarea
id: possible-alternatives
attributes:
label: Describe alternatives you've considered
description: >-
A clear and concise description of any alternative solutions or features you've considered.
- type: textarea
id: additional-info
attributes:
label: Additional information
description: |
If you have any additional information for us, use the field below.
Please note, you can attach screenshots or screen recordings here, by
dragging and dropping files in the field below.

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.idea
.shellcheckrc

View File

@@ -1,12 +1,72 @@
# KIAUH
![main_menu](resources/screenshots/kiauh.png)
# Klipper Installation And Update Helper
![GitHub](https://img.shields.io/github/license/th33xitus/kiauh) ![GitHub Repo stars](https://img.shields.io/github/stars/th33xitus/kiauh) ![GitHub forks](https://img.shields.io/github/forks/th33xitus/kiauh) ![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/th33xitus/kiauh) ![GitHub last commit](https://img.shields.io/github/last-commit/th33xitus/kiauh) ![GitHub contributors](https://img.shields.io/github/contributors/th33xitus/kiauh)
## Klipper Installation And Update Helper
### **📋 Please see the [Changelog](docs/changelog.md) for possible important information !**
This script was actually created for my personal use only but i then decided to make the script accessible for everyone.
It is meant to help guiding you through a complete fresh install of Klipper and optionally the DWC2 web UI + DWC2-for-Klipper.
There are also functions for updating your current installations or removing them from your system.
**📢 Disclaimer: Usage of this script happens at your own risk!**
## First things first: When you decide to use this script, you use it at your own risk!
# THIS VERSION IS WORK IN PROGRESS!!!
# BUGS MAY BE STILL PRESENT!!!
## **🛠️ Instructions:**
For downloading this script it is necessary to have git installed.\
If you haven't, please run `sudo apt-get install git -y` to install git first.\
After git is installed, use the following commands in the given order to download and execute the script:
```shell
cd ~
git clone https://github.com/th33xitus/kiauh.git
./kiauh/kiauh.sh
```
## **🧰 Functions and Features:**
### **Core Functions:**
- **Installing** Klipper to your Raspberry Pi or other Debian based Linux Distribution.
- **Installing** of the Moonraker API (needed for Mainsail, Fluidd and KlipperScreen)
- **Installing** several web interfaces such as Mainsail, Fluidd, Duet Web Control or OctoPrint including their dependencies.
- **Installing** of KlipperScreen (OctoScreen but for Klipper!)
- **Updating** of all the listed installations above excluding OctoPrint. For updating OctoPrint, please use the OctoPrint interface!
- **Removing** of all the listed installations above.
- **Backup** of all the listed installations above.
### **Also possible:**
- Build the Klipper Firmware
- Flash the MCU
- Read ID of the currently connected MCU
- and more ...
### **For a list of additional features please see: [Feature List](docs/features.md)**
## **❗ Notes:**
- Tested **only** on Raspberry Pi OS Lite (Debian 10 Buster)
- Other Debian based distributions can work
- Reported to work on Armbian too
- During the use of this script you might be asked for your sudo password. There are several functions involved which need sudo privileges.
## **🌐 Sources & Further Information**
For more information or instructions to the various components KIAUH can install, please check out the corresponding repositories listed below:
* ⛵[Klipper](https://github.com/Klipper3d/klipper) by [KevinOConnor](https://github.com/KevinOConnor)
* 🌙[Moonraker](https://github.com/Arksine/moonraker) by [Arksine](https://github.com/Arksine)
* 💨[Mainsail](https://github.com/mainsail-crew/mainsail) by [mainsail-crew](https://github.com/mainsail-crew)
* 🌊[Fluidd](https://github.com/fluidd-core/fluidd) by [fluidd-core](https://github.com/fluidd-core)
* 🕸️[Duet Web Control](https://github.com/Duet3D/DuetWebControl) by [Duet3D](https://github.com/Duet3D)
* 🕸️[DWC2-for-Klipper-Socket](https://github.com/Stephan3/dwc2-for-klipper-socket) by [Stephan3](https://github.com/Stephan3)
* 🖥️[KlipperScreen](https://github.com/jordanruthe/KlipperScreen) by [jordanruthe](https://github.com/jordanruthe)
* 🐙[OctoPrint](https://github.com/OctoPrint/OctoPrint) by [OctoPrint](https://github.com/OctoPrint)
* 🔬[PrettyGCode](https://github.com/Kragrathea/pgcode) by [Kragrathea](https://github.com/Kragrathea)
* 🤖[Moonraker-Telegram-Bot](https://github.com/nlef/moonraker-telegram-bot) by [nlef](https://github.com/nlef)
## **Credits**
* A big thank you to [lixxbox](https://github.com/lixxbox) for that awesome KIAUH-Logo!
* Also a big thank you to everyone who supported my work with a [Ko-fi](https://ko-fi.com/th33xitus) !
* Last but not least: Thank you to all contributors and members of the Klipper Community who like and share this project!

165
docs/changelog.md Normal file
View File

@@ -0,0 +1,165 @@
## Changelog
This document covers possible important changes to KIAUH.
### 2022-01-29
* Starting from the 28th of January, Moonraker can make use of PackageKit and PolicyKit.\
More details on that can be found [here](
https://github.com/Arksine/moonraker/issues/349) and [here](https://github.com/Arksine/moonraker/pull/346)
* KIAUH will install Moonrakers PolicyKit rules by default when __installing__ Moonraker
* KIAUH will also install Moonrakers PolicyKit rules when __updating__ Moonraker __via KIAUH__ as of now
### 2021-12-30
* Updated the doc for the usage of the [G-Code Shell Command Extension](docs/gcode_shell_command.md)
* It became apparent, that some user groups are missing on some systems. A missing video group \
membership for example caused issues when installing mjpg-streamer while not using the default pi user. \
Other issues could occur when trying to flash an MCU on Debian or Ubuntu distributions where a user might not be part
of the dialout group by default. A check for the tty group is also done. The tty group is needed for setting
up a linux MCU (currently not yet supported by KIAUH).
* There is an issue when trying to install Mainsail or Fluidd on Ubuntu 21.10. Permissions on that distro seem to have seen a rework
in comparison to 20.04 and users will be greeted with an "Error 403 - Permission denied" message after installing one of Klippers webinterfaces.
I still have to figure out a viable solution for that.
### 2021-09-28
* New Feature! Added an installer for the Telegram Bot for Moonraker by [nlef](https://github.com/nlef).
Checkout his project! Remember to report all issues and/or bugs regarding that project in its corresponding repo and not here 😛.\
You can find it here: https://github.com/nlef/moonraker-telegram-bot
### 2021-09-24
* The flashing function got adjusted a bit. It is now possible to also flash controllers which are connected over UART and thus accessible via `/dev/ttyAMA0`. You now have to select a connection methop prior flashing which is either USB or UART.
* Due to several requests over time I have now created a Ko-fi account for those who want to support this project and my work with a small donation. Many thanks in advance to all future donors. You can support me on Ko-fi with this link: https://ko-fi.com/th33xitus
* As usual, if you find any bugs or issues please report them. I tested the little rework i did with the hardware i have available and haven't encountered any malfunctions of flashing them yet.
### 2021-08-10
* KIAUH now supports the installation of the "PrettyGCode for Klipper" GCode-Viewer created by [Kragrathea](https://github.com/Kragrathea)! Installation, updating and removal are possible with KIAUH. For more details to this cool piece of software, please have a look here: https://github.com/Kragrathea/pgcode
### 2021-07-10
* The NGINX configuration files got updated to be in sync with MainsailOS and FluiddPi. Issues with the NGINX service not starting up due to wrong configuration should be resolved now. To get the updated configuration files, please remove Moonraker and Mainsail / Fluidd with KIAUH first and then re-install it. An automated file check for those configuration files might follow in the future which then automates updating those files if there were important changes.
* The default `moonraker.conf` was updated to reflect the recent changes to the update manager section. The update channel is set to `dev`.
### 2021-06-29
* KIAUH will now patch the new `log_path` to existing moonraker.conf files when updating Moonraker and the entry is missing. Before that, it was necessary that the user provided that path manually to make Fluidd display the logfiles in its interface. This issue should be resolved now.
### 2021-06-15
* Moonraker introduced an optional `log_path` which clients can make use of to show log files located in that folder to their users. More info here: https://github.com/Arksine/moonraker/commit/829b3a4ee80579af35dd64a37ccc092a1f67682a \
Client developers agreed upon using `~/klipper_logs` as the new default log path.\
That means, from now on, Klipper and Moonraker services installed with KIAUH will place their logfiles in that mentioned folder.
* Additionally, KIAUH will now detect Klipper and Moonraker systemd services that still use the old default location of `/tmp/<service>.log` and will update them next time the user updates Klipper and/or Moonraker with the KIAUH update function.
* Additional symlinks for the following logfiles will get created along those update procedures to make them accessible through the webinterface once its supported:
- webcamd.log
- mainsail-access.log
- mainsail-error.log
- fluidd-access.log
- fluidd-error.log
* For MainsailOS and FluiddPi users:\
MainsailOS and FluiddPi will switch the shipped Klipper service from SysVinit to systemd probably with their next release. KIAUH can already help migrate older MainsailOS (0.4.0 and below) and FluiddPi (v1.13.0) releases to match their new service-, file- and folder-structure so you don't have to re-flash the SD-Card of your Raspberry Pi.\
In detail here is what is going to happen when you use the new "CustomPiOS Migration Helper" from the Advanced Menu\
`(Main Menu -> 4 -> Enter -> 10 -> Enter)` in a short summary:
* The Klipper SysVinit service will get replaced by a Klipper systemd service
* Klipper and Moonraker will use the new log-directory `~/klipper_logs`
* The webcamd service gets updated
* The webcamd script gets updated and moved from `/root/bin/webcamd` to `/usr/local/bin/webcamd`
* The NGINX `upstreams.conf` gets updated to be able to configure up to 4 webcams
* The `mainsail.txt` / `fluiddpi.txt` gets moved from `/boot` to `~/klipper_config` and renamed to `webcam.txt`
* Symlinks for the webcamd.log and various NGINX logs get created in `~/klipper_config`
* Configuration files for Klipper, Moonraker and webcamd get added to `/etc/logrotate.d`
* If they still exist, two lines will be removed from the mainsail.cfg or client_macros.cfg macro configurations:\
`SAVE_GCODE_STATE NAME=PAUSE_state` and `RESTORE_GCODE_STATE NAME=PAUSE_state`
* **Please note:**\
The "CustomPiOS Migration Helper" is intended to only work on "vanilla" MainsailOS and FluiddPi systems. Do not try to migrate a modified MainsailOS or FluiddPi system (for example if you already used KIAUH to re-install services or to set up a multi-instance installation for Klipper / Moonraker). This won't work.
### 2021-01-31
* **This is a big one... KIAUH v3.0 is out.**\
With this update you can now install multiple instances of Klipper, Moonraker, Duet Web Control or Octoprint on the same Pi. This was quite a big rework of the whole script. So bugs can appear but with the help of some testers, i think there shouldn't be any critical ones anymore. In this regards thanks to @lixxbox and @zellneralex for testing.
* Important changes to how installations are set up now: All components get installed as systemd services. Installation via init.d was dropped completely! This shouldn't affect you at all, since the common linux distributions like RaspberryPi OS or custom distributions like MainsailOS, FluiddPi or OctoPi support both ways of installing services. I just wanted to mention it here.
* Now with KIAUH v3.0 and multi-instance installation capabilities, there are some things to point out. You will now need to tell KIAUH where your printers configurations are located when installing Klipper for the first time. Even though it is not recommended, you can change this location with the help of KIAUH and rewrite Klipper and Moonraker to use the new location.
* When setting up a multi-instance system, the folder structure will only change slightly. The goal was to keep it as compatible as possible with the custom distributions like mainsailOS and FluiddPi. This should help converting a single-instance setup of mainsailOS/FluiddPi to a multi-instance setup in no time, but keeping single-instance backwards compatibility if needed at a later point in time.
* The folder structure is as follows when setting up multi-instances:\
Each printer instance will get its own folder within your configuration location. The decision to this specific structure was made to make it as painless and easy as possible to convert to a multi-instance setup.
Here is an example:
```shell
/home/<username>
└── klipper_config
├── printer_1
│ ├── printer.cfg
│ └── moonraker.conf
├── printer_2
│ ├── printer.cfg
│ └── moonraker.conf
└── printer_n
├── printer.cfg
└── moonraker.conf
```
* Also when setting up multi-instances of each service, the name of each service slightly changes.
Each service gets its corresponding instance added to the service filename.
**This only applies to multi-instances! Single instance installations with KIAUH will keep their original names!**
Corresponding to the filetree example from above that would mean:
```
Klipper services:
--> klipper-1.service
--> klipper-2.service
--> klipper-n.service
Moonraker services:
--> moonraker-1.service
--> moonraker-2.service
--> moonraker-n.service
```
* The same service file rules from above apply to DWC and OctoPrint even though only Klipper and Moonraker are shown in this example.
* You can start, stop and restart all Klipper, Moonraker, DWC and OctoPrint instances from the KIAUH main menu. For doing this, just type "stop klipper", "start moonraker", "restart octoprint" and so on.
* KIAUH v3.0 relocated its ini-file. It is now a hidden file in the users home-directory calles `.kiauh.ini`. This has the benefit of keeping all values in that file between possible re-installations of KIAUH. Otherwise that file would be lost.
* The option of adding more trusted clients to the moonraker.conf file was dropped. Since you can edit this file right inside of Mainsail or Fluidd, only some basic entries are made which get you running.
* I bet i have missed mentioning other stuff as well because it took me quite some time to re-write many functions. So i just hope you like the new version 😄
### 2020-11-28
* KIAUH now supports the installation, update and removal of [KlipperScreen](https://github.com/jordanruthe/KlipperScreen). This feature was was provided by [jordanruthe](https://github.com/jordanruthe)! Thank you!
### 2020-11-18
* Some changes to Fluidd caused a little rework on how KIAUH will install/update Fluidd from now on. Please see the [fluidd v1.0.0-rc0 release notes](https://github.com/cadriel/fluidd/releases/tag/v1.0.0-rc.0) for further information about what modifications to the moonraker.conf file exactly had to be done. In a nutshell, KIAUH will now always patch the required entries to the moonraker.conf if not already there.
### 2020-10-30:
* The user can now choose to install Klipper as a systemd service.
* The Shell Command extension and `shell_command.py` got renamed to G-Code Shell Command extension and `gcode_shell_command.py`. In case the [pending PR](https://github.com/KevinOConnor/klipper/pull/2173) will be merged in the future, this was an early attempt to dodge possible incompatibilities. The [G-Code Shell Command docs](gcode_shell_command.md) has been updated accordingly.
* The way how KIAUH interacts and writes to the users printer.cfg got changed. Usually KIAUH wrote everything directly into the printer.cfg. The way it will work from now on is, that a new file called `kiauh.cfg` will be created if there is something that needs to be written to the printer.cfg and everything gets written to `kiauh.cfg` instead. The only thing which then gets written to the users printer.cfg is `[include kiauh.cfg]`. This line will be located at the very top of the existing printer.cfg with a little comment as a note. The user can then decide to either keep the `kiauh.cfg` or take its content, places it into the printer.cfg directly and remove the `[include kiauh.cfg]`.
* The `mainsail_macros.cfg` got renamed to `webui_macros.cfg`. Since Mainsail and Fluidd both use the same kind of pause, cancel and resume macros, a more generic name was chosen for the file containing the example macros one can choose to install when installing those webinterfaces.
### 2020-10-10:
* Support for changing the Klipper branch to the moonraker-dev branch from @Arksine has been dropped. Support for Moonraker has been merged into Klipper mainline a long time ago.
* A new function is available from the main menu. You can now upload your log files to http://paste.c-net.org/ to share them for debugging purposes.
### 2020-10-06:
* Fluidd, a new Klipper interface got added to the list of available installers. At the same time some installation routines have changed or have seen some rework. Changes were made to the installation of NGINX configurations. A method was introduced to change the listen port of a webinterface configuration if there is already another webinterface listening on the default port (80).
* At the moment, the Moonraker installer no longer asks you whether you want to install a web interface too. For now you therefore have to install them with their respective installers. Please report any bugs or issues you encounter.
### 2020-09-17:
* The dev-2.0 branch will be abandoned as of today. If you did a checkout to that branch in the past, you have to checkout back to master to receive updates.
### 2020-09-12:
* The old [dwc2-for-klipper](https://github.com/Stephan3/dwc2-for-klipper) won't be supported anymore!\
The is a new, fully rewritten project available: [dwc2-for-klipper-socket](https://github.com/Stephan3/dwc2-for-klipper-socket).\
The installer of this script also got rewritten to make use of that new project. You will not be able to install or remove the old [dwc2-for-klipper](https://github.com/Stephan3/dwc2-for-klipper) with KIAUH anymore if you updated KIAUH to the newest version.

28
docs/features.md Normal file
View File

@@ -0,0 +1,28 @@
# Feature List:
- **Automatic dependency check:**\
If packages are missing but needed for the asked task, the script will automatically install them
- **Switch between different Klipper Forks:**\
[origin/master](https://github.com/KevinOConnor/klipper/tree/master) or [scurve-shaping](https://github.com/dmbutyugin/klipper/tree/scurve-shaping) or [scurve-smoothing](https://github.com/dmbutyugin/klipper/tree/scurve-smoothing)\
The update function of the script will always update the currently selected/active fork!
- **Toggle auto-create backups before updating:**\
When enabled, a backup of the installation you want to update is made prior updating
- **Rollback:**\
When updating Klipper, KIAUH saves the current commit hash to a local ini-file. In case of an unsuccesfull update you can use this function to quickly revert back to the commit with the hash you updated from.
- **Preconfigure OctoPrint:**\
When installing OctoPrint, a config is created which preconfigures your installation to be used with Klipper.\
That means:
- adding the restart/shutdown commands for OctoPrint
- adding the serial port `/tmp/printer`
- set the behavior to "Cancel any ongoing prints but stay connected to the printer"
- **Enable/Disable OctoPrint Service:**\
Usefull when using DWC2/Mainsail/Fluidd and OctoPrint at the same time to prevent them interfering with each other
- **Installing a G-Code Shell Command extension:**\
For further information about that extension please see the [G-Code Shell Command Extension Doc](gcode_shell_command.md)
- **Uploading logfiles:**\
You can directly upload logfiles like klippy.log, moonraker.log and dwc2.log from the KIAUH main menu for providing them for troubleshooting purposes.
to be continued...

View File

@@ -0,0 +1,74 @@
# G-Code Shell Command Extension
### Creator of this extension is [Arksine](https://github.com/Arksine).
This is a brief explanation of how to use the shell command extension for Klipper, which you can install with KIAUH.
After installing the extension you can execute linux commands or even scripts from within Klipper with custom commands defined in your printer.cfg.
#### How to configure a shell command:
```shell
# Runs a linux command or script from within klipper. Note that sudo commands
# that require password authentication are disallowed. All executable scripts
# should include a shebang.
# [gcode_shell_command my_shell_cmd]
#command:
# The linux shell command/script to be executed. This parameter must be
# provided
#timeout: 2.
# The timeout in seconds until the command is forcably terminated. Default
# is 2 seconds.
#verbose: True
# If enabled, the command's output will be forwarded to the terminal. Its
# recommended to set this to false for commands that my run in quick
# succession. Default is True.
```
Once you have set up a shell command with the given parameters from above in your printer.cfg you can run the command as follows:
`RUN_SHELL_COMMAND CMD=name`
Example:
```
[gcode_shell_command hello_world]
command: echo hello world
timeout: 2.
verbose: True
```
Execute with:
`RUN_SHELL_COMMAND CMD=hello_world`
### Passing parameters:
As of commit [f231fa9](https://github.com/th33xitus/kiauh/commit/f231fa9c69191f23277b4e3319f6b675bfa0ee42) it is also possible to pass optional parameters to a `gcode_shell_command`.
The following short example shows storing the extruder temperature into a variable, passing that value with a parameter to a `gcode_shell_command`, which then,
once the gcode_macro runs and the gcode_shell_command gets called, executes the `script.sh`. The script then echoes a message to the console (if `verbose: True`)
and writes the value of the parameter into a textfile called `test.txt` located in the home directory.
Content of the `gcode_shell_command` and the `gcode_macro`:
```
[gcode_shell_command print_to_file]
command: sh /home/pi/klipper_config/script.sh
timeout: 30.
verbose: True
[gcode_macro GET_TEMP]
gcode:
{% set temp = printer.extruder.temperature %}
{ action_respond_info("%s" % (temp)) }
RUN_SHELL_COMMAND CMD=print_to_file PARAMS={temp}
```
Content of `script.sh`:
```shell
#!/bin/sh
echo "temp is: $1"
echo "$1" >> "${HOME}/test.txt"
```
## Warning
This extension may have a high potential for abuse if not used carefully! Also, depending on the command you execute, high system loads may occur and can cause system instabilities.
Use this extension at your own risk and only if you know what you are doing!

View File

@@ -1 +0,0 @@
backup_before_update=false

428
kiauh.sh Normal file → Executable file
View File

@@ -2,13 +2,60 @@
clear
set -e
### set some variables
ERROR_MSG=""
green="\e[92m"
yellow="\e[93m"
red="\e[91m"
cyan="\e[96m"
default="\e[39m"
### set color variables
green=$(echo -en "\e[92m")
yellow=$(echo -en "\e[93m")
red=$(echo -en "\e[91m")
cyan=$(echo -en "\e[96m")
default=$(echo -en "\e[39m")
### sourcing all additional scripts
SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )"
for script in "${SRCDIR}/kiauh/scripts/"*.sh; do . $script; done
for script in "${SRCDIR}/kiauh/scripts/ui/"*.sh; do . $script; done
### set important directories
#klipper
KLIPPER_DIR=${HOME}/klipper
KLIPPY_ENV=${HOME}/klippy-env
#nginx
NGINX_SA=/etc/nginx/sites-available
NGINX_SE=/etc/nginx/sites-enabled
NGINX_CONFD=/etc/nginx/conf.d
#moonraker
MOONRAKER_DIR=${HOME}/moonraker
MOONRAKER_ENV=${HOME}/moonraker-env
#mainsail
MAINSAIL_DIR=${HOME}/mainsail
#fluidd
FLUIDD_DIR=${HOME}/fluidd
#dwc2
DWC2FK_DIR=${HOME}/dwc2-for-klipper-socket
DWC_ENV_DIR=${HOME}/dwc-env
DWC2_DIR=${HOME}/duetwebcontrol
#octoprint
OCTOPRINT_DIR=${HOME}/OctoPrint
OCTOPRINT_CFG_DIR=${HOME}/.octoprint
#KlipperScreen
KLIPPERSCREEN_DIR=${HOME}/KlipperScreen
KLIPPERSCREEN_ENV_DIR=${HOME}/.KlipperScreen-env
#MoonrakerTelegramBot
MOONRAKER_TELEGRAM_BOT_DIR=${HOME}/moonraker-telegram-bot
MOONRAKER_TELEGRAM_BOT_ENV_DIR=${HOME}/moonraker-telegram-bot-env
#misc
INI_FILE=${HOME}/.kiauh.ini
BACKUP_DIR=${HOME}/kiauh-backups
### set github repos
KLIPPER_REPO=https://github.com/Klipper3d/klipper.git
ARKSINE_REPO=https://github.com/Arksine/klipper.git
DMBUTYUGIN_REPO=https://github.com/dmbutyugin/klipper.git
DWC2FK_REPO=https://github.com/Stephan3/dwc2-for-klipper-socket.git
KLIPPERSCREEN_REPO=https://github.com/jordanruthe/KlipperScreen.git
NLEF_REPO=https://github.com/nlef/moonraker-telegram-bot.git
#branches
BRANCH_SCURVE_SMOOTHING=dmbutyugin/scurve-smoothing
BRANCH_SCURVE_SHAPING=dmbutyugin/scurve-shaping
### set some messages
warn_msg(){
@@ -24,364 +71,35 @@ title_msg(){
echo -e "${cyan}$1${default}"
}
get_date(){
current_date=`date +"%Y-%m-%d_%H%M%S"`
current_date=$(date +"%y%m%d-%H%M")
}
print_unkown_cmd(){
ERROR_MSG="Invalid command!"
}
### sourcing all additional scripts
for script in ${HOME}/kiauh/scripts/*; do . $script; done
### set important directories
#klipper
KLIPPER_DIR=${HOME}/klipper
KLIPPY_ENV_DIR=${HOME}/klippy-env
KLIPPER_SERVICE1=/etc/init.d/klipper
KLIPPER_SERVICE2=/etc/default/klipper
#dwc2
DWC2FK_DIR=${HOME}/dwc2-for-klipper
DWC2_DIR=${HOME}/sdcard/dwc2
WEB_DWC2=${HOME}/klipper/klippy/extras/web_dwc2.py
TORNADO_DIR1=${HOME}/klippy-env/lib/python2.7/site-packages/tornado
TORNADO_DIR2=${HOME}/klippy-env/lib/python2.7/site-packages/tornado-5.1.1.dist-info
#mainsail/moonraker
MAINSAIL_DIR=${HOME}/mainsail
MAINSAIL_SERVICE1=/etc/init.d/moonraker
MAINSAIL_SERVICE2=/etc/default/moonraker
#misc
BACKUP_DIR=${HOME}/kiauh-backups
PRINTER_CFG=${HOME}/printer.cfg
### set github repos
KLIPPER_REPO=https://github.com/KevinOConnor/klipper.git
ARKSINE_REPO=https://github.com/Arksine/klipper.git
DMBUTYUGIN_REPO=https://github.com/dmbutyugin/klipper.git
DWC2FK_REPO=https://github.com/Stephan3/dwc2-for-klipper.git
#branches
BRANCH_MOONRAKER=Arksine/work-web_server-20200131
BRANCH_DEV_MOONRAKER=Arksine/dev-moonraker-testing
BRANCH_SCURVE_SMOOTHING=dmbutyugin/scurve-smoothing
BRANCH_SCURVE_SHAPING=dmbutyugin/scurve-shaping
print_error_msg(){
print_msg(){
if [[ "$ERROR_MSG" != "" ]]; then
echo -e "${red}"
echo -e "#########################################################"
echo -e "$ERROR_MSG "
echo -e " $ERROR_MSG "
echo -e "#########################################################"
echo -e "${default}"
fi
if [ "$CONFIRM_MSG" != "" ]; then
echo -e "${green}"
echo -e "#########################################################"
echo -e " $CONFIRM_MSG "
echo -e "#########################################################"
echo -e "${default}"
fi
}
main_menu(){
print_header
print_error_msg && ERROR_MSG=""
#check install status
klipper_status
dwc2_status
mainsail_status
print_branch
main_ui
while true; do
read -p "Perform action: " action; echo
case "$action" in
0)
clear
print_header
ERROR_MSG=" Sorry this function is not implemented yet!"
print_error_msg && ERROR_MSG=""
main_ui;;
1)
clear
install_menu
break;;
2)
clear
update_menu
break;;
3)
clear
remove_menu
break;;
4)
clear
advanced_menu
break;;
5)
clear
backup_menu
break;;
Q|q)
exit -1;;
*)
clear
print_header
ERROR_MSG=" Unknown command '$action'"
print_error_msg && ERROR_MSG=""
main_ui;;
esac
done
clear; main_menu
}
install_menu(){
print_header
install_ui
while true; do
read -p "Perform action: " action; echo
case "$action" in
1)
clear
print_header
install_klipper
print_error_msg && ERROR_MSG=""
install_ui;;
2)
clear
print_header
dwc2_install_routine
print_error_msg && ERROR_MSG=""
install_ui;;
3)
clear
print_header
mainsail_install_routine
print_error_msg && ERROR_MSG=""
install_ui;;
Q|q)
clear; main_menu; break;;
*)
clear
print_header
ERROR_MSG=" Unknown command '$action'"
print_error_msg && ERROR_MSG=""
install_ui;;
esac
done
install_menu
}
update_menu(){
print_header
read_bb4u_stat
#compare versions
ui_print_versions
update_ui
while true; do
read -p "Perform action: " action; echo
case "$action" in
0)
clear
print_header
toggle_backups
print_error_msg && ERROR_MSG=""
update_ui;;
1)
clear
print_header
update_klipper && ui_print_versions
print_error_msg && ERROR_MSG=""
update_ui;;
2)
clear
print_header
update_dwc2fk && ui_print_versions
print_error_msg && ERROR_MSG=""
update_ui;;
3)
clear
print_header
update_dwc2 && ui_print_versions
print_error_msg && ERROR_MSG=""
update_ui;;
4)
clear
print_header
update_mainsail && ui_print_versions
print_error_msg && ERROR_MSG=""
update_ui;;
Q|q)
clear; main_menu; break;;
*)
clear
print_header
ERROR_MSG=" Unknown command '$action'"
print_error_msg && ERROR_MSG=""
ui_print_versions
update_ui;;
esac
done
update_menu
}
remove_menu(){
print_header
remove_ui
while true; do
read -p "Perform action: " action; echo
case "$action" in
1)
clear
print_header
remove_klipper
print_error_msg && ERROR_MSG=""
remove_ui;;
2)
clear
print_header
remove_dwc2
print_error_msg && ERROR_MSG=""
remove_ui;;
3)
clear
print_header
remove_mainsail
print_error_msg && ERROR_MSG=""
remove_ui;;
Q|q)
clear; main_menu; break;;
*)
clear
print_header
ERROR_MSG=" Unknown command '$action'"
print_error_msg && ERROR_MSG=""
remove_ui;;
esac
done
remove_menu
}
advanced_menu(){
print_header
print_error_msg && ERROR_MSG=""
advanced_ui
while true; do
read -p "Perform action: " action; echo
case "$action" in
1)
clear
switch_menu
print_error_msg && ERROR_MSG=""
advanced_ui;;
2)
clear
print_header
build_fw
print_error_msg && ERROR_MSG=""
advanced_ui;;
3)
clear
print_header
flash_routine
print_error_msg && ERROR_MSG=""
advanced_ui;;
4)
clear
print_header
get_usb_id
print_error_msg && ERROR_MSG=""
advanced_ui;;
5)
clear
print_header
get_usb_id && write_printer_id
print_error_msg && ERROR_MSG=""
advanced_ui;;
6)
clear
print_header
create_dwc2fk_cfg
print_error_msg && ERROR_MSG=""
advanced_ui;;
Q|q)
clear; main_menu; break;;
*)
clear
print_header
ERROR_MSG=" Unknown command '$action'"
print_error_msg && ERROR_MSG=""
advanced_ui;;
esac
done
advanced_menu
}
switch_menu(){
print_header
if [ -d $KLIPPER_DIR ]; then
read_branch
print_error_msg && ERROR_MSG=""
switch_ui
while true; do
read -p "Perform action: " action; echo
case "$action" in
1)
clear
print_header
switch_to_origin
read_branch
print_error_msg && ERROR_MSG=""
switch_ui;;
2)
clear
print_header
switch_to_scurve_shaping
read_branch
print_error_msg && ERROR_MSG=""
switch_ui;;
3)
clear
print_header
switch_to_scurve_smoothing
read_branch
print_error_msg && ERROR_MSG=""
switch_ui;;
4)
clear
print_header
switch_to_moonraker
read_branch
print_error_msg && ERROR_MSG=""
switch_ui;;
5)
clear
print_header
switch_to_dev_moonraker
read_branch
print_error_msg && ERROR_MSG=""
switch_ui;;
Q|q)
clear; advanced_menu; break;;
esac
done
else
ERROR_MSG=" No klipper directory found! Download klipper first!"
fi
}
backup_menu(){
print_header
print_error_msg && ERROR_MSG=""
backup_ui
while true; do
read -p "Perform action: " action; echo
case "$action" in
1)
clear
print_header
#function goes here
print_error_msg && ERROR_MSG=""
backup_ui;;
Q|q)
clear; main_menu; break;;
*)
clear
print_header
ERROR_MSG=" Unknown command '$action'"
print_error_msg && ERROR_MSG=""
backup_ui;;
esac
done
backup_menu
clear_msg(){
unset CONFIRM_MSG
unset ERROR_MSG
}
check_euid
main_menu
init_ini
kiauh_status
main_menu

62
resources/autocommit.sh Executable file
View File

@@ -0,0 +1,62 @@
#!/bin/bash
#####################################################################
### Please set the paths accordingly. In case you don't have all ###
### the listed folders, just keep that line commented out. ###
#####################################################################
### Path to your config folder you want to backup
#config_folder=~/klipper_config
### Path to your Klipper folder, by default that is '~/klipper'
#klipper_folder=~/klipper
### Path to your Moonraker folder, by default that is '~/moonraker'
#moonraker_folder=~/moonraker
### Path to your Mainsail folder, by default that is '~/mainsail'
#mainsail_folder=~/mainsail
### Path to your Fluidd folder, by default that is '~/fluidd'
#fluidd_folder=~/fluidd
#####################################################################
#####################################################################
#####################################################################
################ !!! DO NOT EDIT BELOW THIS LINE !!! ################
#####################################################################
grab_version(){
if [ ! -z "$klipper_folder" ]; then
cd "$klipper_folder"
klipper_commit=$(git rev-parse --short=7 HEAD)
m1="Klipper on commit: $klipper_commit"
cd ..
fi
if [ ! -z "$moonraker_folder" ]; then
cd "$moonraker_folder"
moonraker_commit=$(git rev-parse --short=7 HEAD)
m2="Moonraker on commit: $moonraker_commit"
cd ..
fi
if [ ! -z "$mainsail_folder" ]; then
mainsail_ver=$(head -n 1 $mainsail_folder/.version)
m3="Mainsail version: $mainsail_ver"
fi
if [ ! -z "$fluidd_folder" ]; then
fluidd_ver=$(head -n 1 $fluidd_folder/.version)
m4="Fluidd version: $fluidd_ver"
fi
}
push_config(){
cd $config_folder
git pull
git add .
current_date=$(date +"%Y-%m-%d %T")
git commit -m "Autocommit from $current_date" -m "$m1" -m "$m2" -m "$m3" -m "$m4"
git push
}
grab_version
push_config

View File

@@ -0,0 +1,6 @@
# /etc/nginx/conf.d/common_vars.conf
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}

26
resources/dwc2_nginx.cfg Normal file
View File

@@ -0,0 +1,26 @@
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream dwc2 {
server 127.0.0.1:4750;
}
server {
listen 80;
#listen [::]:80;
location / {
proxy_pass http://dwc2/;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
#proxy_set_header X-Script-Name /;
proxy_http_version 1.1;
client_max_body_size 0;
}
}

View File

@@ -0,0 +1,87 @@
# Run a shell command via gcode
#
# Copyright (C) 2019 Eric Callahan <arksine.code@gmail.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import os
import shlex
import subprocess
import logging
class ShellCommand:
def __init__(self, config):
self.name = config.get_name().split()[-1]
self.printer = config.get_printer()
self.gcode = self.printer.lookup_object('gcode')
cmd = config.get('command')
cmd = os.path.expanduser(cmd)
self.command = shlex.split(cmd)
self.timeout = config.getfloat('timeout', 2., above=0.)
self.verbose = config.getboolean('verbose', True)
self.proc_fd = None
self.partial_output = ""
self.gcode.register_mux_command(
"RUN_SHELL_COMMAND", "CMD", self.name,
self.cmd_RUN_SHELL_COMMAND,
desc=self.cmd_RUN_SHELL_COMMAND_help)
def _process_output(self, eventime):
if self.proc_fd is None:
return
try:
data = os.read(self.proc_fd, 4096)
except Exception:
pass
data = self.partial_output + data.decode()
if '\n' not in data:
self.partial_output = data
return
elif data[-1] != '\n':
split = data.rfind('\n') + 1
self.partial_output = data[split:]
data = data[:split]
else:
self.partial_output = ""
self.gcode.respond_info(data)
cmd_RUN_SHELL_COMMAND_help = "Run a linux shell command"
def cmd_RUN_SHELL_COMMAND(self, params):
gcode_params = params.get('PARAMS','')
gcode_params = shlex.split(gcode_params)
reactor = self.printer.get_reactor()
try:
proc = subprocess.Popen(
self.command + gcode_params, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
except Exception:
logging.exception(
"shell_command: Command {%s} failed" % (self.name))
raise self.gcode.error("Error running command {%s}" % (self.name))
if self.verbose:
self.proc_fd = proc.stdout.fileno()
self.gcode.respond_info("Running Command {%s}...:" % (self.name))
hdl = reactor.register_fd(self.proc_fd, self._process_output)
eventtime = reactor.monotonic()
endtime = eventtime + self.timeout
complete = False
while eventtime < endtime:
eventtime = reactor.pause(eventtime + .05)
if proc.poll() is not None:
complete = True
break
if not complete:
proc.terminate()
if self.verbose:
if self.partial_output:
self.gcode.respond_info(self.partial_output)
self.partial_output = ""
if complete:
msg = "Command {%s} finished\n" % (self.name)
else:
msg = "Command {%s} timed out" % (self.name)
self.gcode.respond_info(msg)
reactor.unregister_fd(hdl)
self.proc_fd = None
def load_config_prefix(config):
return ShellCommand(config)

View File

@@ -0,0 +1,59 @@
################################################################################
# ~~~~~~~~~~~~~~~~~~~~~~~~ AUTOCREATED WITH KIAUH ~~~~~~~~~~~~~~~~~~~~~~~~~~ #
################################################################################
# Recommended macros and config entries if you use Mainsail or Fluidd! #
# You can edit or delete those macros if you already defined them elsewhere! #
################################################################################
[pause_resume]
[display_status]
[gcode_macro CANCEL_PRINT]
rename_existing: BASE_CANCEL_PRINT
gcode:
TURN_OFF_HEATERS
CLEAR_PAUSE
SDCARD_RESET_FILE
BASE_CANCEL_PRINT
[gcode_macro PAUSE]
rename_existing: BASE_PAUSE
gcode:
##### set defaults #####
{% set x = params.X|default(230) %} #edit to your park position
{% set y = params.Y|default(230) %} #edit to your park position
{% set z = params.Z|default(10)|float %} #edit to your park position
{% set e = params.E|default(1) %} #edit to your retract length
##### calculate save lift position #####
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% set lift_z = z|abs %}
{% if act_z < (max_z - lift_z) %}
{% set z_safe = lift_z %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
##### end of definitions #####
SAVE_GCODE_STATE NAME=PAUSE_state
BASE_PAUSE
G91
G1 E-{e} F2100
G1 Z{z_safe}
G90
G1 X{x} Y{y} F6000
[gcode_macro RESUME]
rename_existing: BASE_RESUME
gcode:
##### set defaults #####
{% set e = params.E|default(1) %} #edit to your retract length
G91
G1 E{e} F2100
G90
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1
BASE_RESUME
################################################################################
################################################################################

15
resources/klipper.service Normal file
View File

@@ -0,0 +1,15 @@
#Systemd service file for klipper
[Unit]
Description=Starts klipper instance %INST% on startup
After=network.target
[Install]
WantedBy=multi-user.target
[Service]
Type=simple
User=%USER%
RemainAfterExit=yes
ExecStart=%KL_ENV%/bin/python %KL_DIR%/klippy/klippy.py %P_CFG% -I %P_TMP% -l %KL_LOG% -a %KL_UDS%
Restart=always
RestartSec=10

View File

@@ -0,0 +1,95 @@
# /etc/nginx/sites-available/<<UI>>
server {
listen 80;
access_log /var/log/nginx/<<UI>>-access.log;
error_log /var/log/nginx/<<UI>>-error.log;
# disable this section on smaller hardware like a pi zero
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_proxied expired no-cache no-store private auth;
gzip_comp_level 4;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css text/xml text/javascript application/javascript application/x-javascript application/json application/xml;
# web_path from <<UI>> static files
root /home/pi/<<UI>>;
index index.html;
server_name _;
# disable max upload size checks
client_max_body_size 0;
# disable proxy request buffering
proxy_request_buffering off;
location / {
try_files $uri $uri/ /index.html;
}
location = /index.html {
add_header Cache-Control "no-store, no-cache, must-revalidate";
}
location /websocket {
proxy_pass http://apiserver/websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 86400;
}
location ~ ^/(printer|api|access|machine|server)/ {
proxy_pass http://apiserver$request_uri;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
}
location /webcam/ {
postpone_output 0;
proxy_buffering off;
proxy_ignore_headers X-Accel-Buffering;
access_log off;
error_log off;
proxy_pass http://mjpgstreamer1/;
}
location /webcam2/ {
postpone_output 0;
proxy_buffering off;
proxy_ignore_headers X-Accel-Buffering;
access_log off;
error_log off;
proxy_pass http://mjpgstreamer2/;
}
location /webcam3/ {
postpone_output 0;
proxy_buffering off;
proxy_ignore_headers X-Accel-Buffering;
access_log off;
error_log off;
proxy_pass http://mjpgstreamer3/;
}
location /webcam4/ {
postpone_output 0;
proxy_buffering off;
proxy_ignore_headers X-Accel-Buffering;
access_log off;
error_log off;
proxy_pass http://mjpgstreamer4/;
}
}

56
resources/moonraker.conf Normal file
View File

@@ -0,0 +1,56 @@
[server]
host: 0.0.0.0
port: %PORT%
enable_debug_logging: False
klippy_uds_address: %UDS%
[database]
database_path: %MR_DB%
[authorization]
trusted_clients:
%LAN%
10.0.0.0/8
127.0.0.0/8
169.254.0.0/16
172.16.0.0/12
192.168.0.0/16
FE80::/10
::1/128
cors_domains:
http://*.lan
http://*.local
https://my.mainsail.xyz
http://my.mainsail.xyz
https://app.fluidd.xyz
http://app.fluidd.xyz
[file_manager]
config_path: %CFG%
log_path: %LOG%
[octoprint_compat]
[history]
[update_manager]
channel: dev
refresh_interval: 168
[update_manager mainsail]
type: web
repo: mainsail-crew/mainsail
path: ~/mainsail
[update_manager fluidd]
type: web
repo: fluidd-core/fluidd
path: ~/fluidd
#[update_manager KlipperScreen]
#type: git_repo
#path: /home/%USER%/KlipperScreen
#origin: https://github.com/jordanruthe/KlipperScreen.git
#env: /home/%USER%/.KlipperScreen-env/bin/python
#requirements: scripts/KlipperScreen-requirements.txt
#install_script: scripts/KlipperScreen-install.sh

View File

@@ -0,0 +1,16 @@
#Systemd service file for moonraker
[Unit]
Description=Starts Moonraker %INST% on startup
After=network.target
[Install]
WantedBy=multi-user.target
[Service]
Type=simple
SupplementaryGroups=moonraker-admin
User=%USER%
RemainAfterExit=yes
ExecStart=%MR_ENV%/bin/python %MR_DIR%/moonraker/moonraker.py -l %MR_LOG% -c %MR_CONF%
Restart=always
RestartSec=10

View File

@@ -0,0 +1,40 @@
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream octoprint {
server 127.0.0.1:5000;
}
upstream mjpg-streamer {
server 127.0.0.1:8080;
}
server {
listen 80;
#listen [::]:80;
location / {
proxy_pass http://octoprint/;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
#proxy_set_header X-Script-Name /;
proxy_http_version 1.1;
client_max_body_size 0;
}
location /webcam {
proxy_pass http://mjpg-streamer/;
}
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}

14
resources/printer.cfg Normal file
View File

@@ -0,0 +1,14 @@
[mcu]
serial: /dev/serial/by-id/<your-mcu-id>
[pause_resume]
[display_status]
[virtual_sdcard]
path: ~/gcode_files
[printer]
kinematics: none
max_velocity: 1000
max_accel: 1000

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@@ -0,0 +1,7 @@
[gcode_shell_command hello_world]
command: echo hello world
timeout: 2.
verbose: True
[gcode_macro HELLO_WORLD]
gcode:
RUN_SHELL_COMMAND CMD=hello_world

25
resources/upstreams.conf Normal file
View File

@@ -0,0 +1,25 @@
# /etc/nginx/conf.d/upstreams.conf
upstream apiserver {
ip_hash;
server 127.0.0.1:7125;
}
upstream mjpgstreamer1 {
ip_hash;
server 127.0.0.1:8080;
}
upstream mjpgstreamer2 {
ip_hash;
server 127.0.0.1:8081;
}
upstream mjpgstreamer3 {
ip_hash;
server 127.0.0.1:8082;
}
upstream mjpgstreamer4 {
ip_hash;
server 127.0.0.1:8083;
}

15
resources/webcamd.service Normal file
View File

@@ -0,0 +1,15 @@
[Unit]
Description=Starts mjpg-streamer on startup
After=network.target
[Install]
WantedBy=multi-user.target
[Service]
Type=forking
User=%USER%
WorkingDirectory=/usr/local/bin
StandardOutput=append:/var/log/webcamd.log
StandardError=append:/var/log/webcamd.log
ExecStart=/usr/local/bin/webcamd
Restart=always

205
scripts/backup.sh Normal file → Executable file
View File

@@ -1,19 +1,33 @@
backup_printer_cfg(){
check_for_backup_dir(){
if [ ! -d $BACKUP_DIR ]; then
status_msg "Create backup directory ..."
status_msg "Create KIAUH backup directory ..."
mkdir -p $BACKUP_DIR && ok_msg "Directory created!"
fi
if [ -f $PRINTER_CFG ]; then
get_date
status_msg "Create backup of printer.cfg ..."
cp $PRINTER_CFG $BACKUP_DIR/printer.cfg."$current_date".backup && ok_msg "Backup created!"
else
ok_msg "No printer.cfg found! Skipping backup ..."
}
toggle_backups(){
source_kiauh_ini
if [ "$backup_before_update" = "true" ]; then
sed -i '/backup_before_update=/s/true/false/' $INI_FILE
BB4U_STATUS="${green}[Enable]${default} backups before updating "
CONFIRM_MSG=" Backups before updates are now >>> DISABLED <<< !"
fi
if [ "$backup_before_update" = "false" ]; then
sed -i '/backup_before_update=/s/false/true/' $INI_FILE
BB4U_STATUS="${red}[Disable]${default} backups before updating "
CONFIRM_MSG=" Backups before updates are now >>> ENABLED <<< !"
fi
}
bb4u(){
source_kiauh_ini
if [ "$backup_before_update" = "true" ]; then
backup_$1
fi
}
read_bb4u_stat(){
source_ini
source_kiauh_ini
if [ ! "$backup_before_update" = "true" ]; then
BB4U_STATUS="${green}[Enable]${default} backups before updating "
else
@@ -21,54 +35,161 @@ read_bb4u_stat(){
fi
}
toggle_backups(){
source_ini
if [ "$backup_before_update" = "true" ]; then
sed -i '/backup_before_update=/s/true/false/' ${HOME}/kiauh2/kiauh.ini
BB4U_STATUS="${green}[Enable]${default} backups before updating "
fi
if [ "$backup_before_update" = "false" ]; then
sed -i '/backup_before_update=/s/false/true/' ${HOME}/kiauh2/kiauh.ini
BB4U_STATUS="${red}[Disable]${default} backups before updating "
################################################################################
#******************************************************************************#
################################################################################
backup_printer_cfg(){
check_for_backup_dir
if [ -f $PRINTER_CFG ]; then
get_date
status_msg "Timestamp: $current_date"
status_msg "Create backup of printer.cfg ..."
cp $PRINTER_CFG $BACKUP_DIR/printer.cfg."$current_date".backup && ok_msg "Backup complete!"
else
ok_msg "No printer.cfg found! Skipping backup ..."
fi
}
bb4u_klipper(){
source_ini
if [ -d $KLIPPER_DIR ] && [ "$backup_before_update" = "true" ]; then
backup_klipper_config_dir(){
source_kiauh_ini
check_for_backup_dir
if [ -d "$klipper_cfg_loc" ]; then
get_date
status_msg "Timestamp: $current_date"
status_msg "Create backup of the Klipper config directory ..."
config_folder_name="$(echo "$klipper_cfg_loc" | rev | cut -d"/" -f1 | rev)"
mkdir -p $BACKUP_DIR/$config_folder_name/$current_date
cp -r "$klipper_cfg_loc" "$_" && ok_msg "Backup complete!"
echo
else
ok_msg "No config directory found! Skipping backup ..."
echo
fi
}
backup_moonraker_database(){
check_for_backup_dir
if ls -d ${HOME}/.moonraker_database* 2>/dev/null 1>&2; then
get_date
status_msg "Timestamp: $current_date"
mkdir -p "$BACKUP_DIR/mr_db_backup/$current_date"
for database in $(ls -d ${HOME}/.moonraker_database*)
do
status_msg "Create backup of $database ..."
cp -r $database "$BACKUP_DIR/mr_db_backup/$current_date"
ok_msg "Done!"
done
ok_msg "Backup complete!\n"
else
ok_msg "No Moonraker database found! Skipping backup ..."
fi
}
backup_klipper(){
if [ -d $KLIPPER_DIR ] && [ -d $KLIPPY_ENV ]; then
status_msg "Creating Klipper backup ..."
check_for_backup_dir
get_date
status_msg "Timestamp: $current_date"
mkdir -p $BACKUP_DIR/klipper-backups/"$current_date"
cp -r $KLIPPER_DIR $_ && cp -r $KLIPPY_ENV_DIR $_ && ok_msg "Backup complete!"
cp -r $KLIPPER_DIR $_ && cp -r $KLIPPY_ENV $_ && ok_msg "Backup complete!"
else
ERROR_MSG=" Can't backup klipper and/or klipper-env directory! Not found!"
fi
}
bb4u_dwc2fk(){
source_ini
if [ -d $DWC2FK_DIR ] && [ "$backup_before_update" = "true" ]; then
get_date
status_msg "Creating DWC2-for-Klipper backup ..."
mkdir -p $BACKUP_DIR/dwc2-for-klipper-backups/"$current_date"
cp -r $DWC2FK_DIR $_ && ok_msg "Backup complete!"
fi
}
bb4u_dwc2(){
source_ini
if [ -d $DWC2_DIR ] && [ "$backup_before_update" = "true" ]; then
get_date
backup_dwc2(){
if [ -d $DWC2FK_DIR ] && [ -d $DWC_ENV_DIR ] && [ -d $DWC2_DIR ]; then
status_msg "Creating DWC2 Web UI backup ..."
check_for_backup_dir
get_date
status_msg "Timestamp: $current_date"
mkdir -p $BACKUP_DIR/dwc2-backups/"$current_date"
cp -r $DWC2_DIR $_ && ok_msg "Backup complete!"
cp -r $DWC2FK_DIR $_ && cp -r $DWC_ENV_DIR $_ && cp -r $DWC2_DIR $_
ok_msg "Backup complete!"
else
ERROR_MSG=" Can't backup dwc2-for-klipper-socket and/or dwc2 directory!\n Not found!"
fi
}
bb4u_mainsail(){
source_ini
if [ -d $MAINSAIL_DIR ] && [ "$backup_before_update" = "true" ]; then
get_date
backup_mainsail(){
if [ -d $MAINSAIL_DIR ]; then
status_msg "Creating Mainsail backup ..."
check_for_backup_dir
get_date
status_msg "Timestamp: $current_date"
mkdir -p $BACKUP_DIR/mainsail-backups/"$current_date"
cp -r $MAINSAIL_DIR $_ && ok_msg "Backup complete!"
else
ERROR_MSG=" Can't backup mainsail directory! Not found!"
fi
}
}
backup_fluidd(){
if [ -d $FLUIDD_DIR ]; then
status_msg "Creating Fluidd backup ..."
check_for_backup_dir
get_date
status_msg "Timestamp: $current_date"
mkdir -p $BACKUP_DIR/fluidd-backups/"$current_date"
cp -r $FLUIDD_DIR $_ && ok_msg "Backup complete!"
else
ERROR_MSG=" Can't backup fluidd directory! Not found!"
fi
}
backup_moonraker(){
if [ -d $MOONRAKER_DIR ] && [ -d $MOONRAKER_ENV ]; then
status_msg "Creating Moonraker backup ..."
check_for_backup_dir
get_date
status_msg "Timestamp: $current_date"
mkdir -p $BACKUP_DIR/moonraker-backups/"$current_date"
cp -r $MOONRAKER_DIR $_ && cp -r $MOONRAKER_ENV $_ && ok_msg "Backup complete!"
else
ERROR_MSG=" Can't backup moonraker and/or moonraker-env directory! Not found!"
fi
}
backup_octoprint(){
if [ -d $OCTOPRINT_DIR ] && [ -d $OCTOPRINT_CFG_DIR ]; then
status_msg "Creating OctoPrint backup ..."
check_for_backup_dir
get_date
status_msg "Timestamp: $current_date"
mkdir -p $BACKUP_DIR/octoprint-backups/"$current_date"
cp -r $OCTOPRINT_DIR $_ && cp -r $OCTOPRINT_CFG_DIR $_
ok_msg "Backup complete!"
else
ERROR_MSG=" Can't backup OctoPrint and/or .octoprint directory!\n Not found!"
fi
}
backup_klipperscreen(){
if [ -d $KLIPPERSCREEN_DIR ] ; then
status_msg "Creating KlipperScreen backup ..."
check_for_backup_dir
get_date
status_msg "Timestamp: $current_date"
mkdir -p $BACKUP_DIR/klipperscreen-backups/"$current_date"
cp -r $KLIPPERSCREEN_DIR $_
ok_msg "Backup complete!"
else
ERROR_MSG=" Can't backup KlipperScreen directory!\n Not found!"
fi
}
backup_MoonrakerTelegramBot(){
if [ -d $MOONRAKER_TELEGRAM_BOT_DIR ] ; then
status_msg "Creating MoonrakerTelegramBot backup ..."
check_for_backup_dir
get_date
status_msg "Timestamp: $current_date"
mkdir -p $BACKUP_DIR/MoonrakerTelegramBot-backups/"$current_date"
cp -r $MOONRAKER_TELEGRAM_BOT_DIR $_
ok_msg "Backup complete!"
else
ERROR_MSG=" Can't backup MoonrakerTelegramBot directory!\n Not found!"
fi
}

View File

@@ -0,0 +1,54 @@
#!/bin/sh
# System startup script for dwc2-for-klipper-socket
### BEGIN INIT INFO
# Provides: dwc2-for-klipper-socket
# Required-Start: $local_fs
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: dwc2-for-klipper-socket daemon
# Description: Starts the dwc2-for-klipper-socket daemon.
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
DESC="dwc2-for-klipper-socket daemon"
NAME="dwc2-for-klipper-socket"
DEFAULTS_FILE=/etc/default/dwc
PIDFILE=/var/run/dwc.pid
. /lib/lsb/init-functions
# Read defaults file
[ -r $DEFAULTS_FILE ] && . $DEFAULTS_FILE
case "$1" in
start) log_daemon_msg "Starting dwc2-for-klipper-socket" $NAME
start-stop-daemon --start --quiet --exec $DWC_EXEC \
--background --pidfile $PIDFILE --make-pidfile \
--chuid $DWC_USER --user $DWC_USER \
-- $DWC_ARGS
log_end_msg $?
;;
stop) log_daemon_msg "Stopping dwc2-for-klipper-socket" $NAME
killproc -p $PIDFILE $DWC_EXEC
RETVAL=$?
[ $RETVAL -eq 0 ] && [ -e "$PIDFILE" ] && rm -f $PIDFILE
log_end_msg $RETVAL
;;
restart) log_daemon_msg "Restarting dwc2-for-klipper-socket" $NAME
$0 stop
$0 start
;;
reload|force-reload)
log_daemon_msg "Reloading configuration not supported" $NAME
log_end_msg 1
;;
status)
status_of_proc -p $PIDFILE $DWC_EXEC $NAME && exit 0 || exit $?
;;
*) log_action_msg "Usage: /etc/init.d/dwc {start|stop|status|restart|reload|force-reload}"
exit 2
;;
esac
exit 0

View File

@@ -0,0 +1,106 @@
#!/bin/bash
# This script installs dwc2-for-klipper-socket on a Raspberry Pi machine running
# Raspbian/Raspberry Pi OS based distributions.
# https://github.com/Stephan3/dwc2-for-klipper-socket.git
PYTHONDIR="${HOME}/dwc-env"
SYSTEMDDIR="/etc/systemd/system"
DWC_USER=${USER}
# Step 1: Verify Klipper has been installed
check_klipper()
{
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "klipper.service")" ]; then
echo "Klipper service found!"
else
echo "Klipper service not found, please install Klipper first"
exit -1
fi
}
# Step 2: Install packages
install_packages()
{
PKGLIST="python3-virtualenv python3-dev python3-tornado"
# Update system package info
report_status "Running apt-get update..."
sudo apt-get update --allow-releaseinfo-change
# Install desired packages
report_status "Installing packages..."
sudo apt-get install --yes ${PKGLIST}
}
# Step 3: Create python virtual environment
create_virtualenv()
{
report_status "Updating python virtual environment..."
# Create virtualenv if it doesn't already exist
[ ! -d ${PYTHONDIR} ] && virtualenv -p /usr/bin/python3 ${PYTHONDIR}
# Install/update dependencies
${PYTHONDIR}/bin/pip install tornado==6.0.4
}
# Step 4: Install startup script
install_script(){
report_status "Installing system start script..."
sudo /bin/sh -c "cat > $SYSTEMDDIR/dwc.service" << EOF
#Systemd service file for DWC
[Unit]
Description=dwc_webif
After=network.target
[Install]
WantedBy=multi-user.target
[Service]
Type=simple
User=$DWC_USER
RemainAfterExit=yes
ExecStart=${PYTHONDIR}/bin/python3 ${SRCDIR}/web_dwc2.py
Restart=always
RestartSec=10
EOF
# Use systemctl to enable the klipper systemd service script
sudo systemctl enable dwc.service
}
# Step 5: Start DWC service
start_software()
{
report_status "Launching dwc2-for-klipper-socket..."
sudo systemctl start dwc
}
# Helper functions
report_status()
{
echo -e "\n\n###### $1"
}
verify_ready()
{
if [ "$EUID" -eq 0 ]; then
echo "This script must not run as root"
exit -1
fi
}
# Force script to exit if an error occurs
set -e
# Find SRCDIR from the pathname of this script
SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )"
# Run installation steps defined above
verify_ready
check_klipper
install_packages
create_virtualenv
install_script
start_software

View File

@@ -0,0 +1,106 @@
#!/bin/bash
# This script installs dwc2-for-klipper-socket on a Raspberry Pi machine running
# Raspbian/Raspberry Pi OS based distributions.
# https://github.com/Stephan3/dwc2-for-klipper-socket.git
PYTHONDIR="${HOME}/dwc-env"
# Step 1: Verify Klipper has been installed
check_klipper()
{
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "klipper.service")" ]; then
echo "Klipper service found!"
else
echo "Klipper service not found, please install Klipper first"
exit -1
fi
}
# Step 2: Install packages
install_packages()
{
PKGLIST="python3-virtualenv python3-dev python3-tornado"
# Update system package info
report_status "Running apt-get update..."
sudo apt-get update --allow-releaseinfo-change
# Install desired packages
report_status "Installing packages..."
sudo apt-get install --yes ${PKGLIST}
}
# Step 3: Create python virtual environment
create_virtualenv()
{
report_status "Updating python virtual environment..."
# Create virtualenv if it doesn't already exist
[ ! -d ${PYTHONDIR} ] && virtualenv -p /usr/bin/python3 ${PYTHONDIR}
# Install/update dependencies
${PYTHONDIR}/bin/pip install tornado==6.0.4
}
# Step 4: Install startup script
install_script(){
report_status "Installing system start script..."
sudo cp "${SRCDIR}/scripts/dwc-start.sh" /etc/init.d/dwc
sudo update-rc.d dwc defaults
}
# Step 5: Install startup script config
install_config(){
DEFAULTS_FILE=/etc/default/dwc
[ -f $DEFAULTS_FILE ] && return
report_status "Installing system start configuration..."
sudo /bin/sh -c "cat > $DEFAULTS_FILE" <<EOF
# Configuration for /etc/init.d/dwc
DWC_USER=$USER
DWC_EXEC=${PYTHONDIR}/bin/python3
DWC_ARGS="${SRCDIR}/web_dwc2.py"
EOF
}
# Step 4: Start server
start_software()
{
report_status "Launching dwc2-for-klipper-socket..."
sudo /etc/init.d/klipper stop
sudo /etc/init.d/dwc restart
sudo /etc/init.d/klipper start
}
# Helper functions
report_status()
{
echo -e "\n\n###### $1"
}
verify_ready()
{
if [ "$EUID" -eq 0 ]; then
echo "This script must not run as root"
exit -1
fi
}
# Force script to exit if an error occurs
set -e
# Find SRCDIR from the pathname of this script
SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )"
# Run installation steps defined above
verify_ready
check_klipper
install_packages
create_virtualenv
install_script
install_config
start_software

View File

@@ -0,0 +1,41 @@
stop_service() {
# Stop DWC Service
echo "#### Stopping DWC Service.."
sudo systemctl stop dwc
sudo systemctl disable dwc
}
remove_service() {
# Remove DWC from Services
echo
echo "#### Removing DWC Service.."
sudo rm -f /etc/systemd/system/dwc.service
sudo systemctl daemon-reload
}
remove_files() {
# Remove virtualenv
if [ -d ~/dwc-env ]; then
echo "Removing virtualenv..."
rm -rf ~/dwc-env
else
echo "No DWC virtualenv found"
fi
# Notify user of method to remove DWC source code
echo
echo "The DWC system files and virtualenv have been removed."
}
verify_ready()
{
if [ "$EUID" -eq 0 ]; then
echo "This script must not run as root"
exit -1
fi
}
verify_ready
stop_service
remove_service
remove_files

View File

@@ -0,0 +1,45 @@
stop_service() {
# Stop DWC Service
echo "#### Stopping DWC Service.."
sudo service dwc stop
}
remove_service() {
# Remove DWC from Startup
echo
echo "#### Removing DWC from Startup.."
sudo update-rc.d -f dwc remove
# Remove DWC from Services
echo
echo "#### Removing DWC Service.."
sudo rm -f /etc/init.d/dwc /etc/default/dwc
}
remove_files() {
# Remove virtualenv
if [ -d ~/dwc-env ]; then
echo "Removing virtualenv..."
rm -rf ~/dwc-env
else
echo "No DWC virtualenv found"
fi
# Notify user of method to remove DWC source code
echo
echo "The DWC system files and virtualenv have been removed."
}
verify_ready()
{
if [ "$EUID" -eq 0 ]; then
echo "This script must not run as root"
exit -1
fi
}
verify_ready
stop_service
remove_service
remove_files

334
scripts/flash_mcu.sh Executable file
View File

@@ -0,0 +1,334 @@
#!/bin/bash
show_flash_method_help(){
top_border
echo -e "| ~~~~~~~~ < ? > Help: Flash MCU < ? > ~~~~~~~~ |"
hr
echo -e "| ${cyan}Regular flashing method:${default} |"
echo -e "| The default method to flash controller boards which |"
echo -e "| are connected and updated over USB and not by placing |"
echo -e "| a compiled firmware file onto an internal SD-Card. |"
blank_line
echo -e "| Common controllers that get flashed that way are: |"
echo -e "| - Arduino Mega 2560 |"
echo -e "| - Fysetc F6 / S6 (used without a Display + SD-Slot) |"
blank_line
echo -e "| ${cyan}Updating via SD-Card Update:${default} |"
echo -e "| Many popular controller boards ship with a bootloader |"
echo -e "| capable of updating the firmware via SD-Card. |"
echo -e "| Choose this method if your controller board supports |"
echo -e "| this way of updating. This method ONLY works for up- |"
echo -e "| grading firmware. The initial flashing procedure must |"
echo -e "| be done manually per the instructions that apply to |"
echo -e "| your controller board. |"
blank_line
echo -e "| Common controllers that can be flashed that way are: |"
echo -e "| - BigTreeTech SKR 1.3 / 1.4 (Turbo) / E3 / Mini E3 |"
echo -e "| - Fysetc F6 / S6 (used with a Display + SD-Slot) |"
echo -e "| - Fysetc Spider |"
blank_line
back_footer
while true; do
read -p "${cyan}###### Please select:${default} " choice
case "$choice" in
B|b)
clear && print_header
select_flash_method
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
}
select_flash_method(){
top_border
echo -e "| ~~~~~~~~~~~~ [ Flash MCU ] ~~~~~~~~~~~~ |"
hr
echo -e "| Please select the flashing method to flash your MCU. |"
echo -e "| Make sure to only select a method your MCU supports. |"
echo -e "| Not all MCUs support both methods! |"
hr
blank_line
echo -e "| 1) Regular flashing method |"
echo -e "| 2) Updating via SD-Card Update |"
blank_line
back_help_footer
while true; do
read -p "${cyan}###### Please select:${default} " choice
case "$choice" in
1)
echo -e "###### > Regular flashing method"
select_mcu_connection
select_mcu_id
[[ "$CONFIRM_FLASH" == true ]] && flash_mcu
break;;
2)
echo -e "###### > SD-Card Update"
select_mcu_connection
select_mcu_id
[[ "$CONFIRM_FLASH" == true ]] && flash_mcu_sd
break;;
B|b)
advanced_menu
break;;
H|h)
clear && print_header
show_flash_method_help
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
}
select_mcu_id(){
if [ ${#mcu_list[@]} -ge 1 ]; then
top_border
echo -e "| ${red}!!! ATTENTION !!!${default} |"
hr
echo -e "| Make sure, to select the correct MCU! |"
echo -e "| ${red}ONLY flash a firmware created for the respective MCU!${default} |"
bottom_border
echo -e "${cyan}###### List of available MCU:${default}"
### list all mcus
id=0
for mcu in ${mcu_list[@]}; do
let id++
echo -e " $id) $mcu"
done
### verify user input
sel_index=""
while [[ ! ($sel_index =~ ^[1-9]+$) ]] || [ "$sel_index" -gt "$id" ]; do
echo
read -p "${cyan}###### Select MCU to flash:${default} " sel_index
if [[ ! ($sel_index =~ ^[1-9]+$) ]]; then
warn_msg "Invalid input!"
elif [ "$sel_index" -lt 1 ] || [ "$sel_index" -gt "$id" ]; then
warn_msg "Please select a number between 1 and $id!"
fi
mcu_index=$(echo $((sel_index - 1)))
selected_mcu_id="${mcu_list[$mcu_index]}"
done
### confirm selection
while true; do
echo -e "\n###### You selected:\n ● MCU #$sel_index: $selected_mcu_id\n"
read -p "${cyan}###### Continue? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
echo -e "###### > Yes"
status_msg "Flashing $selected_mcu_id ..."
CONFIRM_FLASH=true
break;;
N|n|No|no)
echo -e "###### > No"
CONFIRM_FLASH=false
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
fi
}
flash_mcu(){
do_action_service "stop" "klipper"
make flash FLASH_DEVICE="${mcu_list[$mcu_index]}"
### evaluate exit code of make flash
if [ ! $? -eq 0 ]; then
warn_msg "Flashing failed!"
warn_msg "Please read the console output above!"
else
ok_msg "Flashing successfull!"
fi
do_action_service "start" "klipper"
}
flash_mcu_sd(){
flash_script="${HOME}/klipper/scripts/flash-sdcard.sh"
### write each supported board to the array to make it selectable
board_list=()
for board in $("$flash_script" -l | tail -n +2); do
board_list+=($board)
done
i=0
top_border
echo -e "| Please select the type of board that corresponds to |"
echo -e "| the currently selected MCU ID you chose before. |"
blank_line
echo -e "| The following boards are currently supported: |"
hr
### display all supported boards to the user
for board in ${board_list[@]}; do
if [ $i -lt 10 ]; then
printf "| $i) %-50s|\n" "${board_list[$i]}"
else
printf "| $i) %-49s|\n" "${board_list[$i]}"
fi
i=$((i + 1))
done
quit_footer
### make the user select one of the boards
while true; do
read -p "${cyan}###### Please select board type:${default} " choice
if [ "$choice" = "q" ] || [ "$choice" = "Q" ]; then
clear && advanced_menu && break
elif [ "$choice" -le ${#board_list[@]} ]; then
selected_board="${board_list[$choice]}"
break
else
clear && print_header
ERROR_MSG="Invalid choice!" && print_msg && clear_msg
flash_mcu_sd
fi
done
while true; do
top_border
echo -e "| If your board is flashed with firmware that connects |"
echo -e "| at a custom baud rate, please change it now. |"
blank_line
echo -e "| If you are unsure, stick to the default 250000! |"
bottom_border
echo -e "${cyan}###### Please set the baud rate:${default} "
unset baud_rate
while [[ ! $baud_rate =~ ^[0-9]+$ ]]; do
read -e -i "250000" -e baud_rate
selected_baud_rate=$baud_rate
break
done
break
done
###flash process
do_action_service "stop" "klipper"
"$flash_script" -b "$selected_baud_rate" "$selected_mcu_id" "$selected_board"
### evaluate exit code of flash-sdcard.sh execution
if [ ! $? -eq 0 ]; then
warn_msg "Flashing failed!"
warn_msg "Please read the console output above!"
else
ok_msg "Flashing successfull!"
fi
do_action_service "start" "klipper"
}
build_fw(){
if [ -d "$KLIPPER_DIR" ]; then
cd "$KLIPPER_DIR"
status_msg "Initializing firmware build ..."
dep=(build-essential dpkg-dev make)
dependency_check
make clean && make menuconfig
status_msg "Building firmware ..."
make && ok_msg "Firmware built!"
else
ERROR_MSG="Klipper was not found!\n Can not build firmware without Klipper!"
print_msg && clear_msg && return 1
fi
}
select_mcu_connection(){
echo
top_border
echo -e "| ${yellow}Make sure to have the controller board connected now!${default} |"
blank_line
echo -e "| How is the controller board connected to the host? |"
echo -e "| 1) USB |"
echo -e "| 2) UART |"
bottom_border
while true; do
read -p "${cyan}###### Connection method:${default} " choice
case "$choice" in
1)
retrieve_id "USB"
break;;
2)
retrieve_id "UART"
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
unset mcu_count
if [[ "${#mcu_list[@]}" -lt 1 ]]; then
warn_msg "No MCU found!"
warn_msg "MCU not plugged in or not detectable!"
echo
fi
}
retrieve_id(){
status_msg "Identifying MCU ..."
sleep 1
mcu_list=()
mcu_count=1
[ "$1" = "USB" ] && path="/dev/serial/by-id/*"
[ "$1" = "UART" ] && path="/dev/ttyAMA0"
if [[ "$(ls $path)" != "" ]] ; then
for mcu in $path; do
declare "mcu_id_$mcu_count"="$mcu"
mcu_id="mcu_id_$mcu_count"
mcu_list+=("${!mcu_id}")
echo -e " ● ($1) MCU #$mcu_count: ${cyan}$mcu${default}\n"
let mcu_count++
done
fi 2>/dev/null
}
check_usergroup_dialout(){
if grep -q "dialout" </etc/group && ! grep -q "dialout" <(groups "${USER}"); then
group_dialout=false
else
group_dialout=true
fi
if grep -q "tty" </etc/group && ! grep -q "tty" <(groups "${USER}"); then
group_tty=false
else
group_tty=true
fi
if [ "$group_dialout" == "false" ] || [ "$group_tty" == "false" ] ; then
top_border
echo -e "| ${yellow}WARNING: Your current user is not in group:${default} |"
[ "$group_tty" == "false" ] && echo -e "| ${yellow}● tty${default} |"
[ "$group_dialout" == "false" ] && echo -e "| ${yellow}● dialout${default} |"
blank_line
echo -e "| It is possible that you won't be able to successfully |"
echo -e "| flash without your user being a member of that group. |"
echo -e "| If you want to add the current user to the group(s) |"
echo -e "| listed above, answer with 'Y'. Else skip with 'n'. |"
blank_line
echo -e "| ${yellow}INFO:${default} |"
echo -e "| ${yellow}Relog required for group assignments to take effect!${default} |"
bottom_border
while true; do
read -p "${cyan}###### Add user '${USER}' to group(s) now? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
echo -e "###### > Yes"
status_msg "Adding user '${USER}' to group(s) ..."
if [ "$group_tty" == "false" ]; then
sudo usermod -a -G tty "${USER}" && ok_msg "Group 'tty' assigned!"
fi
if [ "$group_dialout" == "false" ]; then
sudo usermod -a -G dialout "${USER}" && ok_msg "Group 'dialout' assigned!"
fi
ok_msg "You need to relog/restart for the group(s) to be applied!" && exit 0;;
N|n|No|no)
echo -e "###### > No"
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
fi
}

512
scripts/functions.sh Normal file → Executable file
View File

@@ -1,66 +1,261 @@
### base variables
SYSTEMDDIR="/etc/systemd/system"
# setting up some frequently used functions
check_euid(){
if [ "$EUID" -eq 0 ]
then
echo -e "${red}"
echo -e "/=================================================\ "
echo -e "| !!! THIS SCRIPT MUST NOT RAN AS ROOT !!! |"
echo -e "\=================================================/ "
top_border
echo -e "| !!! THIS SCRIPT MUST NOT RAN AS ROOT !!! |"
bottom_border
echo -e "${default}"
exit 1
fi
}
source_ini(){
source ${HOME}/kiauh2/kiauh.ini
}
start_klipper(){
if [ -e /etc/init.d/klipper ]; then
status_msg "Starting klipper service ..."
sudo /etc/init.d/klipper start && sleep 2 && ok_msg "Klipper service started!"
fi
}
stop_klipper(){
if [ -e /etc/init.d/klipper ]; then
status_msg "Stopping klipper service ..."
sudo /etc/init.d/klipper stop && sleep 2 && ok_msg "Klipper service stopped!"
check_klipper_cfg_path(){
source_kiauh_ini
if [ -z $klipper_cfg_loc ]; then
echo
top_border
echo -e "| ${red}!!! WARNING !!!${default} |"
echo -e "| ${red}No Klipper configuration directory set!${default} |"
hr
echo -e "| Before we can continue, KIAUH needs to know where |"
echo -e "| you want your printer configuration to be. |"
blank_line
echo -e "| Please specify a folder where your Klipper configu- |"
echo -e "| ration is stored or, if you don't have one yet, in |"
echo -e "| which it should be saved after the installation. |"
bottom_border
change_klipper_cfg_path
fi
}
start_moonraker(){
if [ -e /etc/init.d/moonraker ]; then
status_msg "Starting moonraker service ..."
sudo /etc/init.d/moonraker start && sleep 2 && ok_msg "Moonraker service started!"
fi
}
stop_moonraker(){
if [ -e /etc/init.d/moonraker ]; then
status_msg "Stopping moonraker service ..."
sudo /etc/init.d/moonraker stop && sleep 2 && ok_msg "Moonraker service stopped!"
fi
}
dep_check(){
for package in "${dep[@]}"
do
! command -v $package >&/dev/null 2>&1 && install+=($package)
done
if ! [ ${#install[@]} -eq 0 ]; then
warn_msg "The following packages are missing but necessary:"
echo ${install[@]}
change_klipper_cfg_path(){
source_kiauh_ini
old_klipper_cfg_loc="$klipper_cfg_loc"
EXAMPLE_FOLDER=$(printf "%s/your_config_folder" "${HOME}")
while true; do
read -p "Do you want to install them now? (Y/n): " yn
top_border
echo -e "| ${red}IMPORTANT:${default} |"
echo -e "| Please enter the new path in the following format: |"
printf "| ${yellow}%-51s${default} |\n" "$EXAMPLE_FOLDER"
blank_line
echo -e "| By default 'klipper_config' is recommended! |"
bottom_border
echo
echo -e "${cyan}###### Please set the Klipper config directory:${default} "
if [ -z "$old_klipper_cfg_loc" ]; then
read -e -i "/home/${USER}/klipper_config" -e new_klipper_cfg_loc
else
read -e -i "$old_klipper_cfg_loc" -e new_klipper_cfg_loc
fi
echo
read -p "${cyan}###### Set config directory to '${yellow}$new_klipper_cfg_loc${cyan}' ? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
status_msg "Installing dependencies ..."
sudo apt-get install ${install[@]} -y && ok_msg "Dependencies installed!"
break;;
N|n|No|no) break;;
*) echo "Unknown parameter: $yn"; echo;;
echo -e "###### > Yes"
### backup the old config dir
backup_klipper_config_dir
### write new location to kiauh.ini
sed -i "s|klipper_cfg_loc=$old_klipper_cfg_loc|klipper_cfg_loc=$new_klipper_cfg_loc|" $INI_FILE
status_msg "Directory set to '$new_klipper_cfg_loc'!"
### write new location to klipper and moonraker service
set_klipper_cfg_path
echo; ok_msg "Config directory changed!"
break;;
N|n|No|no)
echo -e "###### > No"
change_klipper_cfg_path
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
}
set_klipper_cfg_path(){
### stop services
do_action_service "stop" "klipper"
do_action_service "stop" "moonraker"
### copy config files to new klipper config folder
if [ ! -z "$old_klipper_cfg_loc" ] && [ -d "$old_klipper_cfg_loc" ]; then
if [ ! -d "$new_klipper_cfg_loc" ]; then
status_msg "Copy config files to '$new_klipper_cfg_loc' ..."
mkdir -p "$new_klipper_cfg_loc"
cd $old_klipper_cfg_loc
cp -r -v ./* "$new_klipper_cfg_loc"
ok_msg "Done!"
fi
fi
SERVICE_FILES=$(find "$SYSTEMDDIR" -regextype posix-extended -regex "$SYSTEMDDIR/klipper(-[^0])+[0-9]*.service")
### handle single klipper instance service file
if [ -f $SYSTEMDDIR/klipper.service ]; then
status_msg "Configuring Klipper for new path ..."
sudo sed -i -r "/ExecStart=/ s|klippy.py (.+)\/printer.cfg|klippy.py $new_klipper_cfg_loc/printer.cfg|" $SYSTEMDDIR/klipper.service
ok_msg "OK!"
elif [ -n "$SERVICE_FILES" ]; then
### handle multi klipper instance service file
status_msg "Configuring Klipper for new path ..."
for service in $SERVICE_FILES; do
sudo sed -i -r "/ExecStart=/ s|klippy.py (.+)\/printer_|klippy.py $new_klipper_cfg_loc/printer_|" "$service"
done
ok_msg "OK!"
fi
SERVICE_FILES=$(find "$SYSTEMDDIR" -regextype posix-extended -regex "$SYSTEMDDIR/moonraker(-[^0])+[0-9]*.service")
### handle single moonraker instance service and moonraker.conf file
if [ -f $SYSTEMDDIR/moonraker.service ]; then
status_msg "Configuring Moonraker for new path ..."
sudo sed -i -r "/ExecStart=/ s|-c (.+)\/moonraker\.conf|-c $new_klipper_cfg_loc/moonraker.conf|" $SYSTEMDDIR/moonraker.service
### replace old file path with new one in moonraker.conf
sed -i -r "/config_path:/ s|config_path:.*|config_path: $new_klipper_cfg_loc|" $new_klipper_cfg_loc/moonraker.conf
ok_msg "OK!"
elif [ -n "$SERVICE_FILES" ]; then
### handle multi moonraker instance service file
status_msg "Configuring Moonraker for new path ..."
for service in $SERVICE_FILES; do
sudo sed -i -r "/ExecStart=/ s|-c (.+)\/printer_|-c $new_klipper_cfg_loc/printer_|" "$service"
done
MR_CONFS=$(find "$new_klipper_cfg_loc" -regextype posix-extended -regex "$new_klipper_cfg_loc/printer_[1-9]+/moonraker.conf")
### replace old file path with new one in moonraker.conf
for moonraker_conf in $MR_CONFS; do
loc=$(echo "$moonraker_conf" | rev | cut -d"/" -f2- | rev)
sed -i -r "/config_path:/ s|config_path:.*|config_path: $loc|" "$moonraker_conf"
done
ok_msg "OK!"
fi
### reloading units
sudo systemctl daemon-reload
### restart services
do_action_service "restart" "klipper"
do_action_service "restart" "moonraker"
}
source_kiauh_ini(){
source $INI_FILE
}
do_action_service(){
shopt -s extglob # enable extended globbing
SERVICES="$SYSTEMDDIR/$2?(-*([0-9])).service"
### set a variable for the ok and status messages
[ "$1" == "start" ] && ACTION1="started" && ACTION2="Starting"
[ "$1" == "stop" ] && ACTION1="stopped" && ACTION2="Stopping"
[ "$1" == "restart" ] && ACTION1="restarted" && ACTION2="Restarting"
[ "$1" == "enable" ] && ACTION1="enabled" && ACTION2="Enabling"
[ "$1" == "disable" ] && ACTION1="disabled" && ACTION2="Disabling"
if ls $SERVICES 2>/dev/null 1>&2; then
for service in $(ls $SERVICES | rev | cut -d"/" -f1 | rev); do
status_msg "$ACTION2 $service ..."
sudo systemctl $1 "$service"
ok_msg "$service $ACTION1!"
done
fi
shopt -u extglob # disable extended globbing
}
toggle_octoprint_service(){
if systemctl list-unit-files | grep -E "octoprint.*" | grep "enabled" &>/dev/null; then
do_action_service "stop" "octoprint"
do_action_service "disable" "octoprint"
sleep 2
CONFIRM_MSG=" OctoPrint Service is now >>> DISABLED <<< !"
elif systemctl list-unit-files | grep -E "octoprint.*" | grep "disabled" &>/dev/null; then
do_action_service "enable" "octoprint"
do_action_service "start" "octoprint"
sleep 2
CONFIRM_MSG=" OctoPrint Service is now >>> ENABLED <<< !"
else
ERROR_MSG=" You cannot activate a service that does not exist!"
fi
}
read_octoprint_service_status(){
unset OPRINT_SERVICE_STATUS
if [ ! -f "/etc/systemd/system/octoprint.service" ]; then
return 0
fi
if systemctl list-unit-files | grep -E "octoprint*" | grep "enabled" &>/dev/null; then
OPRINT_SERVICE_STATUS="${red}[Disable]${default} OctoPrint Service "
else
OPRINT_SERVICE_STATUS="${green}[Enable]${default} OctoPrint Service "
fi
}
start_klipperscreen(){
status_msg "Starting KlipperScreen Service ..."
sudo systemctl start KlipperScreen && ok_msg "KlipperScreen Service started!"
}
stop_klipperscreen(){
status_msg "Stopping KlipperScreen Service ..."
sudo systemctl stop KlipperScreen && ok_msg "KlipperScreen Service stopped!"
}
restart_klipperscreen(){
status_msg "Restarting KlipperScreen Service ..."
sudo systemctl restart KlipperScreen && ok_msg "KlipperScreen Service restarted!"
}
start_MoonrakerTelegramBot(){
status_msg "Starting MoonrakerTelegramBot Service ..."
sudo systemctl start moonraker-telegram-bot && ok_msg "MoonrakerTelegramBot Service started!"
}
stop_MoonrakerTelegramBot(){
status_msg "Stopping MoonrakerTelegramBot Service ..."
sudo systemctl stop moonraker-telegram-bot && ok_msg "MoonrakerTelegramBot Service stopped!"
}
restart_MoonrakerTelegramBot(){
status_msg "Restarting MoonrakerTelegramBot Service ..."
sudo systemctl restart moonraker-telegram-bot && ok_msg "MoonrakerTelegramBot Service restarted!"
}
restart_nginx(){
if ls /lib/systemd/system/nginx.service 2>/dev/null 1>&2; then
status_msg "Restarting NGINX Service ..."
sudo systemctl restart nginx && ok_msg "NGINX Service restarted!"
fi
}
dependency_check(){
status_msg "Checking for the following dependencies:"
#check if package is installed, if not write name into array
for pkg in "${dep[@]}"
do
echo -e "${cyan}$pkg ${default}"
if [[ ! $(dpkg-query -f'${Status}' --show $pkg 2>/dev/null) = *\ installed ]]; then
inst+=($pkg)
fi
done
#if array is not empty, install packages from array elements
if [ "${#inst[@]}" != "0" ]; then
status_msg "Installing the following dependencies:"
for element in ${inst[@]}
do
echo -e "${cyan}$element ${default}"
done
echo
sudo apt-get update --allow-releaseinfo-change && sudo apt-get install ${inst[@]} -y
ok_msg "Dependencies installed!"
#clearing the array
unset inst
else
ok_msg "Dependencies already met! Continue..."
fi
}
@@ -75,111 +270,150 @@ print_error(){
done
sum=$(IFS=+; echo "$((${data_count[*]}))")
if [ $sum -eq 0 ]; then
ERROR_MSG=" Looks like $1 was already removed!\n Skipping..."
ERROR_MSG="Looks like $1 was already removed!\n Skipping..."
else
ERROR_MSG=""
fi
}
pkg_check(){
status_msg "Checking if nginx is installed"
if [[ $(dpkg-query -f'${Status}' --show nginx 2>/dev/null) = *\ installed ]]; then
echo "nginx found!"
else
echo "nginx was not found, installing..." 2>&1
sudo apt-get -y install nginx 2>/dev/null
fi
}
build_fw(){
if [ -d $KLIPPER_DIR ]; then
cd $KLIPPER_DIR && make menuconfig
status_msg "Building firmware ..."
make clean && make && ok_msg "Firmware built!"
else
warn_msg "Can not build firmware without a Klipper directory!"
fi
}
### grab the printers id
get_usb_id(){
warn_msg "Make sure your printer is the only USB device connected!"
while true; do
echo -e "${cyan}"
read -p "###### Press any key to continue ... " yn
echo -e "${default}"
case "$yn" in
*) break;;
esac
done
status_msg "Identifying the correct USB port ..."
USB_ID=$(ls /dev/serial/by-id/*)
if [ -e /dev/serial/by-id/* ]; then
status_msg "The ID of your printer is:"
title_msg "$USB_ID"
else
warn_msg "Could not retrieve ID!"
return 1
fi
}
write_printer_id(){
while true; do
echo -e "${cyan}"
read -p "###### Do you want to write the ID to your printer.cfg? (Y/n): " yn
echo -e "${default}"
case "$yn" in
Y|y|Yes|yes|"")
backup_printer_cfg
cat <<PRINTERID >> $PRINTER_CFG
##########################
### CREATED WITH KIAUH ###
##########################
[mcu]
serial: $USB_ID
##########################
##########################
PRINTERID
ok_msg "Config written!"
break;;
N|n|No|no) break;;
esac
done
}
flash_routine(){
echo -e "/=================================================\ "
echo -e "| ATTENTION! |"
echo -e "| Flashing a Smoothie based board for the first |"
echo -e "| time with this script will certainly fail. |"
echo -e "| This applies to boards like the BTT SKR V1.3 or |"
echo -e "| the newer SKR V1.4 (Turbo). You have to copy |"
echo -e "| the firmware file to the microSD card manually |"
echo -e "| and rename it to 'firmware.bin'. |"
echo -e "| |"
echo -e "| You find the file in: ~/klipper/out/klipper.bin |"
echo -e "\=================================================/ "
setup_gcode_shell_command(){
echo
top_border
echo -e "| You are about to install the G-Code Shell Command |"
echo -e "| extension. Please make sure to read the instructions |"
echo -e "| before you continue and remember that potential risks |"
echo -e "| can be involved after installing this extension! |"
blank_line
echo -e "| ${red}You accept that you are doing this on your own risk!${default} |"
bottom_border
while true; do
echo -e "${cyan}"
read -p "###### Do you want to continue? (Y/n): " yn
echo -e "${default}"
read -p "${cyan}###### Do you want to continue? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
get_usb_id && flash_mcu && write_printer_id; break;;
N|n|No|no) break;;
if [ -d $KLIPPER_DIR/klippy/extras ]; then
status_msg "Installing gcode shell command extension ..."
if [ -f $KLIPPER_DIR/klippy/extras/gcode_shell_command.py ]; then
warn_msg "There is already a file named 'gcode_shell_command.py'\nin the destination location!"
while true; do
read -p "${cyan}###### Do you want to overwrite it? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
rm -f $KLIPPER_DIR/klippy/extras/gcode_shell_command.py
install_gcode_shell_command
break;;
N|n|No|no)
break;;
esac
done
else
install_gcode_shell_command
fi
else
ERROR_MSG="Folder ~/klipper/klippy/extras not found!"
fi
break;;
N|n|No|no)
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
}
flash_mcu(){
stop_klipper
if ! make flash FLASH_DEVICE="$USB_ID" ; then
warn_msg "Flashing failed!"
warn_msg "Please read the log above!"
else
ok_msg "Flashing successfull!"
install_gcode_shell_command(){
do_action_service "stop" "klipper"
status_msg "Copy 'gcode_shell_command.py' to '$KLIPPER_DIR/klippy/extras' ..."
cp ${SRCDIR}/kiauh/resources/gcode_shell_command.py $KLIPPER_DIR/klippy/extras
while true; do
echo
read -p "${cyan}###### Do you want to create the example shell command? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
status_msg "Copy shell_command.cfg ..."
### create a backup of the config folder
backup_klipper_config_dir
### handle single printer.cfg
if [ -f $klipper_cfg_loc/printer.cfg ] && [ ! -f $klipper_cfg_loc/shell_command.cfg ]; then
### copy shell_command.cfg to config location
cp ${SRCDIR}/kiauh/resources/shell_command.cfg $klipper_cfg_loc
ok_msg "$klipper_cfg_loc/shell_command.cfg created!"
### write the include to the very first line of the printer.cfg
sed -i "1 i [include shell_command.cfg]" $klipper_cfg_loc/printer.cfg
fi
### handle multi printer.cfg
if ls $klipper_cfg_loc/printer_* 2>/dev/null 1>&2; then
for config in $(find $klipper_cfg_loc/printer_*/printer.cfg); do
path=$(echo $config | rev | cut -d"/" -f2- | rev)
if [ ! -f $path/shell_command.cfg ]; then
### copy shell_command.cfg to config location
cp ${SRCDIR}/kiauh/resources/shell_command.cfg $path
ok_msg "$path/shell_command.cfg created!"
### write the include to the very first line of the printer.cfg
sed -i "1 i [include shell_command.cfg]" $path/printer.cfg
fi
done
fi
break;;
N|n|No|no)
break;;
esac
done
ok_msg "Shell command extension installed!"
do_action_service "restart" "klipper"
}
create_minimal_cfg(){
#create a minimal default config
if [ "$SEL_DEF_CFG" = "true" ]; then
cat <<- EOF >> $PRINTER_CFG
[mcu]
serial: </dev/serial/by-id/your-mcu>
[printer]
kinematics: none
max_velocity: 1
max_accel: 1
[virtual_sdcard]
path: ~/sdcard
[pause_resume]
[display_status]
EOF
fi
start_klipper
}
}
init_ini(){
### copy an existing kiauh.ini to its new location to keep all possible saved values
if [ -f ${SRCDIR}/kiauh/kiauh.ini ] && [ ! -f $INI_FILE ]; then
cp ${SRCDIR}/kiauh/kiauh.ini $INI_FILE
fi
if [ ! -f $INI_FILE ]; then
echo -e "#don't edit this file if you don't know what you are doing...\c" > $INI_FILE
fi
if [ ! $(grep -E "^backup_before_update=." $INI_FILE) ]; then
echo -e "\nbackup_before_update=false\c" >> $INI_FILE
fi
if [ ! $(grep -E "^previous_origin_state=[[:alnum:]]" $INI_FILE) ]; then
echo -e "\nprevious_origin_state=0\c" >> $INI_FILE
fi
if [ ! $(grep -E "^previous_smoothing_state=[[:alnum:]]" $INI_FILE) ]; then
echo -e "\nprevious_smoothing_state=0\c" >> $INI_FILE
fi
if [ ! $(grep -E "^previous_shaping_state=[[:alnum:]]" $INI_FILE) ]; then
echo -e "\nprevious_shaping_state=0\c" >> $INI_FILE
fi
if [ ! $(grep -E "^logupload_accepted=." $INI_FILE) ]; then
echo -e "\nlogupload_accepted=false\c" >> $INI_FILE
fi
###add empty klipper config path if missing
if [ ! $(grep -E "^klipper_cfg_loc=" $INI_FILE) ]; then
echo -e "\nklipper_cfg_loc=\c" >> $INI_FILE
fi
fetch_webui_ports
}

538
scripts/install_dwc2.sh Normal file → Executable file
View File

@@ -1,166 +1,390 @@
#TODO:
# - check for existing/running octoprint service
# - ask for permission to disable octoprint service
### base variables
SYSTEMDDIR="/etc/systemd/system"
DWC_ENV="${HOME}/dwc-env"
DWC2_DIR="${HOME}/duetwebcontrol"
dwc2_install_routine(){
if [ -d $KLIPPER_DIR ]; then
# check for existing installation
if [ -d ${HOME}/klippy-env/lib/python2.7/site-packages/tornado ]; then
ERROR_MSG=" Looks like DWC2 is already installed!\n Skipping..."
return
fi
stop_klipper
install_tornado
install_dwc2fk && dwc2fk_cfg
install_dwc2
start_klipper
system_check_dwc(){
### check system for an installed octoprint service
if systemctl is-enabled octoprint.service -q 2>/dev/null; then
OCTOPRINT_ENABLED="true"
fi
}
dwc_setup_dialog(){
status_msg "Initializing Duet Web Control installation ..."
### check system for several requirements before initializing the dwc2 installation
system_check_dwc
### check for existing klipper service installations
if [ ! "$(systemctl list-units --full -all -t service --no-legend | grep -F "klipper.service")" ] && [ ! "$(systemctl list-units --full -all -t service --no-legend | grep -E "klipper-[[:digit:]].service")" ]; then
ERROR_MSG="Klipper service not found, please install Klipper first!" && return 0
fi
### count amount of klipper services
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "klipper.service")" ]; then
INSTANCE_COUNT=1
else
ERROR_MSG=" Please install Klipper first!\n Skipping..."
INSTANCE_COUNT=$(systemctl list-units --full -all -t service --no-legend | grep -E "klipper-[[:digit:]].service" | wc -l)
fi
### initial config path check
check_klipper_cfg_path
### ask user how to handle OctoPrint, Haproxy and Lighttpd
process_octoprint_dialog_dwc2
process_services_dialog
### instance confirmation dialog
while true; do
echo
top_border
if [ "$INSTANCE_COUNT" -gt 1 ]; then
printf "|%-55s|\n" " $INSTANCE_COUNT Klipper instances were found!"
else
echo -e "| 1 Klipper instance was found! | "
fi
echo -e "| You need one DWC instance per Klipper instance. | "
bottom_border
echo
read -p "${cyan}###### Create $INSTANCE_COUNT DWC instances? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
echo -e "###### > Yes"
status_msg "Creating $INSTANCE_COUNT DWC instances ..."
dwc_setup
break;;
N|n|No|no)
echo -e "###### > No"
warn_msg "Exiting DWC setup ..."
echo
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
}
###TODO for future: should be some kind of shared function between moonraker and this installer, since it does the same
process_octoprint_dialog_dwc2(){
### ask user to disable octoprint when its service was found
if [ "$OCTOPRINT_ENABLED" = "true" ]; then
while true; do
echo
top_border
echo -e "| ${red}!!! WARNING - OctoPrint service found !!!${default} |"
hr
echo -e "| You might consider disabling the OctoPrint service, |"
echo -e "| since an active OctoPrint service may lead to unex- |"
echo -e "| pected behavior of Duet Web Control for Klipper. |"
bottom_border
read -p "${cyan}###### Do you want to disable OctoPrint now? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
echo -e "###### > Yes"
status_msg "Stopping OctoPrint ..."
sudo systemctl stop octoprint && ok_msg "OctoPrint service stopped!"
status_msg "Disabling OctoPrint ..."
sudo systemctl disable octoprint && ok_msg "OctoPrint service disabled!"
break;;
N|n|No|no)
echo -e "###### > No"
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
fi
status_msg "Installation will start now! Please wait ..."
}
#############################################################
#############################################################
get_dwc_ver(){
DWC2_VERSION=$(curl -s https://api.github.com/repositories/28820678/releases/latest | grep tag_name | cut -d'"' -f4)
}
dwc_setup(){
### get printer config directory
source_kiauh_ini
DWC_CONF_LOC="$klipper_cfg_loc"
### check dependencies
dep=(git wget gzip tar curl)
dependency_check
### step 1: get dwc2-for-klipper
status_msg "Downloading DWC2-for-Klipper-Socket ..."
cd "${HOME}" && git clone "$DWC2FK_REPO"
ok_msg "Download complete!"
### step 2: install dwc2 dependencies and create python virtualenv
status_msg "Installing dependencies ..."
install_dwc_packages
create_dwc_virtualenv
### step 3: create dwc2.cfg folder and dwc2.cfg
[ ! -d "$DWC_CONF_LOC" ] && mkdir -p "$DWC_CONF_LOC"
dwc_cfg_creation
### step 4: download Duet Web Control
download_dwc_webui
### step 5: create dwc instances
INSTANCE=1
if [ "$INSTANCE_COUNT" -eq $INSTANCE ]; then
create_single_dwc_instance
else
#create_multi_dwc_instance
create_multi_dwc_instance
fi
}
install_tornado(){
#check for dependencies
dep=(virtualenv)
dep_check
#execute operation
status_msg "Installing Tornado 5.1.1 ..."
cd ${HOME}
PYTHONDIR="${HOME}/klippy-env"
virtualenv ${PYTHONDIR}
${PYTHONDIR}/bin/pip install tornado==5.1.1 && ok_msg "Tornado 5.1.1 successfully installed!"
}
install_dwc2fk(){
cd ${HOME}
status_msg "Cloning dwc2-for-klipper repository ..."
git clone $DWC2FK_REPO && ok_msg "dwc2-for-klipper successfully cloned!"
#create a web_dwc2.py symlink if not already existing
if [ -d $KLIPPER_DIR/klippy/extras ] && [ ! -e $KLIPPER_DIR/klippy/extras/web_dwc2.py ]; then
status_msg "Creating web_dwc2.py symlink ..."
ln -s $DWC2FK_DIR/web_dwc2.py $KLIPPER_DIR/klippy/extras/web_dwc2.py && ok_msg "Symlink created!"
fi
}
dwc2fk_cfg(){
while true; do
echo -e "${cyan}"
read -p "###### Do you want to create the config now? (Y/n): " yn
echo -e "${default}"
case "$yn" in
Y|y|Yes|yes|"") create_dwc2fk_cfg; break;;
N|n|No|no) break;;
*) echo "Unknown parameter: $yn"; dwc2fk_cfg;;
esac
done
}
create_dwc2fk_cfg(){
echo -e "/=================================================\ "
echo -e "| 1) [Default configuration] | "
echo -e "| 2) [Custom configuration] | "
echo -e "| 3) [Skip] | "
echo -e "\=================================================/ "
while true; do
read -p "Please select: " choice; echo
case "$choice" in
1) dwc2fk_default_cfg && ok_msg "Config written ..."; break;;
2) create_dwc2fk_custom_cfg && ok_msg "Config written ..."; break;;
3) echo "Skipping ..."; break;;
esac
done
}
dwc2fk_default_cfg(){
cat <<DWC2 >> $PRINTER_CFG
##########################
### CREATED WITH KIAUH ###
##########################
[virtual_sdcard]
path: ~/sdcard
[web_dwc2]
printer_name: my_printer
listen_adress: 0.0.0.0
listen_port: 4750
web_path: dwc2/web
##########################
##########################
DWC2
}
create_dwc2fk_custom_cfg(){
echo -e "${cyan}"
read -e -p "Printer name: " -i "my_printer" PRINTER_NAME
read -e -p "Listen adress: " -i "0.0.0.0" LISTEN_ADRESS
read -e -p "Listen port: " -i "4750" LISTEN_PORT
read -e -p "Web path: " -i "dwc2/web" WEB_PATH
echo -e "${default}"
DWC2_CFG=$(cat <<DWC2
##########################
### CREATED WITH KIAUH ###
##########################
[virtual_sdcard]
path: ~/sdcard
[web_dwc2]
printer_name: $PRINTER_NAME
listen_adress: $LISTEN_ADRESS
listen_port: $LISTEN_PORT
web_path: $WEB_PATH
##########################
##########################
DWC2
)
echo "The following lines will be written:"
echo -e "$DWC2_CFG"
while true; do
echo -e "${cyan}"
read -p "###### Write now (Y) or start over (n)? (Y/n): " yn
echo -e "${default}"
case "$yn" in
Y|y|Yes|yes|"") echo -e "$DWC2_CFG" >> $PRINTER_CFG; break;;
N|n|No|no) create_dwc2fk_custom_cfg;;
esac
done
}
install_dwc2(){
#needed packages for webcam
while true; do
echo -e "${cyan}"
read -p "###### Do you want to use a webcam? (Y/n): " yn
echo -e "${default}"
case "$yn" in
Y|y|Yes|yes|"")
status_msg "Checking for dependencies ..."
webcam_dep_check && ok_msg "Dependencies installed!"
break;;
N|n|No|no) break;;
*) echo "Unknown parameter: $yn"; echo;;
esac
done
#the update_dwc2 function does the same as installing dwc2
update_dwc2 && ok_msg "DWC2 Web UI installed!"
}
webcam_dep_check(){
webcam_dep=(
build-essential
libjpeg8-dev
imagemagick
libv4l-dev
cmake
)
for pkg in "${webcam_dep[@]}"
download_dwc_webui(){
#get Duet Web Control
GET_DWC2_URL=$(curl -s https://api.github.com/repositories/28820678/releases/latest | grep browser_download_url | cut -d'"' -f4)
status_msg "Downloading DWC2 Web UI ..."
[ ! -d "$DWC2_DIR" ] && mkdir -p "$DWC2_DIR"
cd "$DWC2_DIR" && wget "$GET_DWC2_URL"
ok_msg "Download complete!"
status_msg "Extracting archive ..."
unzip -q -o *.zip
for f_ in $(find . | grep '.gz')
do
if ! [[ $(dpkg-query -f'${Status}' --show $pkg 2>/dev/null) = *\ installed ]]; then
install+=($pkg)
fi
gunzip -f "${f_}"
done
if ! [ ${#install[@]} -eq 0 ]; then
sudo apt-get install ${install[@]} -y
ok_msg "Done!"
status_msg "Writing DWC version to file ..."
echo "$GET_DWC2_URL" | cut -d/ -f8 > "$DWC2_DIR/.version"
ok_msg "Done!"
status_msg "Remove downloaded archive ..."
rm -rf *.zip && ok_msg "Done!" && ok_msg "Duet Web Control installed!"
}
##############################################################################################
#********************************************************************************************#
##############################################################################################
install_dwc_packages()
{
PKGLIST="python3-virtualenv python3-dev python3-tornado"
# Update system package info
status_msg "Running apt-get update..."
sudo apt-get update --allow-releaseinfo-change
# Install desired packages
status_msg "Installing packages..."
sudo apt-get install --yes "${PKGLIST}"
}
create_dwc_virtualenv()
{
status_msg "Installing python virtual environment..."
# Create virtualenv if it doesn't already exist
[ ! -d "${DWC_ENV}" ] && virtualenv -p /usr/bin/python3 "${DWC_ENV}"
# Install/update dependencies
"${DWC_ENV}"/bin/pip install tornado==6.0.4
}
create_single_dwc_startscript(){
### create systemd service file
sudo /bin/sh -c "cat > ${SYSTEMDDIR}/dwc.service" << DWC
[Unit]
Description=DuetWebControl
After=network.target
[Install]
WantedBy=multi-user.target
[Service]
Type=simple
User=${USER}
RemainAfterExit=yes
ExecStart=${DWC_ENV}/bin/python3 ${DWC2FK_DIR}/web_dwc2.py -l ${DWC_LOG} -c ${DWC_CFG}
Restart=always
RestartSec=10
DWC
}
create_multi_dwc_startscript(){
### create systemd service file
sudo /bin/sh -c "cat > ${SYSTEMDDIR}/dwc-$INSTANCE.service" << DWC
[Unit]
Description=DuetWebControl
After=network.target
[Install]
WantedBy=multi-user.target
[Service]
Type=simple
User=${USER}
RemainAfterExit=yes
ExecStart=${DWC_ENV}/bin/python3 ${DWC2FK_DIR}/web_dwc2.py -l ${DWC_LOG} -c ${DWC_CFG}
Restart=always
RestartSec=10
DWC
}
create_single_dwcfk_cfg(){
### create single instance config file
/bin/sh -c "cat > $DWC_CONF_LOC/dwc2.cfg" << DWCCFG
[webserver]
listen_adress: 0.0.0.0
web_root: ${HOME}/duetwebcontrol
port: ${PORT}
[reply_filters]
regex:
max_accel: \d+.\d+
max_accel_to_decel: \d+.\d+
square_corner_velocity: \d+.\d+
max_velocity: \d+.\d+
DWCCFG
}
create_multi_dwcfk_cfg(){
### create single instance config file
/bin/sh -c "cat > $DWC_CONF_LOC/printer_$INSTANCE/dwc2.cfg" << DWCCFG
[webserver]
listen_adress: 0.0.0.0
web_root: ${HOME}/duetwebcontrol
port: ${PORT}
[reply_filters]
regex:
max_accel: \d+.\d+
max_accel_to_decel: \d+.\d+
square_corner_velocity: \d+.\d+
max_velocity: \d+.\d+
DWCCFG
}
##############################################################################################
#********************************************************************************************#
##############################################################################################
print_dwc_ip_list(){
i=1
for ip in ${dwc_ip_list[@]}; do
echo -e " ${cyan}● Instance $i:${default} $ip"
i=$((i + 1))
done
}
create_single_dwc_instance(){
status_msg "Setting up 1 Duet Web Control instance ..."
### single instance variables
DWC_LOG=/tmp/dwc.log
DWC_CFG="$DWC_CONF_LOC/dwc2.cfg"
### create instance
status_msg "Creating single DWC instance ..."
create_single_dwc_startscript
### enable instance
sudo systemctl enable dwc.service
ok_msg "Single DWC instance created!"
### launching instance
status_msg "Launching DWC instance ..."
sudo systemctl start dwc
### confirm message
CONFIRM_MSG="Single DWC instance has been set up!"
print_msg && clear_msg
### display moonraker ip to the user
print_dwc_ip_list; echo
}
create_multi_dwc_instance(){
status_msg "Setting up $INSTANCE_COUNT instances of Duet Web Control ..."
while [ $INSTANCE -le "$INSTANCE_COUNT" ]; do
### multi instance variables
DWC_LOG=/tmp/dwc-$INSTANCE.log
DWC_CFG="$DWC_CONF_LOC/printer_$INSTANCE/dwc2.cfg"
### create instance
status_msg "Creating instance #$INSTANCE ..."
create_multi_dwc_startscript
### enable instance
sudo systemctl enable dwc-$INSTANCE.service
ok_msg "DWC instance $INSTANCE created!"
### launching instance
status_msg "Launching DWC instance $INSTANCE ..."
sudo systemctl start dwc-$INSTANCE
### instance counter +1
INSTANCE=$(expr $INSTANCE + 1)
done
### confirm message
CONFIRM_MSG="$INSTANCE_COUNT DWC instances has been set up!"
print_msg && clear_msg
### display moonraker ip to the user
print_dwc_ip_list; echo
}
dwc_cfg_creation(){
### default dwc port
DEFAULT_PORT=4750
### get printer config directory
source_kiauh_ini
DWC_CONF_LOC="$klipper_cfg_loc"
### reset instances back to 1 again
INSTANCE=1
### declare empty array for ips which get displayed to the user at the end of the setup
HOSTNAME=$(hostname -I | cut -d" " -f1)
dwc_ip_list=()
### create single instance dwc2.cfg file
if [ "$INSTANCE_COUNT" -eq $INSTANCE ]; then
### set port
PORT=$DEFAULT_PORT
### write the ip and port to the ip list for displaying it later to the user
dwc_ip_list+=("$HOSTNAME:$PORT")
status_msg "Creating dwc2.cfg in $DWC_CONF_LOC"
[ ! -d "$DWC_CONF_LOC" ] && mkdir -p "$DWC_CONF_LOC"
if [ ! -f "$DWC_CONF_LOC/dwc2.cfg" ]; then
create_single_dwcfk_cfg && ok_msg "dwc2.cfg created!"
else
warn_msg "There is already a file called 'dwc2.cfg'!"
warn_msg "Skipping..."
fi
### create multi instance moonraker.conf files
else
while [ $INSTANCE -le "$INSTANCE_COUNT" ]; do
### set each instance to its own port
PORT=$(expr $DEFAULT_PORT + $INSTANCE - 1)
### write the ip and port to the ip list for displaying it later to the user
dwc_ip_list+=("$HOSTNAME:$PORT")
### start the creation of each instance
status_msg "Creating dwc2.cfg for instance #$INSTANCE"
[ ! -d "$DWC_CONF_LOC/printer_$INSTANCE" ] && mkdir -p "$DWC_CONF_LOC/printer_$INSTANCE"
if [ ! -f "$DWC_CONF_LOC/printer_$INSTANCE/dwc2.cfg" ]; then
create_multi_dwcfk_cfg && ok_msg "dwc2.cfg created!"
else
warn_msg "There is already a file called 'dwc2.cfg'!"
warn_msg "Skipping..."
fi
### raise instance counter by 1
INSTANCE=$(expr $INSTANCE + 1)
done
fi
}

223
scripts/install_klipper.sh Normal file → Executable file
View File

@@ -1,30 +1,195 @@
install_klipper(){
if [ -e /etc/init.d/klipper ] && [ -e /etc/default/klipper ]; then
ERROR_MSG=" Looks like klipper is already installed!\n Skipping ..."
else
#check for dependencies
dep=(git)
dep_check
#execute operation
cd ${HOME}
status_msg "Cloning klipper repository ..."
git clone $KLIPPER_REPO && ok_msg "Klipper successfully cloned!"
status_msg "Installing klipper service ..."
$KLIPPER_DIR/scripts/install-octopi.sh && sleep 2 && ok_msg "Klipper installation complete!"
#create a klippy.log symlink in home-dir just for convenience
if [ ! -e ${HOME}/klippy.log ]; then
status_msg "Creating klippy.log symlink ..."
ln -s /tmp/klippy.log ${HOME}/klippy.log && ok_msg "Symlink created!"
fi
while true; do
echo -e "${cyan}"
read -p "###### Do you want to flash your MCU now? (Y/n): " yn
echo -e "${default}"
case "$yn" in
Y|y|Yes|yes|"") build_fw && flash_routine; break;;
N|n|No|no) break;;
*) warn_msg "Unknown parameter: $yn"; echo;;
esac
done
### base variables
SYSTEMDDIR="/etc/systemd/system"
KLIPPY_ENV="${HOME}/klippy-env"
KLIPPER_DIR="${HOME}/klipper"
KLIPPER_REPO="https://github.com/Klipper3d/klipper.git"
klipper_setup_dialog(){
### check for existing klipper service installations
SERVICE_FILES=""
INITD_SERVICE_FILES=$(find "/etc/init.d" -regextype posix-extended -regex "/etc/init.d/klipper(-[^0])?[0-9]*")
SYSTEMD_SERVICE_FILES=$(find "$SYSTEMDDIR" -regextype posix-extended -regex "$SYSTEMDDIR/klipper(-[^0])?[0-9]*.service")
[ -n "$INITD_SERVICE_FILES" ] && SERVICE_FILES+="${INITD_SERVICE_FILES}"
[ -n "$SYSTEMD_SERVICE_FILES" ] && SERVICE_FILES+=" ${SYSTEMD_SERVICE_FILES}"
if [ -n "$SERVICE_FILES" ]; then
ERROR_MSG="At least one Klipper service is already installed:"
for service in $SERVICE_FILES; do
ERROR_MSG="${ERROR_MSG}\n ➔ $service"
done && return
fi
}
status_msg "Initializing Klipper installation ..."
### initial printer.cfg path check
check_klipper_cfg_path
### ask for amount of instances to create
top_border
echo -e "| Please select the number of Klipper instances to set |"
echo -e "| up. The number of Klipper instances will determine |"
echo -e "| the amount of printers you can run from this machine. |"
blank_line
echo -e "| ${yellow}WARNING: There is no limit on the number of instances${default} |"
echo -e "| ${yellow}you can set up with this script.${default} |"
bottom_border
count=""
while [[ ! ($count =~ ^[1-9]+((0)+)?$) ]]; do
read -p "${cyan}###### Number of Klipper instances to set up:${default} " count
if [[ ! ($count =~ ^[1-9]+((0)+)?$) ]]; then
warn_msg "Invalid Input!" && echo
else
echo
read -p "${cyan}###### Install $count instance(s)? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
echo -e "###### > Yes"
status_msg "Installing $count Klipper instance(s) ..."
klipper_setup "$count"
break;;
N|n|No|no)
echo -e "###### > No"
warn_msg "Exiting Klipper setup ..."
echo
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
fi
done
}
install_klipper_packages(){
### read PKGLIST from official install script
status_msg "Reading dependencies..."
install_script="${HOME}/klipper/scripts/install-octopi.sh"
#PKGLIST=$(grep "PKGLIST=" $install_script | sed 's/PKGLIST//g; s/[$={}\n"]//g')
PKGLIST=$(grep "PKGLIST=" "$install_script" | sed 's/PKGLIST//g; s/[$"{}=]//g; s/\s\s*/ /g' | tr -d '\n')
### add dbus requirement for DietPi distro
[ -e "/boot/dietpi/.version" ] && PKGLIST+=" dbus"
for pkg in $PKGLIST; do
echo "${cyan}$pkg${default}"
done
read -r -a PKGLIST <<< "$PKGLIST"
### Update system package info
status_msg "Running apt-get update..."
sudo apt-get update --allow-releaseinfo-change
### Install desired packages
status_msg "Installing packages..."
sudo apt-get install --yes "${PKGLIST[@]}"
}
create_klipper_virtualenv(){
status_msg "Installing python virtual environment..."
# Create virtualenv if it doesn't already exist
[ ! -d "${KLIPPY_ENV}" ] && virtualenv -p python2 "${KLIPPY_ENV}"
# Install/update dependencies
"${KLIPPY_ENV}"/bin/pip install -r "${KLIPPER_DIR}"/scripts/klippy-requirements.txt
}
klipper_setup(){
INSTANCE_COUNT=$1
### checking dependencies
dep=(git)
dependency_check
### step 1: clone klipper
status_msg "Downloading Klipper ..."
### force remove existing klipper dir and clone into fresh klipper dir
[ -d "$KLIPPER_DIR" ] && rm -rf "$KLIPPER_DIR"
cd "${HOME}" && git clone "$KLIPPER_REPO"
status_msg "Download complete!"
### step 2: install klipper dependencies and create python virtualenv
status_msg "Installing dependencies ..."
install_klipper_packages
create_klipper_virtualenv
### step 3: create shared gcode_files and logs folder
[ ! -d "${HOME}"/gcode_files ] && mkdir -p "${HOME}"/gcode_files
[ ! -d "${HOME}"/klipper_logs ] && mkdir -p "${HOME}"/klipper_logs
### step 4: create klipper instances
create_klipper_service
### confirm message
if [[ $INSTANCE_COUNT -eq 1 ]]; then
CONFIRM_MSG="Klipper has been set up!"
elif [[ $INSTANCE_COUNT -gt 1 ]]; then
CONFIRM_MSG="$INSTANCE_COUNT Klipper instances have been set up!"
fi && print_msg && clear_msg
}
create_klipper_service(){
### get config directory
source_kiauh_ini
### set up default values
SINGLE_INST=1
CFG_PATH="$klipper_cfg_loc"
KL_ENV=$KLIPPY_ENV
KL_DIR=$KLIPPER_DIR
KL_LOG="${HOME}/klipper_logs/klippy.log"
KL_UDS="/tmp/klippy_uds"
P_TMP="/tmp/printer"
P_CFG="$CFG_PATH/printer.cfg"
P_CFG_SRC="${SRCDIR}/kiauh/resources/printer.cfg"
KL_SERV_SRC="${SRCDIR}/kiauh/resources/klipper.service"
KL_SERV_TARGET="$SYSTEMDDIR/klipper.service"
write_kl_service(){
[ ! -d "$CFG_PATH" ] && mkdir -p "$CFG_PATH"
### create a minimal config if there is no printer.cfg
[ ! -f "$P_CFG" ] && cp "$P_CFG_SRC" "$P_CFG"
### replace placeholder
if [ ! -f $KL_SERV_TARGET ]; then
status_msg "Creating Klipper Service $i ..."
sudo cp "$KL_SERV_SRC" $KL_SERV_TARGET
sudo sed -i "s|%INST%|$i|" $KL_SERV_TARGET
sudo sed -i "s|%USER%|${USER}|" $KL_SERV_TARGET
sudo sed -i "s|%KL_ENV%|$KL_ENV|" $KL_SERV_TARGET
sudo sed -i "s|%KL_DIR%|$KL_DIR|" $KL_SERV_TARGET
sudo sed -i "s|%KL_LOG%|$KL_LOG|" $KL_SERV_TARGET
sudo sed -i "s|%P_CFG%|$P_CFG|" $KL_SERV_TARGET
sudo sed -i "s|%P_TMP%|$P_TMP|" $KL_SERV_TARGET
sudo sed -i "s|%KL_UDS%|$KL_UDS|" $KL_SERV_TARGET
fi
}
if [[ $SINGLE_INST -eq $INSTANCE_COUNT ]]; then
### write single instance service
write_kl_service
### enable instance
sudo systemctl enable klipper.service
ok_msg "Single Klipper instance created!"
### launching instance
status_msg "Launching Klipper instance ..."
sudo systemctl start klipper
else
i=1
while [[ $i -le $INSTANCE_COUNT ]]; do
### rewrite default variables for multi instance cases
CFG_PATH="$klipper_cfg_loc/printer_$i"
KL_SERV_TARGET="$SYSTEMDDIR/klipper-$i.service"
P_TMP="/tmp/printer-$i"
P_CFG="$CFG_PATH/printer.cfg"
KL_LOG="${HOME}/klipper_logs/klippy-$i.log"
KL_UDS="/tmp/klippy_uds-$i"
### write multi instance service
write_kl_service
### enable instance
sudo systemctl enable klipper-$i.service
ok_msg "Klipper instance #$i created!"
### launching instance
status_msg "Launching Klipper instance #$i ..."
sudo systemctl start klipper-$i
### raise values by 1
i=$((i+1))
done
unset i
fi
}

603
scripts/install_klipper_webui.sh Executable file
View File

@@ -0,0 +1,603 @@
MAINSAIL_REPO_API="https://api.github.com/repos/mainsail-crew/mainsail/releases"
FLUIDD_REPO_API="https://api.github.com/repos/fluidd-core/fluidd/releases"
system_check_webui(){
### check system for installed moonraker service
if ls /etc/systemd/system/moonraker.service 2>/dev/null 1>&2 || ls /etc/systemd/system | grep -q -E "moonraker-[[:digit:]]+.service"; then
moonraker_chk_ok="true"
else
moonraker_chk_ok="false"
fi
### check system for an installed and enabled octoprint service
if sudo systemctl list-unit-files | grep -E "octoprint.*" | grep "enabled" &>/dev/null; then
OCTOPRINT_ENABLED="true"
fi
### check system for an installed haproxy service
if [[ $(dpkg-query -f'${Status}' --show haproxy 2>/dev/null) = *\ installed ]]; then
HAPROXY_FOUND="true"
fi
### check system for an installed lighttpd service
if [[ $(dpkg-query -f'${Status}' --show lighttpd 2>/dev/null) = *\ installed ]]; then
LIGHTTPD_FOUND="true"
fi
### check system for an installed apache2 service
if [[ $(dpkg-query -f'${Status}' --show apache2 2>/dev/null) = *\ installed ]]; then
APACHE2_FOUND="true"
fi
}
get_user_selection_mjpg-streamer(){
while true; do
unset INSTALL_MJPG
echo
top_border
echo -e "| Install MJGP-Streamer for webcam support? |"
bottom_border
read -p "${cyan}###### Install MJPG-Streamer? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
echo -e "###### > Yes"
INSTALL_MJPG="true"
break;;
N|n|No|no)
echo -e "###### > No"
INSTALL_MJPG="false"
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
}
get_user_selection_kiauh_macros(){
#ask user for webui default macros
while true; do
unset ADD_KIAUH_MACROS
echo
top_border
echo -e "| It is recommended to have some important macros set |"
echo -e "| up in your printer configuration to have $1|"
echo -e "| fully functional and working. |"
blank_line
echo -e "| Those macros are: |"
echo -e "| ${cyan}● [gcode_macro PAUSE]${default} |"
echo -e "| ${cyan}● [gcode_macro RESUME]${default} |"
echo -e "| ${cyan}● [gcode_macro CANCEL_PRINT]${default} |"
blank_line
echo -e "| If you already have these macros in your config file |"
echo -e "| you can skip this step and choose 'no'. |"
echo -e "| Otherwise you should consider to answer with 'yes' to |"
echo -e "| add the recommended example macros to your config. |"
bottom_border
read -p "${cyan}###### Add the recommended macros? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
echo -e "###### > Yes"
ADD_KIAUH_MACROS="true"
break;;
N|n|No|no)
echo -e "###### > No"
ADD_KIAUH_MACROS="false"
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
}
install_webui(){
source_kiauh_ini
### checking dependencies
dep=(nginx)
dependency_check
### check if moonraker is already installed
system_check_webui
### ask user how to handle OctoPrint, Haproxy, Lighttpd, Apache2 if found
process_octoprint_dialog
process_services_dialog
### process possible disruptive services
process_disruptive_services
[ "$1" == "mainsail" ] && IF_NAME1="Mainsail" && IF_NAME2="Mainsail "
[ "$1" == "fluidd" ] && IF_NAME1="Fluidd" && IF_NAME2="Fluidd "
### exit mainsail/fluidd setup if moonraker not found
if [ $moonraker_chk_ok = "false" ]; then
ERROR_MSG="Moonraker service not found!\n Please install Moonraker first!"
print_msg && clear_msg && return 0
fi
status_msg "Initializing $IF_NAME1 installation ..."
### check for other enabled web interfaces
unset SET_LISTEN_PORT
detect_enabled_sites
### check if another site already listens to port 80
$1_port_check
### ask user to install mjpg-streamer
if ! ls /etc/systemd/system/webcamd.service 2>/dev/null 1>&2; then
get_user_selection_mjpg-streamer
fi
### ask user to install the recommended webinterface macros
if ! ls "$klipper_cfg_loc"/kiauh_macros.cfg 2>/dev/null 1>&2 || ! ls "$klipper_cfg_loc"/printer_*/kiauh_macros.cfg 2>/dev/null 1>&2; then
get_user_selection_kiauh_macros "$IF_NAME2"
fi
### create /etc/nginx/conf.d/upstreams.conf
set_upstream_nginx_cfg
### create /etc/nginx/sites-available/<interface config>
set_nginx_cfg "$1"
### symlink nginx log
symlink_webui_nginx_log "$1"
### copy the kiauh_macros.cfg to the config location
install_kiauh_macros
### install mainsail/fluidd
$1_setup
### install mjpg-streamer
[ "$INSTALL_MJPG" = "true" ] && install_mjpg-streamer
fetch_webui_ports #WIP
### confirm message
CONFIRM_MSG="$IF_NAME1 has been set up!"
print_msg && clear_msg
}
symlink_webui_nginx_log(){
LPATH="${HOME}/klipper_logs"
UI_ACCESS_LOG="/var/log/nginx/$1-access.log"
UI_ERROR_LOG="/var/log/nginx/$1-error.log"
[ ! -d "$LPATH" ] && mkdir -p "$LPATH"
if [ -f "$UI_ACCESS_LOG" ] && [ ! -L "$LPATH/$1-access.log" ]; then
status_msg "Creating symlink for $UI_ACCESS_LOG ..."
ln -s "$UI_ACCESS_LOG" "$LPATH"
ok_msg "OK!"
fi
if [ -f "$UI_ERROR_LOG" ] && [ ! -L "$LPATH/$1-error.log" ]; then
status_msg "Creating symlink for $UI_ERROR_LOG ..."
ln -s "$UI_ERROR_LOG" "$LPATH"
ok_msg "OK!"
fi
}
install_kiauh_macros(){
source_kiauh_ini
### copy kiauh_macros.cfg
if [ "$ADD_KIAUH_MACROS" = "true" ]; then
### create a backup of the config folder
backup_klipper_config_dir
### handle multi printer.cfg
if ls "$klipper_cfg_loc"/printer_* 2>/dev/null 1>&2; then
for config in $(find $klipper_cfg_loc/printer_*/printer.cfg); do
path=$(echo "$config" | rev | cut -d"/" -f2- | rev)
if [ ! -f "$path/kiauh_macros.cfg" ]; then
### copy kiauh_macros.cfg to config location
status_msg "Creating macro config file ..."
cp "${SRCDIR}/kiauh/resources/kiauh_macros.cfg" "$path"
### write the include to the very first line of the printer.cfg
sed -i "1 i [include kiauh_macros.cfg]" "$path/printer.cfg"
ok_msg "$path/kiauh_macros.cfg created!"
fi
done
### handle single printer.cfg
elif [ -f "$klipper_cfg_loc/printer.cfg" ] && [ ! -f "$klipper_cfg_loc/kiauh_macros.cfg" ]; then
### copy kiauh_macros.cfg to config location
status_msg "Creating macro config file ..."
cp "${SRCDIR}/kiauh/resources/kiauh_macros.cfg" "$klipper_cfg_loc"
### write the include to the very first line of the printer.cfg
sed -i "1 i [include kiauh_macros.cfg]" "$klipper_cfg_loc/printer.cfg"
ok_msg "$klipper_cfg_loc/kiauh_macros.cfg created!"
fi
### restart klipper service to parse the modified printer.cfg
do_action_service "restart" "klipper"
fi
}
mainsail_port_check(){
if [ "$MAINSAIL_ENABLED" = "false" ]; then
if [ "$SITE_ENABLED" = "true" ]; then
status_msg "Detected other enabled interfaces:"
[ "$OCTOPRINT_ENABLED" = "true" ] && echo -e " ${cyan}● OctoPrint - Port: $OCTOPRINT_PORT${default}"
[ "$FLUIDD_ENABLED" = "true" ] && echo -e " ${cyan}● Fluidd - Port: $FLUIDD_PORT${default}"
[ "$DWC2_ENABLED" = "true" ] && echo -e " ${cyan}● DWC2 - Port: $DWC2_PORT${default}"
if [ "$FLUIDD_PORT" = "80" ] || [ "$DWC2_PORT" = "80" ] || [ "$OCTOPRINT_PORT" = "80" ]; then
PORT_80_BLOCKED="true"
select_mainsail_port
fi
else
DEFAULT_PORT=$(grep listen "${SRCDIR}/kiauh/resources/klipper_webui_nginx.cfg" | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
SET_LISTEN_PORT=$DEFAULT_PORT
fi
SET_NGINX_CFG="true"
else
SET_NGINX_CFG="false"
fi
}
fluidd_port_check(){
if [ "$FLUIDD_ENABLED" = "false" ]; then
if [ "$SITE_ENABLED" = "true" ]; then
status_msg "Detected other enabled interfaces:"
[ "$OCTOPRINT_ENABLED" = "true" ] && echo " ${cyan}● OctoPrint - Port: $OCTOPRINT_PORT${default}"
[ "$MAINSAIL_ENABLED" = "true" ] && echo " ${cyan}● Mainsail - Port: $MAINSAIL_PORT${default}"
[ "$DWC2_ENABLED" = "true" ] && echo " ${cyan}● DWC2 - Port: $DWC2_PORT${default}"
if [ "$MAINSAIL_PORT" = "80" ] || [ "$DWC2_PORT" = "80" ] || [ "$OCTOPRINT_PORT" = "80" ]; then
PORT_80_BLOCKED="true"
select_fluidd_port
fi
else
DEFAULT_PORT=$(grep listen "${SRCDIR}/kiauh/resources/klipper_webui_nginx.cfg" | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
SET_LISTEN_PORT=$DEFAULT_PORT
fi
SET_NGINX_CFG="true"
else
SET_NGINX_CFG="false"
fi
}
select_mainsail_port(){
if [ "$PORT_80_BLOCKED" = "true" ]; then
echo
top_border
echo -e "| ${red}!!!WARNING!!!${default} |"
echo -e "| ${red}You need to choose a different port for Mainsail!${default} |"
echo -e "| ${red}The following web interface is listening at port 80:${default} |"
blank_line
[ "$OCTOPRINT_PORT" = "80" ] && echo "| ● OctoPrint |"
[ "$FLUIDD_PORT" = "80" ] && echo "| ● Fluidd |"
[ "$DWC2_PORT" = "80" ] && echo "| ● DWC2 |"
blank_line
echo -e "| Make sure you don't choose a port which was already |"
echo -e "| assigned to one of the other webinterfaces and do ${red}NOT${default} |"
echo -e "| use ports in the range of 4750 or above! |"
blank_line
echo -e "| Be aware: there is ${red}NO${default} sanity check for the following |"
echo -e "| input. So make sure to choose a valid port! |"
bottom_border
while true; do
read -p "${cyan}Please enter a new Port:${default} " NEW_PORT
if [ "$NEW_PORT" != "$FLUIDD_PORT" ] && [ "$NEW_PORT" != "$DWC2_PORT" ] && [ "$NEW_PORT" != "$OCTOPRINT_PORT" ]; then
echo "Setting port $NEW_PORT for Mainsail!"
SET_LISTEN_PORT=$NEW_PORT
break
else
echo "That port is already taken! Select a different one!"
fi
done
fi
}
select_fluidd_port(){
if [ "$PORT_80_BLOCKED" = "true" ]; then
echo
top_border
echo -e "| ${red}!!!WARNING!!!${default} |"
echo -e "| ${red}You need to choose a different port for Fluidd!${default} |"
echo -e "| ${red}The following web interface is listening at port 80:${default} |"
blank_line
[ "$OCTOPRINT_PORT" = "80" ] && echo "| ● OctoPrint |"
[ "$MAINSAIL_PORT" = "80" ] && echo "| ● Mainsail |"
[ "$DWC2_PORT" = "80" ] && echo "| ● DWC2 |"
blank_line
echo -e "| Make sure you don't choose a port which was already |"
echo -e "| assigned to one of the other webinterfaces and do ${red}NOT${default} |"
echo -e "| use ports in the range of 4750 or above! |"
blank_line
echo -e "| Be aware: there is ${red}NO${default} sanity check for the following |"
echo -e "| input. So make sure to choose a valid port! |"
bottom_border
while true; do
read -p "${cyan}Please enter a new Port:${default} " NEW_PORT
if [ "$NEW_PORT" != "$MAINSAIL_PORT" ] && [ "$NEW_PORT" != "$DWC2_PORT" ] && [ "$NEW_PORT" != "$OCTOPRINT_PORT" ]; then
echo "Setting port $NEW_PORT for Fluidd!"
SET_LISTEN_PORT=$NEW_PORT
break
else
echo "That port is already taken! Select a different one!"
fi
done
fi
}
get_mainsail_ver(){
MAINSAIL_VERSION=$(curl -s $MAINSAIL_REPO_API | grep tag_name | cut -d'"' -f4 | head -1)
}
get_fluidd_ver(){
FLUIDD_VERSION=$(curl -s $FLUIDD_REPO_API | grep tag_name | cut -d'"' -f4 | head -1)
}
mainsail_setup(){
### get mainsail download url
MAINSAIL_DL_URL=$(curl -s $MAINSAIL_REPO_API | grep browser_download_url | cut -d'"' -f4 | head -1)
### remove existing and create fresh mainsail folder, then download mainsail
[ -d "$MAINSAIL_DIR" ] && rm -rf "$MAINSAIL_DIR"
mkdir "$MAINSAIL_DIR" && cd $MAINSAIL_DIR
status_msg "Downloading Mainsail $MAINSAIL_VERSION ..."
wget "$MAINSAIL_DL_URL" && ok_msg "Download complete!"
### extract archive
status_msg "Extracting archive ..."
unzip -q -o *.zip && ok_msg "Done!"
### delete downloaded zip
status_msg "Remove downloaded archive ..."
rm -rf *.zip && ok_msg "Done!"
### check for moonraker multi-instance and if multi-instance was found, enable mainsails remoteMode
if [ $(ls /etc/systemd/system/moonraker* | grep -E "moonraker(-[[:digit:]]+)?\.service" | wc -l) -gt 1 ]; then
enable_mainsail_remotemode
fi
}
enable_mainsail_remotemode(){
rm -f "$MAINSAIL_DIR/config.json"
echo -e "{\n \"remoteMode\":true\n}" >> "$MAINSAIL_DIR/config.json"
}
fluidd_setup(){
### get fluidd download url
FLUIDD_DL_URL=$(curl -s $FLUIDD_REPO_API | grep browser_download_url | cut -d'"' -f4 | head -1)
### remove existing and create fresh fluidd folder, then download fluidd
[ -d "$FLUIDD_DIR" ] && rm -rf "$FLUIDD_DIR"
mkdir "$FLUIDD_DIR" && cd $FLUIDD_DIR
status_msg "Downloading Fluidd $FLUIDD_VERSION ..."
wget "$FLUIDD_DL_URL" && ok_msg "Download complete!"
### extract archive
status_msg "Extracting archive ..."
unzip -q -o *.zip && ok_msg "Done!"
### delete downloaded zip
status_msg "Remove downloaded archive ..."
rm -rf *.zip && ok_msg "Done!"
}
set_upstream_nginx_cfg(){
get_date
### backup existing nginx configs
[ ! -d "$BACKUP_DIR/nginx_cfg" ] && mkdir -p "$BACKUP_DIR/nginx_cfg"
[ -f "$NGINX_CONFD/upstreams.conf" ] && sudo mv "$NGINX_CONFD/upstreams.conf" "$BACKUP_DIR/nginx_cfg/${current_date}_upstreams.conf"
[ -f "$NGINX_CONFD/common_vars.conf" ] && sudo mv "$NGINX_CONFD/common_vars.conf" "$BACKUP_DIR/nginx_cfg/${current_date}_common_vars.conf"
### transfer ownership of backed up files from root to ${USER}
for log in $(ls "$BACKUP_DIR/nginx_cfg"); do
sudo chown "${USER}" "$BACKUP_DIR/nginx_cfg/$log"
done
### copy nginx configs to target destination
if [ ! -f "$NGINX_CONFD/upstreams.conf" ]; then
sudo cp "${SRCDIR}/kiauh/resources/upstreams.conf" "$NGINX_CONFD"
fi
if [ ! -f "$NGINX_CONFD/common_vars.conf" ]; then
sudo cp "${SRCDIR}/kiauh/resources/common_vars.conf" "$NGINX_CONFD"
fi
}
fetch_webui_ports(){
### read listen ports from possible installed interfaces
### and write them to ~/.kiauh.ini
WEBIFS=(mainsail fluidd octoprint dwc2)
for interface in "${WEBIFS[@]}"; do
if [ -f "/etc/nginx/sites-available/${interface}" ]; then
port=$(grep -E "listen" "/etc/nginx/sites-available/$interface" | head -1 | sed 's/^\s*//' | sed 's/;$//' | cut -d" " -f2)
if [ ! -n "$(grep -E "${interface}_port" "$INI_FILE")" ]; then
sed -i '$a'"${interface}_port=${port}" "$INI_FILE"
else
sed -i "/^${interface}_port/d" "$INI_FILE"
sed -i '$a'"${interface}_port=${port}" "$INI_FILE"
fi
else
sed -i "/^${interface}_port/d" "$INI_FILE"
fi
done
}
match_nginx_configs(){
### reinstall nginx configs if the amount of upstreams don't match anymore
source_kiauh_ini
cfg_updated="false"
mainsail_nginx_cfg="/etc/nginx/sites-available/mainsail"
fluidd_nginx_cfg="/etc/nginx/sites-available/fluidd"
upstreams_webcams=$(grep -E "mjpgstreamer" /etc/nginx/conf.d/upstreams.conf | wc -l)
status_msg "Checking validity of NGINX configurations ..."
if [ -e "$mainsail_nginx_cfg" ]; then
mainsail_webcams=$(grep -E "mjpgstreamer" "$mainsail_nginx_cfg" | wc -l)
fi
if [ -e "$fluidd_nginx_cfg" ]; then
fluidd_webcams=$(grep -E "mjpgstreamer" "$fluidd_nginx_cfg" | wc -l)
fi
### check for outdated upstreams.conf
if [[ "$upstreams_webcams" -lt "$mainsail_webcams" ]] || [[ "$upstreams_webcams" -lt "$fluidd_webcams" ]]; then
status_msg "Outdated upstreams.conf found! Updating ..."
sudo rm -f "$NGINX_CONFD/upstreams.conf"
sudo rm -f "$NGINX_CONFD/common_vars.conf"
set_upstream_nginx_cfg
cfg_updated="true"
fi
### check for outdated mainsail config
if [ -e "$mainsail_nginx_cfg" ]; then
if [[ "$upstreams_webcams" -gt "$mainsail_webcams" ]]; then
status_msg "Outdated Mainsail config found! Updating ..."
sudo rm -f "$mainsail_nginx_cfg"
sudo cp "${SRCDIR}/kiauh/resources/klipper_webui_nginx.cfg" "$mainsail_nginx_cfg"
sudo sed -i "s/<<UI>>/mainsail/g" "$mainsail_nginx_cfg"
sudo sed -i "/root/s/pi/${USER}/" "$mainsail_nginx_cfg"
sudo sed -i "s/listen\s[0-9]*;/listen $mainsail_port;/" "$mainsail_nginx_cfg"
sudo sed -i "s/listen\s\[\:*\]\:[0-9]*;/listen \[::\]\:$mainsail_port;/" "$mainsail_nginx_cfg"
cfg_updated="true" && ok_msg "Done!"
fi
fi
### check for outdated fluidd config
if [ -e "$fluidd_nginx_cfg" ]; then
if [[ "$upstreams_webcams" -gt "$fluidd_webcams" ]]; then
status_msg "Outdated Fluidd config found! Updating ..."
sudo rm -f "$fluidd_nginx_cfg"
sudo cp "${SRCDIR}/kiauh/resources/klipper_webui_nginx.cfg" "$fluidd_nginx_cfg"
sudo sed -i "s/<<UI>>/fluidd/g" "$fluidd_nginx_cfg"
sudo sed -i "/root/s/pi/${USER}/" "$fluidd_nginx_cfg"
sudo sed -i "s/listen\s[0-9]*;/listen $fluidd_port;/" "$fluidd_nginx_cfg"
sudo sed -i "s/listen\s\[\:*\]\:[0-9]*;/listen \[::\]\:$fluidd_port;/" "$fluidd_nginx_cfg"
cfg_updated="true" && ok_msg "Done!"
fi
fi
### only restart nginx if configs were updated
if [ "$cfg_updated" == "true" ]; then
restart_nginx && unset cfg_updated
fi
}
process_octoprint_dialog(){
#ask user to disable octoprint when its service was found
if [ "$OCTOPRINT_ENABLED" = "true" ]; then
while true; do
echo
top_border
echo -e "| ${red}!!! WARNING - OctoPrint service found !!!${default} |"
hr
echo -e "| You might consider disabling the OctoPrint service, |"
echo -e "| since an active OctoPrint service may lead to unex- |"
echo -e "| pected behavior of the Klipper Webinterfaces. |"
bottom_border
read -p "${cyan}###### Do you want to disable OctoPrint now? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
echo -e "###### > Yes"
status_msg "Stopping OctoPrint ..."
do_action_service "stop" "octoprint" && ok_msg "OctoPrint service stopped!"
status_msg "Disabling OctoPrint ..."
do_action_service "disable" "octoprint" && ok_msg "OctoPrint service disabled!"
break;;
N|n|No|no)
echo -e "###### > No"
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
fi
}
process_disruptive_services(){
#handle haproxy service
if [ "$DISABLE_HAPROXY" = "true" ] || [ "$REMOVE_HAPROXY" = "true" ]; then
if systemctl is-active haproxy -q; then
status_msg "Stopping haproxy service ..."
sudo systemctl stop haproxy && ok_msg "Service stopped!"
fi
### disable haproxy
if [ "$DISABLE_HAPROXY" = "true" ]; then
status_msg "Disabling haproxy ..."
sudo systemctl disable haproxy && ok_msg "Haproxy service disabled!"
### remove haproxy
if [ "$REMOVE_HAPROXY" = "true" ]; then
status_msg "Removing haproxy ..."
sudo apt-get remove haproxy -y && sudo update-rc.d -f haproxy remove && ok_msg "Haproxy removed!"
fi
fi
fi
### handle lighttpd service
if [ "$DISABLE_LIGHTTPD" = "true" ] || [ "$REMOVE_LIGHTTPD" = "true" ]; then
if systemctl is-active lighttpd -q; then
status_msg "Stopping lighttpd service ..."
sudo systemctl stop lighttpd && ok_msg "Service stopped!"
fi
### disable lighttpd
if [ "$DISABLE_LIGHTTPD" = "true" ]; then
status_msg "Disabling lighttpd ..."
sudo systemctl disable lighttpd && ok_msg "Lighttpd service disabled!"
### remove lighttpd
if [ "$REMOVE_LIGHTTPD" = "true" ]; then
status_msg "Removing lighttpd ..."
sudo apt-get remove lighttpd -y && sudo update-rc.d -f lighttpd remove && ok_msg "Lighttpd removed!"
fi
fi
fi
### handle apache2 service
if [ "$DISABLE_APACHE2" = "true" ] || [ "$REMOVE_APACHE2" = "true" ]; then
if systemctl is-active apache2 -q; then
status_msg "Stopping apache2 service ..."
sudo systemctl stop apache2 && ok_msg "Service stopped!"
fi
### disable lighttpd
if [ "$DISABLE_APACHE2" = "true" ]; then
status_msg "Disabling lighttpd ..."
sudo systemctl disable apache2 && ok_msg "Apache2 service disabled!"
### remove lighttpd
if [ "$REMOVE_APACHE2" = "true" ]; then
status_msg "Removing apache2 ..."
sudo apt-get remove apache2 -y && sudo update-rc.d -f apache2 remove && ok_msg "Apache2 removed!"
fi
fi
fi
}
process_services_dialog(){
#notify user about haproxy or lighttpd services found and possible issues
if [ "$HAPROXY_FOUND" = "true" ] || [ "$LIGHTTPD_FOUND" = "true" ] || [ "$APACHE2_FOUND" = "true" ]; then
while true; do
echo
top_border
echo -e "| ${red}Possibly disruptive/incompatible services found!${default} |"
hr
if [ "$HAPROXY_FOUND" = "true" ]; then
echo -e "| ● haproxy |"
fi
if [ "$LIGHTTPD_FOUND" = "true" ]; then
echo -e "| ● lighttpd |"
fi
if [ "$APACHE2_FOUND" = "true" ]; then
echo -e "| ● apache2 |"
fi
hr
echo -e "| Having those packages installed can lead to unwanted |"
echo -e "| behaviour. It is recommend to remove those packages. |"
echo -e "| |"
echo -e "| 1) Remove packages (recommend) |"
echo -e "| 2) Disable only (may cause issues) |"
echo -e "| ${red}3) Skip this step (not recommended)${default} |"
bottom_border
read -p "${cyan}###### Please choose:${default} " action
case "$action" in
1)
echo -e "###### > Remove packages"
REMOVE_HAPROXY="true"
REMOVE_LIGHTTPD="true"
REMOVE_APACHE2="true"
break;;
2)
echo -e "###### > Disable only"
DISABLE_HAPROXY="true"
DISABLE_LIGHTTPD="true"
DISABLE_APACHE2="true"
break;;
3)
echo -e "###### > Skip"
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
fi
}

View File

@@ -0,0 +1,39 @@
install_klipperscreen(){
python3_check
if [ $py_chk_ok = "true" ]; then
source_kiauh_ini
#KlipperScreen main installation
klipperscreen_setup
#after install actions
restart_klipperscreen
else
ERROR_MSG="Python 3.7 or above required!\n Please upgrade your Python version first."
print_msg && clear_msg
fi
}
python3_check(){
status_msg "Your Python 3 version is: $(python3 --version)"
major=$(python3 --version | cut -d" " -f2 | cut -d"." -f1)
minor=$(python3 --version | cut -d"." -f2)
if [ $major -ge 3 ] && [ $minor -ge 7 ]; then
ok_msg "Python version ok!"
py_chk_ok="true"
else
py_chk_ok="false"
fi
}
klipperscreen_setup(){
dep=(wget curl unzip dfu-util)
dependency_check
status_msg "Downloading KlipperScreen ..."
# force remove existing KlipperScreen dir
[ -d $KLIPPERSCREEN_DIR ] && rm -rf $KLIPPERSCREEN_DIR
# clone into fresh KlipperScreen dir
cd ${HOME} && git clone $KLIPPERSCREEN_REPO
ok_msg "Download complete!"
status_msg "Installing KlipperScreen ..."
$KLIPPERSCREEN_DIR/scripts/KlipperScreen-install.sh
ok_msg "KlipperScreen successfully installed!"
}

View File

@@ -1,349 +0,0 @@
mainsail_install_routine(){
if [ -d $KLIPPER_DIR ]; then
#check for dependencies
dep=(wget curl unzip)
dep_check
#execute operation
install_moonraker
disable_wrong_webserver
remove_wrong_webserver
install_nginx
test_api
test_nginx
install_mainsail && ok_msg "Mainsail install complete!"; echo
else
ERROR_MSG=" Please install Klipper first!\n Skipping..."
fi
}
install_moonraker(){
cd $KLIPPER_DIR
if [[ $(git describe --all) = "remotes/Arksine/work-web_server-20200131" ]]; then
status_msg "Installing Moonraker ..."
$KLIPPER_DIR/scripts/install-moonraker.sh && ok_msg "Moonraker successfully installed!"
if [ ! -d ${HOME}/sdcard ]; then
mkdir ${HOME}/sdcard
fi
#create a moonraker.log symlink in home-dir just for convenience
if [ ! -e ${HOME}/moonraker.log ]; then
status_msg "Creating moonraker.log symlink ..."
ln -s /tmp/moonraker.log ${HOME}/moonraker.log && ok_msg "Symlink created!"
fi
else
warn_msg "You are not using Arksine/work-web_server-20200131."
warn_msg "Please switch to the moonraker fork first!"
while true; do
echo -e "${cyan}"
read -p "###### Do you want to switch to it now? (Y/n): " yn
echo -e "${default}"
case "$yn" in
Y|y|Yes|yes|"") switch_to_moonraker && install_moonraker; break;;
N|n|No|no) break;;
*) echo "Unknown parameter: $yn"; echo;;
esac
done
fi
}
check_printer_cfg(){
if [ ! -e $PRINTER_CFG ]; then
warn_msg "No printer.cfg found"
while true; do
echo -e "${cyan}"
read -p "###### Do you want to create a default config? (Y/n): " yn
echo -e "${default}"
case "$yn" in
Y|y|Yes|yes|"") create_default_cfg; break;;
N|n|No|no) break;;
*) echo "Unknown parameter: $yn"; echo;;
esac
done
else
check_vsdcard_section
check_api_section
fi
}
disable_wrong_webserver(){
if systemctl is-active haproxy ; then
status_msg "Stopping haproxy service ..."
sudo /etc/init.d/haproxy stop && ok_msg "Service stopped!"
fi
if systemctl is-active lighttpd ; then
status_msg "Stopping lighttpd service ..."
sudo /etc/init.d/lighttpd stop && ok_msg "Service stopped!"
fi
}
remove_wrong_webserver(){
rem=(haproxy lighttpd)
for remove in "${rem[@]}"
do
if [[ $(dpkg-query -f'${Status}' --show $remove 2>/dev/null) = *\ installed ]]; then
delete+=($remove)
fi
done
if ! [ ${#delete[@]} -eq 0 ]; then
sudo apt-get remove ${delete[@]} -y
fi
}
install_nginx(){
if ! [[ $(dpkg-query -f'${Status}' --show nginx 2>/dev/null) = *\ installed ]]; then
status_msg "Installing Nginx ..."
sudo apt-get install nginx -y && ok_msg "Nginx successfully installed!"
fi
if [ ! -d $MAINSAIL_DIR ]; then
mkdir $MAINSAIL_DIR
fi
status_msg "Configure Nginx ..."
create_mainsail_cfgfile && sudo mv $MAINSAIL_DIR/mainsail /etc/nginx/sites-available/
if [ -e /etc/nginx/sites-enabled/default ]; then
sudo rm /etc/nginx/sites-enabled/default
fi
if [ ! -e /etc/nginx/sites-enabled/mainsail ]; then
sudo ln -s /etc/nginx/sites-available/mainsail /etc/nginx/sites-enabled/
fi
ok_msg "Nginx configured!"
}
test_api(){
status_msg "Testing API ..."
sleep 5
status_msg "API response from http://localhost:7125/printer/info:"
API_RESPONSE="$(curl -sG4 http://localhost:7125/printer/info)"
echo -e "${cyan}$API_RESPONSE${default}"
if [ $(curl -sG4 "http://localhost:7125/printer/info" | grep '^{"result"' -c) -eq 1 ]; then
echo; ok_msg "Klipper API is working correctly!"; echo
else
echo; warn_msg "Klipper API not working correctly!"; echo
fi
}
test_nginx(){
sudo /etc/init.d/nginx restart
status_msg "Testing Nginx ..."
sleep 5
status_msg "API response from http://localhost/printer/info:"
API_RESPONSE="$(curl -sG4 http://localhost/printer/info)"
echo -e "${cyan}$API_RESPONSE${default}"
if [ $(curl -sG4 "http://localhost/printer/info" | grep '^{"result"' -c) -eq 1 ]; then
echo; ok_msg "Nginx is working correctly!"; echo
else
echo; warn_msg "Nginx is not working correctly!"; echo
fi
}
get_mainsail_ver(){
MAINSAIL_VERSION=`curl -s https://api.github.com/repositories/240875926/tags | grep name | cut -d'"' -f4 | cut -d"v" -f2 | head -1`
}
mainsail_dl_url(){
get_mainsail_ver
MAINSAIL_URL=https://github.com/meteyou/mainsail/releases/download/v"$MAINSAIL_VERSION"/mainsail-alpha-"$MAINSAIL_VERSION".zip
}
install_mainsail(){
mainsail_dl_url
if [ ! -d $MAINSAIL_DIR ]; then
mkdir $MAINSAIL_DIR
fi
cd $MAINSAIL_DIR
status_msg "Downloading Mainsail v$MAINSAIL_VERSION ..."
wget -q -O mainsail.zip $MAINSAIL_URL && status_msg "Extracting archive ..." && unzip -o mainsail.zip && rm mainsail.zip
### write mainsail version to file for update check reasons
echo "$MAINSAIL_VERSION" > $MAINSAIL_DIR/version
}
create_mainsail_cfgfile(){
cat <<MAINSAIL_CFG > $MAINSAIL_DIR/mainsail
map \$http_upgrade \$connection_upgrade {
default upgrade;
'' close;
}
upstream apiserver {
#edit your api port here
ip_hash;
server 127.0.0.1:7125;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
access_log /var/log/nginx/mainsail-access.log;
error_log /var/log/nginx/mainsail-error.log;
#web_path from mainsail static files
root /home/pi/mainsail;
index index.html;
server_name _;
#max upload size for gcodes
client_max_body_size 200M;
location / {
try_files \$uri \$uri/ /index.html;
}
location /printer {
proxy_pass http://apiserver/printer;
proxy_set_header Host \$http_host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Scheme \$scheme;
}
location /api {
proxy_pass http://apiserver/api;
proxy_set_header Host \$http_host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Scheme \$scheme;
}
location /access {
proxy_pass http://apiserver/access;
proxy_set_header Host \$http_host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Scheme \$scheme;
}
location /websocket {
proxy_pass http://apiserver/websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection \$connection_upgrade;
proxy_set_header Host \$http_host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_read_timeout 86400;
}
location /machine {
proxy_pass http://apiserver/machine;
proxy_set_header Host \$http_host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Scheme \$scheme;
}
location /server {
proxy_pass http://apiserver/server;
proxy_set_header Host \$http_host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Scheme \$scheme;
}
}
MAINSAIL_CFG
}
check_vsdcard_section(){
# check if virtual sdcard is present in printer.cfg
if [ $(grep '^\[virtual_sdcard\]$' /home/pi/printer.cfg) ]; then
echo "Virtual sdcard already configured"
else
echo "No virtual sdcard entry found..."
echo "Configuring virtual sdcard..."
# append the following lines to printer.cfg
cat <<VSDCARD >> $PRINTER_CFG
##########################
### CREATED WITH KIAUH ###
##########################
[virtual_sdcard]
path: ~/sdcard
##########################
##########################
VSDCARD
fi
}
check_api_section(){
# check if api server is present in printer.cfg
if [ $(grep '^\[api_server\]$' /home/pi/printer.cfg) ]; then
echo "API server already configured"
else
echo "No API server entry found..."
echo "Configuring API server..."
# append the following lines to printer.cfg
cat <<API >> $PRINTER_CFG
##########################
### CREATED WITH KIAUH ###
##########################
[api_server]
trusted_clients:
192.168.0.0/24
192.168.1.0/24
127.0.0.0/24
##########################
##########################
API
fi
}
create_default_cfg(){
cat <<MAINSAIL_CFG >> $PRINTER_CFG
##########################
### CREATED WITH KIAUH ###
##########################
[virtual_sdcard]
path: ~/sdcard
[api_server]
trusted_clients:
192.168.0.0/24
192.168.1.0/24
127.0.0.0/24
[pause_resume]
[gcode_macro CANCEL]
default_parameter_X: 230
default_parameter_Y: 230
default_parameter_Z: 10
gcode:
M104 S0
M140 S0
M141 S0
M106 S0
CLEAR_PAUSE
RESET_SD
[gcode_macro CANCEL_PRINT]
gcode:
CANCEL
[gcode_macro PAUSE]
rename_existing: BASE_PAUSE
default_parameter_X: 230
default_parameter_Y: 230
default_parameter_Z: 10
gcode:
SAVE_GCODE_STATE NAME=PAUSE_state
BASE_PAUSE
G91
G1 E-1.7 F2100
G1 Z{Z}
G90
G1 X{X} Y{Y} F6000
G91
[gcode_macro RESUME]
rename_existing: BASE_RESUME
gcode:
G91
G1 E1.7 F2100
G91
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1
BASE_RESUME
##########################
##########################
MAINSAIL_CFG
}

132
scripts/install_mjpg-streamer.sh Executable file
View File

@@ -0,0 +1,132 @@
### base variables
SYSTEMDDIR="/etc/systemd/system"
WEBCAMD_SRC="https://raw.githubusercontent.com/mainsail-crew/MainsailOS/master/src/modules/mjpgstreamer/filesystem/root/usr/local/bin/webcamd"
WEBCAM_TXT_SRC="https://raw.githubusercontent.com/mainsail-crew/MainsailOS/master/src/modules/mjpgstreamer/filesystem/home/pi/klipper_config/webcam.txt"
install_mjpg-streamer(){
check_klipper_cfg_path
source_kiauh_ini
### set default values
MJPG_SERV_SRC="${SRCDIR}/kiauh/resources/webcamd.service"
MJPG_SERV_TARGET="$SYSTEMDDIR/webcamd.service"
WEBCAM_TXT="$klipper_cfg_loc/webcam.txt"
### if there is a webcamd.service -> exit
if [ -f $MJPG_SERV_TARGET ]; then
ERROR_MSG="Looks like MJPG-streamer is already installed!\n Please remove it first before you try to re-install it!"
print_msg && clear_msg && return
fi
### check and install dependencies if missing
dep=(git cmake build-essential imagemagick libv4l-dev ffmpeg)
if apt-cache search libjpeg62-turbo-dev | grep -Eq "^libjpeg62-turbo-dev "; then
dep+=(libjpeg62-turbo-dev)
elif apt-cache search libjpeg8-dev | grep -Eq "^libjpeg8-dev "; then
dep+=(libjpeg8-dev)
fi
dependency_check
### step 1: clone moonraker
status_msg "Downloading MJPG-Streamer ..."
cd "${HOME}" && git clone https://github.com/jacksonliam/mjpg-streamer.git
ok_msg "Download complete!"
### step 2: compiling mjpg-streamer
status_msg "Compiling MJPG-Streamer ..."
cd "${HOME}"/mjpg-streamer/mjpg-streamer-experimental && make
ok_msg "Compiling complete!"
#step 3: install mjpg-streamer
status_msg "Installing MJPG-Streamer ..."
cd "${HOME}"/mjpg-streamer && mv mjpg-streamer-experimental/* .
mkdir www-mjpgstreamer
cat <<EOT >> ./www-mjpgstreamer/index.html
<html>
<head><title>mjpg_streamer test page</title></head>
<body>
<h1>Snapshot</h1>
<p>Refresh the page to refresh the snapshot</p>
<img src="./?action=snapshot" alt="Snapshot">
<h1>Stream</h1>
<img src="./?action=stream" alt="Stream">
</body>
</html>
EOT
sudo wget $WEBCAMD_SRC -O "/usr/local/bin/webcamd"
sudo sed -i "/^config_dir=/ s|=.*|=$klipper_cfg_loc|" /usr/local/bin/webcamd
sudo sed -i "/MJPGSTREAMER_HOME/ s/pi/${USER}/" /usr/local/bin/webcamd
sudo chmod +x /usr/local/bin/webcamd
### step 4: create webcam.txt config file
[ ! -d "$klipper_cfg_loc" ] && mkdir -p "$klipper_cfg_loc"
if [ ! -f "$WEBCAM_TXT" ]; then
status_msg "Creating webcam.txt config file ..."
wget $WEBCAM_TXT_SRC -O "$WEBCAM_TXT"
ok_msg "Done!"
fi
### step 5: create systemd service
status_msg "Creating MJPG-Streamer service ..."
sudo cp "$MJPG_SERV_SRC" $MJPG_SERV_TARGET
sudo sed -i "s|%USER%|${USER}|" $MJPG_SERV_TARGET
ok_msg "MJPG-Streamer service created!"
### step 6: enabling and starting mjpg-streamer service
status_msg "Starting MJPG-Streamer service ..."
sudo systemctl enable webcamd.service
sudo systemctl start webcamd.service
ok_msg "MJPG-Streamer service started!"
### step 6.1: create webcamd.log symlink
[ ! -d "${HOME}/klipper_logs" ] && mkdir -p "${HOME}/klipper_logs"
if [ -f "/var/log/webcamd.log" ] && [ ! -L "${HOME}/klipper_logs/webcamd.log" ]; then
ln -s "/var/log/webcamd.log" "${HOME}/klipper_logs/webcamd.log"
fi
### step 6.2: add webcamd.log logrotate
if [ ! -f "/etc/logrotate.d/webcamd" ]; then
status_msg "Create logrotate rule ..."
sudo /bin/sh -c "cat > /etc/logrotate.d/webcamd" << EOF
/var/log/webcamd.log
{
rotate 2
weekly
maxsize 32M
missingok
notifempty
compress
delaycompress
sharedscripts
}
EOF
ok_msg "Done!"
fi
### step 7: check if user is in group "video"
usergroup_changed=false
USER_IN_VIDEO_GROUP=$(groups "${USER}" | grep "video")
if [ -z "$USER_IN_VIDEO_GROUP" ]; then
status_msg "Adding user ${USER} to group 'video' ..."
sudo usermod -a -G video "${USER}" && ok_msg "Done!"
usergroup_changed=true
else
ok_msg "User ${USER} already in group 'video'!"
fi
### confirm message
CONFIRM_MSG="MJPG-Streamer has been set up!"
if [ "$usergroup_changed" == true ]; then
CONFIRM_MSG="${CONFIRM_MSG}\n ${yellow}INFO: Your User was added to a new group!${green}"
CONFIRM_MSG="${CONFIRM_MSG}\n ${yellow}You need to relog/restart for the group to be applied!${green}"
fi
print_msg && clear_msg
### print webcam ip adress/url
IP=$(hostname -I | cut -d" " -f1)
WEBCAM_IP="http://$IP:8080/?action=stream"
WEBCAM_URL="http://$IP/webcam/?action=stream"
echo -e " ${cyan}● Webcam URL:${default} $WEBCAM_IP"
echo -e " ${cyan}● Webcam URL:${default} $WEBCAM_URL"
echo
}

View File

@@ -0,0 +1,23 @@
install_MoonrakerTelegramBot(){
source_kiauh_ini
#MoonrakerTelegramBot main installation
MoonrakerTelegramBot_setup
#after install actions
restart_MoonrakerTelegramBot
}
MoonrakerTelegramBot_setup(){
source_kiauh_ini
export klipper_cfg_loc
dep=(virtualenv)
dependency_check
status_msg "Downloading MoonrakerTelegramBot ..."
#force remove existing MoonrakerTelegramBot dir
[ -d $MOONRAKER_TELEGRAM_BOT_DIR ] && rm -rf $MOONRAKER_TELEGRAM_BOT_DIR
#clone into fresh MoonrakerTelegramBot dir
cd ${HOME} && git clone $NLEF_REPO
ok_msg "Download complete!"
status_msg "Installing MoonrakerTelegramBot ..."
$MOONRAKER_TELEGRAM_BOT_DIR/scripts/install.sh
echo; ok_msg "MoonrakerTelegramBot successfully installed!"
}

321
scripts/install_moonraker.sh Executable file
View File

@@ -0,0 +1,321 @@
### base variables
SYSTEMDDIR="/etc/systemd/system"
MOONRAKER_ENV="${HOME}/moonraker-env"
MOONRAKER_DIR="${HOME}/moonraker"
MOONRAKER_REPO="https://github.com/Arksine/moonraker.git"
system_check_moonraker(){
### python 3 check
status_msg "Your Python 3 version is: $(python3 --version)"
major=$(python3 --version | cut -d" " -f2 | cut -d"." -f1)
minor=$(python3 --version | cut -d"." -f2)
if [ "$major" -ge 3 ] && [ "$minor" -ge 7 ]; then
py_chk_ok="true"
else
py_chk_ok="false"
fi
}
moonraker_setup_dialog(){
### check for existing moonraker service installations
SERVICE_FILES=$(find "$SYSTEMDDIR" -regextype posix-extended -regex "$SYSTEMDDIR/moonraker(-[^0])?[0-9]*.service")
if [ -n "$SERVICE_FILES" ]; then
ERROR_MSG="At least one Moonraker service is already installed:"
for service in $SERVICE_FILES; do
ERROR_MSG="${ERROR_MSG}\n ➔ $service"
done && return
fi
status_msg "Initializing Moonraker installation ..."
### checking system for python3.7+
system_check_moonraker
### exit moonraker setup if python versioncheck fails
if [ $py_chk_ok = "false" ]; then
ERROR_MSG="Versioncheck failed! Python 3.7 or newer required!\n"
ERROR_MSG="${ERROR_MSG} Please upgrade Python."
print_msg && clear_msg && return
fi
### count amount of klipper services
SERVICE_FILES=$(find "$SYSTEMDDIR" -regextype posix-extended -regex "$SYSTEMDDIR/klipper(-[^0])+[0-9]*.service")
if [ -f /etc/init.d/klipper ] || [ -f /etc/systemd/system/klipper.service ]; then
KLIPPER_COUNT=1
elif [ -n "$SERVICE_FILES" ]; then
KLIPPER_COUNT=$(echo "$SERVICE_FILES" | wc -l)
fi
### initial moonraker.conf path check
check_klipper_cfg_path
top_border
if [[ $KLIPPER_COUNT -eq 1 ]]; then
printf "|${green}%-55s${default}|\n" " 1 Klipper instance was found!"
elif [[ $KLIPPER_COUNT -gt 1 ]]; then
printf "|${green}%-55s${default}|\n" " $KLIPPER_COUNT Klipper instances were found!"
else
echo -e "| ${yellow}INFO: No existing Klipper installation found!${default} |"
fi
echo -e "| Usually you need one Moonraker instance per Klipper |"
echo -e "| instance. Though you can install as many as you wish. |"
bottom_border
echo
count=""
while [[ ! ($count =~ ^[1-9]+((0)+)?$) ]]; do
read -p "${cyan}###### Number of Moonraker instances to set up:${default} " count
if [[ ! ($count =~ ^[1-9]+((0)+)?$) ]]; then
warn_msg "Invalid Input!\n"
else
echo
read -p "${cyan}###### Install $count instance(s)? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
echo -e "###### > Yes"
status_msg "Installing Moonraker ...\n"
moonraker_setup "$count"
break;;
N|n|No|no)
echo -e "###### > No"
warn_msg "Exiting Moonraker setup ...\n"
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
fi
done
}
moonraker_setup(){
INSTANCE_COUNT=$1
### checking dependencies
dep=(wget curl unzip dfu-util virtualenv)
### additional deps for kiauh compatibility for armbian
dep+=(libjpeg-dev zlib1g-dev)
dependency_check
### step 1: clone moonraker
status_msg "Downloading Moonraker ..."
### force remove existing moonraker dir and clone into fresh moonraker dir
[ -d "$MOONRAKER_DIR" ] && rm -rf "$MOONRAKER_DIR"
cd "${HOME}" && git clone $MOONRAKER_REPO
ok_msg "Download complete!"
### step 2: install moonraker dependencies and create python virtualenv
status_msg "Installing dependencies ..."
install_moonraker_packages
create_moonraker_virtualenv
### step 3: create moonraker.conf folder and moonraker.confs
create_moonraker_conf
### step 4: create final moonraker instances
create_moonraker_service
### step 5: create polkit rules for moonraker
moonraker_polkit
### confirm message
if [[ $INSTANCE_COUNT -eq 1 ]]; then
CONFIRM_MSG="Moonraker has been set up!"
elif [[ $INSTANCE_COUNT -gt 1 ]]; then
CONFIRM_MSG="$INSTANCE_COUNT Moonraker instances have been set up!"
fi && print_msg && clear_msg
### display moonraker ips to the user
print_mr_ip_list; echo
}
install_moonraker_packages(){
### read PKGLIST from official install script
status_msg "Reading dependencies..."
install_script="${HOME}/moonraker/scripts/install-moonraker.sh"
PKGLIST=$(grep "PKGLIST=" "$install_script" | sed 's/PKGLIST//g; s/[$"{}=]//g; s/\s\s*/ /g' | tr -d '\n')
for pkg in $PKGLIST; do
echo "${cyan}$pkg${default}"
done
read -r -a PKGLIST <<< "$PKGLIST"
### Update system package info
status_msg "Running apt-get update..."
sudo apt-get update --allow-releaseinfo-change
### Install desired packages
status_msg "Installing packages..."
sudo apt-get install --yes "${PKGLIST[@]}"
}
create_moonraker_virtualenv(){
status_msg "Installing python virtual environment..."
### If venv exists and user prompts a rebuild, then do so
if [ -d "$MOONRAKER_ENV" ] && [ "$REBUILD_ENV" = "y" ]; then
status_msg "Removing old virtualenv"
rm -rf "$MOONRAKER_ENV"
fi
if [ ! -d "$MOONRAKER_ENV" ]; then
virtualenv -p /usr/bin/python3 "$MOONRAKER_ENV"
fi
### Install/update dependencies
"$MOONRAKER_ENV"/bin/pip install -r "$MOONRAKER_DIR"/scripts/moonraker-requirements.txt
}
create_moonraker_service(){
### get config directory
source_kiauh_ini
### set up default values
SINGLE_INST=1
CFG_PATH="$klipper_cfg_loc"
MR_ENV=$MOONRAKER_ENV
MR_DIR=$MOONRAKER_DIR
MR_LOG="${HOME}/klipper_logs/moonraker.log"
MR_CONF="$CFG_PATH/moonraker.conf"
MR_SERV_SRC="${SRCDIR}/kiauh/resources/moonraker.service"
MR_SERV_TARGET="$SYSTEMDDIR/moonraker.service"
write_mr_service(){
if [ ! -f $MR_SERV_TARGET ]; then
status_msg "Creating Moonraker Service $i ..."
sudo cp "$MR_SERV_SRC" $MR_SERV_TARGET
sudo sed -i "s|%INST%|$i|" $MR_SERV_TARGET
sudo sed -i "s|%USER%|${USER}|" $MR_SERV_TARGET
sudo sed -i "s|%MR_ENV%|$MR_ENV|" $MR_SERV_TARGET
sudo sed -i "s|%MR_DIR%|$MR_DIR|" $MR_SERV_TARGET
sudo sed -i "s|%MR_LOG%|$MR_LOG|" $MR_SERV_TARGET
sudo sed -i "s|%MR_CONF%|$MR_CONF|" $MR_SERV_TARGET
fi
}
if [[ $SINGLE_INST -eq $INSTANCE_COUNT ]]; then
### write single instance service
write_mr_service
### enable instance
do_action_service "enable" "moonraker"
ok_msg "Single Moonraker instance created!"
### launching instance
do_action_service "start" "moonraker"
else
i=1
while [[ $i -le $INSTANCE_COUNT ]]; do
### rewrite default variables for multi instance cases
CFG_PATH="$klipper_cfg_loc/printer_$i"
MR_SERV_TARGET="$SYSTEMDDIR/moonraker-$i.service"
MR_CONF="$CFG_PATH/moonraker.conf"
MR_LOG="${HOME}/klipper_logs/moonraker-$i.log"
### write multi instance service
write_mr_service
### enable instance
do_action_service "enable" "moonraker-$i"
ok_msg "Moonraker instance #$i created!"
### launching instance
do_action_service "start" "moonraker-$i"
### raise values by 1
i=$((i+1))
done
unset i
### enable mainsails remoteMode if mainsail is found
if [ -d "$MAINSAIL_DIR" ]; then
status_msg "Mainsail installation found!"
status_msg "Enabling Mainsail remoteMode ..."
enable_mainsail_remotemode
ok_msg "Mainsails remoteMode enabled!"
fi
fi
}
create_moonraker_conf(){
### get config directory
source_kiauh_ini
### set up default values
SINGLE_INST=1
PORT=7125
CFG_PATH="$klipper_cfg_loc"
LOG_PATH="${HOME}/klipper_logs"
MR_CONF="$CFG_PATH/moonraker.conf"
MR_DB="${HOME}/.moonraker_database"
KLIPPY_UDS="/tmp/klippy_uds"
MR_CONF_SRC="${SRCDIR}/kiauh/resources/moonraker.conf"
mr_ip_list=()
IP=$(hostname -I | cut -d" " -f1)
LAN="$(hostname -I | cut -d" " -f1 | cut -d"." -f1-2).0.0/16"
write_mr_conf(){
[ ! -d "$CFG_PATH" ] && mkdir -p "$CFG_PATH"
if [ ! -f "$MR_CONF" ]; then
status_msg "Creating moonraker.conf in $CFG_PATH ..."
cp "$MR_CONF_SRC" "$MR_CONF"
sed -i "s|%PORT%|$PORT|" "$MR_CONF"
sed -i "s|%CFG%|$CFG_PATH|" "$MR_CONF"
sed -i "s|%LOG%|$LOG_PATH|" "$MR_CONF"
sed -i "s|%MR_DB%|$MR_DB|" "$MR_CONF"
sed -i "s|%UDS%|$KLIPPY_UDS|" "$MR_CONF"
# if host ip is not in the default ip ranges, replace placeholder
# otherwise remove placeholder from config
if ! grep -q "$LAN" "$MR_CONF"; then
sed -i "s|%LAN%|$LAN|" "$MR_CONF"
else
sed -i "/%LAN%/d" "$MR_CONF"
fi
sed -i "s|%USER%|${USER}|g" "$MR_CONF"
ok_msg "moonraker.conf created!"
else
warn_msg "There is already a file called 'moonraker.conf'!"
warn_msg "Skipping..."
fi
}
if [[ $SINGLE_INST -eq $INSTANCE_COUNT ]]; then
### write single instance config
write_mr_conf
mr_ip_list+=("$IP:$PORT")
else
i=1
while [[ $i -le $INSTANCE_COUNT ]]; do
### rewrite default variables for multi instance cases
CFG_PATH="$klipper_cfg_loc/printer_$i"
MR_CONF="$CFG_PATH/moonraker.conf"
MR_DB="${HOME}/.moonraker_database_$i"
KLIPPY_UDS="/tmp/klippy_uds-$i"
### write multi instance config
write_mr_conf
mr_ip_list+=("$IP:$PORT")
### raise values by 1
PORT=$((PORT+1))
i=$((i+1))
done
unset PORT && unset i
fi
}
print_mr_ip_list(){
i=1
for ip in "${mr_ip_list[@]}"; do
echo -e " ${cyan}● Instance $i:${default} $ip"
i=$((i + 1))
done
}
### introduced due to
### https://github.com/Arksine/moonraker/issues/349
### https://github.com/Arksine/moonraker/pull/346
moonraker_polkit(){
SYSTEMDDIR="/etc/systemd/system"
MOONRAKER_SERVICES=$(find "$SYSTEMDDIR" -regextype posix-extended -regex "$SYSTEMDDIR/moonraker(-[^0])?[0-9]*.service")
for service in $MOONRAKER_SERVICES; do
HAS_SUPP="$( grep -cm1 "SupplementaryGroups=moonraker-admin" "$service" || true )"
if [ "$HAS_SUPP" -eq 0 ]; then
status_msg "Adding moonraker-admin supplementary group to $service ..."
sudo sed -i "/^Type=simple$/a SupplementaryGroups=moonraker-admin" "$service" \
&& ok_msg "Adding moonraker-admin supplementary group successfull!"
fi
done
### execute moonrakers policykit-rules script
"${HOME}"/moonraker/scripts/set-policykit-rules.sh
sudo systemctl daemon-reload
}

276
scripts/install_octoprint.sh Executable file
View File

@@ -0,0 +1,276 @@
### base variables
SYSTEMDDIR="/etc/systemd/system"
OCTOPRINT_ENV="${HOME}/OctoPrint"
octoprint_setup_dialog(){
status_msg "Initializing OctoPrint installation ..."
### count amount of klipper services
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "klipper.service")" ]; then
INSTANCE_COUNT=1
else
INSTANCE_COUNT=$(systemctl list-units --full -all -t service --no-legend | grep -E "klipper-[[:digit:]].service" | wc -l)
fi
### instance confirmation dialog
while true; do
echo
top_border
if [ $INSTANCE_COUNT -gt 1 ]; then
printf "|%-55s|\n" " $INSTANCE_COUNT Klipper instances were found!"
else
echo -e "| 1 Klipper instance was found! | "
fi
echo -e "| You need one OctoPrint instance per Klipper instance. | "
bottom_border
echo
read -p "${cyan}###### Create $INSTANCE_COUNT OctoPrint instances? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
echo -e "###### > Yes"
status_msg "Creating $INSTANCE_COUNT OctoPrint instances ..."
octoprint_setup
break;;
N|n|No|no)
echo -e "###### > No"
warn_msg "Exiting OctoPrint setup ..."
echo
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
}
octoprint_dependencies(){
dep=(
git
wget
python-pip
python-dev
libyaml-dev
build-essential
python-setuptools
python-virtualenv
)
dependency_check
}
octoprint_setup(){
### check and install all dependencies
octoprint_dependencies
### add user to usergroups and add reboot permissions
add_to_groups
add_reboot_permission
### create and activate the virtualenv
[ ! -d $OCTOPRINT_ENV ] && mkdir -p $OCTOPRINT_ENV
status_msg "Set up virtualenv ..."
cd $OCTOPRINT_ENV
virtualenv --python=python3 venv
source venv/bin/activate
### install octoprint with pip
status_msg "Download and install OctoPrint ..."
pip install pip --upgrade
pip install --no-cache-dir octoprint
ok_msg "Download complete!"
### leave virtualenv
deactivate
### set up instances
INSTANCE=1
if [ $INSTANCE_COUNT -eq $INSTANCE ]; then
create_single_octoprint_instance
else
create_multi_octoprint_instance
fi
}
add_to_groups(){
if [ ! "$(groups | grep tty)" ]; then
status_msg "Adding user '${USER}' to group 'tty' ..."
sudo usermod -a -G tty ${USER} && ok_msg "Done!"
fi
if [ ! "$(groups | grep dialout)" ]; then
status_msg "Adding user '${USER}' to group 'dialout' ..."
sudo usermod -a -G dialout ${USER} && ok_msg "Done!"
fi
}
create_single_octoprint_startscript(){
### create single instance systemd service file
sudo /bin/sh -c "cat > ${SYSTEMDDIR}/octoprint.service" << OCTOPRINT
[Unit]
Description=Starts OctoPrint on startup
After=network-online.target
Wants=network-online.target
[Service]
Environment="LC_ALL=C.UTF-8"
Environment="LANG=C.UTF-8"
Type=simple
User=$USER
ExecStart=${OCTOPRINT_ENV}/venv/bin/octoprint --basedir ${BASEDIR} --config ${CONFIG_YAML} --port=${PORT} serve
[Install]
WantedBy=multi-user.target
OCTOPRINT
}
create_multi_octoprint_startscript(){
### create multi instance systemd service file
sudo /bin/sh -c "cat > ${SYSTEMDDIR}/octoprint-$INSTANCE.service" << OCTOPRINT
[Unit]
Description=Starts OctoPrint instance $INSTANCE on startup
After=network-online.target
Wants=network-online.target
[Service]
Environment="LC_ALL=C.UTF-8"
Environment="LANG=C.UTF-8"
Type=simple
User=$USER
ExecStart=${OCTOPRINT_ENV}/venv/bin/octoprint --basedir ${BASEDIR} --config ${CONFIG_YAML} --port=${PORT} serve
[Install]
WantedBy=multi-user.target
OCTOPRINT
}
create_config_yaml(){
### create multi instance config.yaml file
/bin/sh -c "cat > ${BASEDIR}/config.yaml" << CONFIGYAML
serial:
additionalPorts:
- ${TMP_PRINTER}
disconnectOnErrors: false
port: ${TMP_PRINTER}
server:
commands:
serverRestartCommand: ${RESTART_COMMAND}
systemRestartCommand: sudo shutdown -r now
systemShutdownCommand: sudo shutdown -h now
CONFIGYAML
}
create_single_octoprint_instance(){
status_msg "Setting up 1 OctoPrint instance ..."
### single instance variables
PORT=5000
BASEDIR="${HOME}/.octoprint"
TMP_PRINTER="/tmp/printer"
CONFIG_YAML="$BASEDIR/config.yaml"
RESTART_COMMAND="sudo service octoprint restart"
### declare empty array for ips which get displayed to the user at the end of the setup
HOSTNAME=$(hostname -I | cut -d" " -f1)
op_ip_list=()
### create instance
status_msg "Creating single OctoPrint instance ..."
create_single_octoprint_startscript
op_ip_list+=("$HOSTNAME:$PORT")
### create the config.yaml
if [ ! -f $BASEDIR/config.yaml ]; then
status_msg "Creating config.yaml ..."
[ ! -d $BASEDIR ] && mkdir $BASEDIR
create_config_yaml
ok_msg "Config created!"
fi
### enable instance
sudo systemctl enable octoprint.service
ok_msg "Single OctoPrint instance created!"
### launching instance
status_msg "Launching OctoPrint instance ..."
sudo systemctl start octoprint
### confirm message
CONFIRM_MSG="Single OctoPrint instance has been set up!"
print_msg && clear_msg
### display all octoprint ips to the user
print_op_ip_list; echo
}
create_multi_octoprint_instance(){
status_msg "Setting up $INSTANCE_COUNT instances of OctoPrint ..."
### declare empty array for ips which get displayed to the user at the end of the setup
HOSTNAME=$(hostname -I | cut -d" " -f1)
op_ip_list=()
### default port
PORT=5000
while [ $INSTANCE -le $INSTANCE_COUNT ]; do
### multi instance variables
BASEDIR="${HOME}/.octoprint-$INSTANCE"
TMP_PRINTER="/tmp/printer-$INSTANCE"
CONFIG_YAML="$BASEDIR/config.yaml"
RESTART_COMMAND="sudo service octoprint restart"
### create instance
status_msg "Creating instance #$INSTANCE ..."
create_multi_octoprint_startscript
op_ip_list+=("$HOSTNAME:$PORT")
### create the config.yaml
if [ ! -f $BASEDIR/config.yaml ]; then
status_msg "Creating config.yaml for instance #$INSTANCE..."
[ ! -d $BASEDIR ] && mkdir $BASEDIR
create_config_yaml
ok_msg "Config #$INSTANCE created!"
fi
### enable instance
sudo systemctl enable octoprint-$INSTANCE.service
ok_msg "OctoPrint instance $INSTANCE created!"
### launching instance
status_msg "Launching OctoPrint instance $INSTANCE ..."
sudo systemctl start octoprint-$INSTANCE
### instance counter +1
INSTANCE=$(expr $INSTANCE + 1)
### port +1
PORT=$(expr $PORT + 1)
done
### confirm message
CONFIRM_MSG="$INSTANCE_COUNT OctoPrint instances have been set up!"
print_msg && clear_msg
### display all moonraker ips to the user
print_op_ip_list; echo
}
add_reboot_permission(){
USER=${USER}
#create a backup when file already exists
if [ -f /etc/sudoers.d/octoprint-shutdown ]; then
sudo mv /etc/sudoers.d/octoprint-shutdown /etc/sudoers.d/octoprint-shutdown.old
fi
#create new permission file
status_msg "Add reboot permission to user '$USER' ..."
cd ${HOME} && echo "$USER ALL=NOPASSWD: /sbin/shutdown" > octoprint-shutdown
sudo chown 0 octoprint-shutdown
sudo mv octoprint-shutdown /etc/sudoers.d/octoprint-shutdown
ok_msg "Permission set!"
}
print_op_ip_list(){
i=1
for ip in ${op_ip_list[@]}; do
echo -e " ${cyan}● Instance $i:${default} $ip"
i=$((i + 1))
done
}

View File

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

114
scripts/ms_theme_installer.sh Executable file
View File

@@ -0,0 +1,114 @@
### base variables
SYSTEMDDIR="/etc/systemd/system"
get_theme_list(){
theme_csv_url="https://raw.githubusercontent.com/mainsail-crew/docs/master/_data/themes.csv"
theme_csv=$(curl -s -L $theme_csv_url)
unset t_name
unset t_note
unset t_auth
unset t_url
i=0
while IFS="," read -r col1 col2 col3 col4; do
t_name+=("$col1")
t_note+=("$col2")
t_auth+=("$col3")
t_url+=("$col4")
if [ ! "$col1" == "name" ]; then
printf "| $i) %-50s|\n" "[$col1]"
fi
i=$((i+1))
done <<< "$theme_csv"
}
ms_theme_ui(){
top_border
echo -e "| ${red}~~~~~~~~ [ Mainsail Theme Installer ] ~~~~~~~${default} | "
hr
echo -e "| ${green}A preview of each Mainsail theme can be found here:${default} | "
echo -e "| https://docs.mainsail.xyz/theming/themes | "
blank_line
echo -e "| ${yellow}Important note:${default} | "
echo -e "| Installing a theme from this menu will overwrite an | "
echo -e "| already installed theme or modified custom.css file! | "
hr
get_theme_list # dynamically generate the themelist from a csv file
echo -e "| | "
echo -e "| R) [Remove Theme] | "
back_footer
}
ms_theme_menu(){
ms_theme_ui
while true; do
read -p "${cyan}Install theme:${default} " a; echo
if [ "$a" = "b" ] || [ "$a" = "B" ]; then
clear && advanced_menu && break
elif [ "$a" = "r" ] || [ "$a" = "R" ]; then
ms_theme_delete
ms_theme_menu
elif [ "$a" -le ${#t_url[@]} ]; then
ms_theme_install "${t_auth[$a]}" "${t_url[$a]}" "${t_name[$a]}" "${t_note[$a]}"
ms_theme_menu
else
clear && print_header
ERROR_MSG="Invalid command!" && print_msg && clear_msg
ms_theme_menu
fi
done
ms_theme_menu
}
check_select_printer(){
unset printer_num
### get klipper cfg loc and set default .theme folder loc
check_klipper_cfg_path
THEME_PATH="$klipper_cfg_loc"
### check if there is more than one moonraker instance and if yes
### ask the user to select the printer he wants to install/remove the theme
MR_SERVICE_COUNT=$(find "$SYSTEMDDIR" -regextype posix-extended -regex "$SYSTEMDDIR/moonraker(-[^0])?[0-9]*.service" | wc -l)
if [[ $MR_SERVICE_COUNT -gt 1 ]]; then
top_border
echo -e "| More than one printer was found on this system! | "
echo -e "| Please select the printer to which you want to | "
echo -e "| apply the previously selected action. | "
bottom_border
read -p "${cyan}Select printer:${default} " printer_num
### rewrite the .theme path matching the selected printer
THEME_PATH="$klipper_cfg_loc/printer_$printer_num"
fi
### create the cfg folder if there is none yet
[ ! -d "$THEME_PATH" ] && mkdir -p "$THEME_PATH"
}
ms_theme_install(){
THEME_URL="https://github.com/$1/$2"
### check and select printer if there is more than 1
check_select_printer
### download all files
status_msg "Installing $3 ..."
status_msg "Please wait ..."
[ -d "$THEME_PATH/.theme" ] && rm -rf "$THEME_PATH/.theme"
cd "$THEME_PATH" && git clone "$THEME_URL" ".theme"
ok_msg "Theme installation complete!"
[ -n "$4" ] && echo "${yellow}###### Theme Info: $4${default}"
ok_msg "Please remember to delete your browser cache!\n"
}
ms_theme_delete(){
check_select_printer
if [ -d "$THEME_PATH/.theme" ]; then
status_msg "Removing Theme ..."
rm -rf "$THEME_PATH/.theme" && ok_msg "Theme removed!\n"
else
status_msg "No Theme installed!\n"
fi
}

172
scripts/network_functions.sh Executable file
View File

@@ -0,0 +1,172 @@
set_nginx_cfg(){
if [ "$SET_NGINX_CFG" = "true" ]; then
#check for dependencies
dep=(nginx)
dependency_check
#execute operations
status_msg "Creating Nginx configuration for $1 ..."
#copy content from resources to the respective nginx config file
cat ${SRCDIR}/kiauh/resources/klipper_webui_nginx.cfg > ${SRCDIR}/kiauh/resources/$1
##edit the nginx config file before moving it
sed -i "s/<<UI>>/$1/g" ${SRCDIR}/kiauh/resources/$1
if [ "$SET_LISTEN_PORT" != "$DEFAULT_PORT" ]; then
status_msg "Configuring port for $1 ..."
#set listen port ipv4
sed -i "s/listen\s[0-9]*;/listen $SET_LISTEN_PORT;/" ${SRCDIR}/kiauh/resources/$1
#set listen port ipv6
sed -i "s/listen\s\[\:*\]\:[0-9]*;/listen \[::\]\:$SET_LISTEN_PORT;/" ${SRCDIR}/kiauh/resources/$1
fi
#set correct user
if [ "$1" = "mainsail" ] || [ "$1" = "fluidd" ]; then
sudo sed -i "/root/s/pi/${USER}/" ${SRCDIR}/kiauh/resources/$1
fi
#moving the config file into correct directory
sudo mv ${SRCDIR}/kiauh/resources/$1 /etc/nginx/sites-available/$1
ok_msg "Nginx configuration for $1 was set!"
if [ "$SET_LISTEN_PORT" != "" ]; then
ok_msg "$1 listening on port $SET_LISTEN_PORT!"
else
ok_msg "$1 listening on default port $DEFAULT_PORT!"
fi
#remove nginx default config
[ -e /etc/nginx/sites-enabled/default ] && sudo rm /etc/nginx/sites-enabled/default
#create symlink for own sites
[ ! -e /etc/nginx/sites-enabled/$1 ] && sudo ln -s /etc/nginx/sites-available/$1 /etc/nginx/sites-enabled/
restart_nginx
fi
}
read_listen_port(){
LISTEN_PORT=$(grep listen /etc/nginx/sites-enabled/$1 | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
}
detect_enabled_sites(){
#check if there is another UI config already installed
#and reads the port they are listening on
if [ -e /etc/nginx/sites-enabled/mainsail ]; then
SITE_ENABLED="true" && MAINSAIL_ENABLED="true"
read_listen_port "mainsail"
MAINSAIL_PORT=$LISTEN_PORT
#echo "debug: Mainsail listens on port: $MAINSAIL_PORT"
else
MAINSAIL_ENABLED="false"
fi
if [ -e /etc/nginx/sites-enabled/fluidd ]; then
SITE_ENABLED="true" && FLUIDD_ENABLED="true"
read_listen_port "fluidd"
FLUIDD_PORT=$LISTEN_PORT
#echo "debug: Fluidd listens on port: $FLUIDD_PORT"
else
FLUIDD_ENABLED="false"
fi
if [ -e /etc/nginx/sites-enabled/dwc2 ]; then
SITE_ENABLED="true" && DWC2_ENABLED="true"
read_listen_port "dwc2"
DWC2_PORT=$LISTEN_PORT
#echo "debug: DWC2 listens on port: $DWC2_PORT"
else
DWC2_ENABLED="false"
fi
if [ -e /etc/nginx/sites-enabled/octoprint ]; then
SITE_ENABLED="true" && OCTOPRINT_ENABLED="true"
read_listen_port "octoprint"
OCTOPRINT_PORT=$LISTEN_PORT
#echo "debug: OctoPrint listens on port: $OCTOPRINT_PORT"
else
OCTOPRINT_ENABLED="false"
fi
}
create_custom_hostname(){
echo
top_border
echo -e "| You can change the hostname of this machine to use |"
echo -e "| that name to open the Interface in your browser. |"
echo -e "| |"
echo -e "| E.g.: If you set the hostname to 'my-printer' you |"
echo -e "| can open DWC2/Mainsail/Fluidd/Octoprint by |"
echo -e "| browsing to: http://my-printer.local |"
bottom_border
while true; do
read -p "${cyan}###### Do you want to change the hostname? (y/N):${default} " yn
case "$yn" in
Y|y|Yes|yes)
user_input_hostname
break;;
N|n|No|no|"") break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
}
user_input_hostname(){
unset NEW_HOSTNAME
unset HOSTNAME_VALID
unset HOSTENAME_CONFIRM
echo
top_border
echo -e "| ${green}Allowed characters: a-z, 0-9 and single '-'${default} |"
echo -e "| ${red}No special characters allowed!${default} |"
echo -e "| ${red}No leading or trailing '-' allowed!${default} |"
bottom_border
while true; do
read -p "${cyan}###### Please set the new hostname:${default} " NEW_HOSTNAME
if [[ $NEW_HOSTNAME =~ ^[^\-\_]+([0-9a-z]\-{0,1})+[^\-\_]+$ ]]; then
ok_msg "'$NEW_HOSTNAME' is a valid hostname!"
HOSTNAME_VALID="true"
while true; do
echo
read -p "${cyan}###### Do you want '$NEW_HOSTNAME' to be the new hostname? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
echo -e "###### > Yes"
HOSTENAME_CONFIRM="true"
break;;
N|n|No|no)
echo -e "###### > No"
echo -e "${red}Skip hostname change ...${default}"
HOSTENAME_CONFIRM="false"
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
break
else
warn_msg "'$NEW_HOSTNAME' is not a valid hostname!"
fi
done
}
set_hostname(){
if [ "$HOSTNAME_VALID" = "true" ] && [ "$HOSTENAME_CONFIRM" = "true" ]; then
#check for dependencies
dep=(avahi-daemon)
dependency_check
#execute operations
#get current hostname and write to variable
HOSTNAME=$(hostname)
#create host file if missing or create backup of existing one with current date&time
if [ -f /etc/hosts ]; then
status_msg "Creating backup of hosts file ..."
get_date
sudo cp /etc/hosts /etc/hosts."$current_date".bak
ok_msg "Backup done!"
ok_msg "File:'/etc/hosts."$current_date".bak'"
else
sudo touch /etc/hosts
fi
#set hostname in /etc/hostname
status_msg "Setting hostname to '$NEW_HOSTNAME' ..."
status_msg "Please wait ..."
sudo hostnamectl set-hostname "$NEW_HOSTNAME"
#write new hostname to /etc/hosts
status_msg "Writing new hostname to /etc/hosts ..."
echo "127.0.0.1 $NEW_HOSTNAME" | sudo tee -a /etc/hosts &>/dev/null
ok_msg "New hostname successfully configured!"
ok_msg "Remember to reboot for the changes to take effect!"
fi
}

645
scripts/remove.sh Normal file → Executable file
View File

@@ -1,145 +1,510 @@
### base variables
SYSTEMDDIR="/etc/systemd/system"
remove_klipper(){
data_arr=(
/etc/init.d/klipper
/etc/default/klipper
$KLIPPER_DIR
$KLIPPY_ENV_DIR
${HOME}/klippy.log
)
print_error "Klipper" && data_count=()
if [ "$ERROR_MSG" = "" ]; then
stop_klipper
if [[ -e /etc/init.d/klipper || -e /etc/default/klipper ]]; then
status_msg "Removing klipper service ..."
sudo update-rc.d -f klipper remove
sudo rm -rf /etc/init.d/klipper /etc/default/klipper && ok_msg "Klipper service removed!"
fi
if [[ -d $KLIPPER_DIR || -d $KLIPPY_ENV_DIR ]]; then
status_msg "Removing klipper and klippy-env diretory ..."
rm -rf $KLIPPER_DIR $KLIPPY_ENV_DIR && ok_msg "Directories removed!"
fi
if [[ -L ${HOME}/klippy.log || -e /tmp/klippy.log ]]; then
status_msg "Removing klippy.log symlink ..."
rm -rf ${HOME}/klippy.log /tmp/klippy.log && ok_msg "Symlink removed!"
fi
ok_msg "Klipper successfully removed!"
fi
}
remove_dwc2(){
data_arr=(
$DWC2FK_DIR
$TORNADO_DIR1
$TORNADO_DIR2
$WEB_DWC2
$DWC2_DIR
)
print_error "DWC2-for-Klipper &\n DWC2 Web UI" && data_count=()
if [ "$ERROR_MSG" = "" ]; then
if [ -d $DWC2FK_DIR ]; then
status_msg "Removing dwc2-for-klipper directory ..."
rm -rf $DWC2FK_DIR && ok_msg "Directory removed!"
fi
if [ -d $TORNADO_DIR1 ]; then
status_msg "Removing tornado from klippy-env ..."
rm -rf $TORNADO_DIR1 $TORNADO_DIR2 && ok_msg "Tornado removed!"
fi
if [ -e $WEB_DWC2 ]; then
status_msg "Removing web_dwc2.py symlink from klippy ..."
rm -rf $WEB_DWC2 && ok_msg "File removed!"
fi
if [ -d $DWC2_DIR ]; then
status_msg "Removing dwc2 directory ..."
rm -rf $DWC2_DIR && ok_msg "Directory removed!"
fi
ok_msg "DWC2-for-Klipper & DWC2 Web UI successfully removed!"
fi
}
remove_mainsail(){
data_arr=(
$MAINSAIL_SERVICE1
$MAINSAIL_SERVICE2
$MAINSAIL_DIR
${HOME}/moonraker.log
${HOME}/.klippy_api_key
${HOME}/.moonraker_api_key
${HOME}/moonraker-env
/etc/nginx/sites-available/mainsail
/etc/nginx/sites-enabled/mainsail
/etc/init.d/nginx
/etc/default/nginx
)
print_error "Mainsail" && data_count=()
if [ "$ERROR_MSG" = "" ]; then
stop_moonraker
#remove moonraker services
if [[ -e /etc/init.d/moonraker || -e /etc/default/moonraker ]]; then
status_msg "Removing moonraker service ..."
sudo update-rc.d -f moonraker remove
sudo rm -rf /etc/init.d/moonraker /etc/default/moonraker && ok_msg "Moonraker service removed!"
fi
#remove mainsail dir
if [ -d $MAINSAIL_DIR ]; then
status_msg "Removing mainsail directory ..."
rm -rf $MAINSAIL_DIR && ok_msg "Directory removed!"
fi
#remove moonraker-env
if [ -d ${HOME}/moonraker-env ]; then
status_msg "Removing moonraker virtualenv ..."
rm -rf ${HOME}/moonraker-env && ok_msg "Directory removed!"
fi
#remove moonraker.log symlink
if [[ -L ${HOME}/moonraker.log || -e /tmp/moonraker.log ]]; then
status_msg "Removing moonraker.log symlink ..."
rm -rf ${HOME}/moonraker.log /tmp/moonraker.log && ok_msg "Symlink removed!"
fi
#remove mainsail cfg
if [ -e /etc/nginx/sites-available/mainsail ]; then
status_msg "Removing mainsail configuration for nginx ..."
sudo rm /etc/nginx/sites-available/mainsail && ok_msg "File removed!"
fi
#remove mainsail symlink
if [ -L /etc/nginx/sites-enabled/mainsail ]; then
status_msg "Removing mainsail symlink for nginx ..."
sudo rm /etc/nginx/sites-enabled/mainsail && ok_msg "File removed!"
fi
#remove legacy api key
if [ -e ${HOME}/.klippy_api_key ]; then
status_msg "Removing legacy API Key ..."
rm ${HOME}/.klippy_api_key && ok_msg "Done!"
fi
#remove api key
if [ -e ${HOME}/.moonraker_api_key ]; then
status_msg "Removing API Key ..."
rm ${HOME}/.moonraker_api_key && ok_msg "Done!"
fi
remove_nginx
ok_msg "Mainsail successfully removed!"
fi
}
remove_nginx(){
#ask for complete removal of nginx if installed
if [[ $(dpkg-query -f'${Status}' --show nginx 2>/dev/null) = *\ installed ]] ; then
shopt -s extglob # enable extended globbing
### ask the user if he wants to uninstall moonraker too.
###? currently usefull if the user wants to switch from single-instance to multi-instance
FILE="$SYSTEMDDIR/moonraker?(-*([0-9])).service"
if ls $FILE 2>/dev/null 1>&2; then
while true; do
echo
read -p "Do you want to completely remove (purge) nginx? (Y/n): " yn
unset REM_MR
top_border
echo -e "| Do you want to remove Moonraker afterwards? |"
echo -e "| |"
echo -e "| This is useful in case you want to switch from a |"
echo -e "| single-instance to a multi-instance installation, |"
echo -e "| which makes a re-installation of Moonraker necessary. |"
echo -e "| |"
echo -e "| If for any other reason you only want to uninstall |"
echo -e "| Klipper, please select 'No' and continue. |"
bottom_border
read -p "${cyan}###### Remove Moonraker afterwards? (y/N):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
status_msg "Stopping and removing nginx service ..."
if [ -e /etc/init.d/nginx ]; then
sudo /etc/init.d/nginx stop && ok_msg "Nginx service stopped!"
sudo rm /etc/init.d/nginx && ok_msg "Nginx service removed!"
fi
if [ -e /etc/default/nginx ]; then
sudo rm /etc/default/nginx
fi
status_msg "Purging nginx from system ..."
sudo apt-get purge nginx nginx-common -y && ok_msg "Nginx removed!"
break;;
N|n|No|no) break;;
esac
Y|y|Yes|yes)
echo -e "###### > Yes"
REM_MR="true"
break;;
N|n|No|no|"")
echo -e "###### > No"
REM_MR="false"
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
fi
}
### remove "legacy" klipper init.d service
if [ -e /etc/init.d/klipper ]; then
status_msg "Removing Klipper Service ..."
sudo systemctl stop klipper
sudo update-rc.d -f klipper remove
sudo rm -f /etc/init.d/klipper
sudo rm -f /etc/default/klipper
ok_msg "Klipper Service removed!"
fi
### remove all klipper services
FILE="$SYSTEMDDIR/klipper?(-*([0-9])).service"
if ls $FILE 2>/dev/null 1>&2; then
status_msg "Removing Klipper Services ..."
for service in $(ls $FILE | cut -d"/" -f5)
do
status_msg "Removing $service ..."
sudo systemctl stop $service
sudo systemctl disable $service
sudo rm -f $SYSTEMDDIR/$service
ok_msg "Done!"
done
### reloading units
sudo systemctl daemon-reload
sudo systemctl reset-failed
ok_msg "Klipper Service removed!"
fi
### remove all logfiles
FILE="${HOME}/klipper_logs/klippy?(-*([0-9])).log"
if ls $FILE 2>/dev/null 1>&2; then
for log in $(ls $FILE); do
status_msg "Removing $log ..."
rm -f $log
ok_msg "$log removed!"
done
fi
### remove all UDS
FILE="/tmp/klippy_uds?(-*([0-9]))"
if ls $FILE 2>/dev/null 1>&2; then
for uds in $(ls $FILE); do
status_msg "Removing $uds ..."
rm -f $uds
ok_msg "$uds removed!"
done
fi
### remove all tmp-printer
FILE="/tmp/printer?(-*([0-9]))"
if ls $FILE 2>/dev/null 1>&2; then
for tmp_printer in $(ls $FILE); do
status_msg "Removing $tmp_printer ..."
rm -f $tmp_printer
ok_msg "$tmp_printer removed!"
done
fi
### removing klipper and klippy-env folders
if [ -d $KLIPPER_DIR ]; then
status_msg "Removing Klipper directory ..."
rm -rf $KLIPPER_DIR && ok_msg "Directory removed!"
fi
if [ -d $KLIPPY_ENV ]; then
status_msg "Removing klippy-env directory ..."
rm -rf $KLIPPY_ENV && ok_msg "Directory removed!"
fi
CONFIRM_MSG=" Klipper was successfully removed!" && print_msg && clear_msg
shopt -u extglob # enable extended globbing
if [ "$REM_MR" == "true" ]; then
remove_moonraker && unset REM_MR
fi
}
#############################################################
#############################################################
remove_moonraker(){
shopt -s extglob # enable extended globbing
### remove "legacy" moonraker init.d service
if [ -f /etc/init.d/moonraker ]; then
status_msg "Removing Moonraker Service ..."
sudo systemctl stop moonraker
sudo update-rc.d -f moonraker remove
sudo rm -f /etc/init.d/moonraker
sudo rm -f /etc/default/moonraker
ok_msg "Moonraker Service removed!"
fi
### remove all moonraker services
FILE="$SYSTEMDDIR/moonraker?(-*([0-9])).service"
if ls $FILE 2>/dev/null 1>&2; then
status_msg "Removing Moonraker Services ..."
for service in $(ls $FILE | cut -d"/" -f5)
do
status_msg "Removing $service ..."
sudo systemctl stop $service
sudo systemctl disable $service
sudo rm -f $SYSTEMDDIR/$service
ok_msg "Done!"
done
### reloading units
sudo systemctl daemon-reload
sudo systemctl reset-failed
ok_msg "Moonraker Service removed!"
fi
### remove all logfiles
FILE="${HOME}/klipper_logs/moonraker?(-*([0-9])).log"
if ls $FILE 2>/dev/null 1>&2; then
for log in $(ls $FILE); do
status_msg "Removing $log ..."
rm -f $log
ok_msg "$log removed!"
done
fi
### remove moonraker nginx config
if [[ -e $NGINX_CONFD/upstreams.conf || -e $NGINX_CONFD/common_vars.conf ]]; then
status_msg "Removing Moonraker NGINX configuration ..."
sudo rm -f $NGINX_CONFD/upstreams.conf $NGINX_CONFD/common_vars.conf && ok_msg "Moonraker NGINX configuration removed!"
fi
### remove legacy api key
if [ -e ${HOME}/.klippy_api_key ]; then
status_msg "Removing legacy API Key ..." && rm ${HOME}/.klippy_api_key && ok_msg "Done!"
fi
### remove api key
if [ -e ${HOME}/.moonraker_api_key ]; then
status_msg "Removing API Key ..." && rm ${HOME}/.moonraker_api_key && ok_msg "Done!"
fi
### removing moonraker and moonraker-env folder
if [ -d $MOONRAKER_DIR ]; then
status_msg "Removing Moonraker directory ..."
rm -rf $MOONRAKER_DIR && ok_msg "Directory removed!"
fi
if [ -d $MOONRAKER_ENV ]; then
status_msg "Removing moonraker-env directory ..."
rm -rf $MOONRAKER_ENV && ok_msg "Directory removed!"
fi
CONFIRM_MSG=" Moonraker was successfully removed!"
shopt -u extglob # disable extended globbing
}
#############################################################
#############################################################
remove_dwc2(){
### remove "legacy" init.d service
if [ -e /etc/init.d/dwc ]; then
status_msg "Removing DWC2-for-Klipper-Socket Service ..."
sudo systemctl stop dwc
sudo update-rc.d -f dwc remove
sudo rm -f /etc/init.d/dwc
sudo rm -f /etc/default/dwc
ok_msg "DWC2-for-Klipper-Socket Service removed!"
fi
### remove all dwc services
if ls /etc/systemd/system/dwc*.service 2>/dev/null 1>&2; then
status_msg "Removing DWC2-for-Klipper-Socket Services ..."
for service in $(ls /etc/systemd/system/dwc*.service | cut -d"/" -f5)
do
status_msg "Removing $service ..."
sudo systemctl stop $service
sudo systemctl disable $service
sudo rm -f $SYSTEMDDIR/$service
ok_msg "Done!"
done
### reloading units
sudo systemctl daemon-reload
sudo systemctl reset-failed
ok_msg "DWC2-for-Klipper-Socket Service removed!"
fi
### remove all logfiles
if ls /tmp/dwc*.log 2>/dev/null 1>&2; then
for logfile in $(ls /tmp/dwc*.log)
do
status_msg "Removing $logfile ..."
rm -f $logfile
ok_msg "File '$logfile' removed!"
done
fi
### removing the rest of the folders
if [ -d $DWC2FK_DIR ]; then
status_msg "Removing DWC2-for-Klipper-Socket directory ..."
rm -rf $DWC2FK_DIR && ok_msg "Directory removed!"
fi
if [ -d $DWC_ENV_DIR ]; then
status_msg "Removing DWC2-for-Klipper-Socket virtualenv ..."
rm -rf $DWC_ENV_DIR && ok_msg "Directory removed!"
fi
if [ -d $DWC2_DIR ]; then
status_msg "Removing DWC2 directory ..."
rm -rf $DWC2_DIR && ok_msg "Directory removed!"
fi
### remove dwc2_port from ~/.kiauh.ini
sed -i "/^dwc2_port=/d" $INI_FILE
CONFIRM_MSG=" DWC2-for-Klipper-Socket was successfully removed!"
}
#############################################################
#############################################################
remove_mainsail(){
### remove mainsail dir
if [ -d $MAINSAIL_DIR ]; then
status_msg "Removing Mainsail directory ..."
rm -rf $MAINSAIL_DIR && ok_msg "Directory removed!"
fi
### remove mainsail config for nginx
if [ -e /etc/nginx/sites-available/mainsail ]; then
status_msg "Removing Mainsail configuration for Nginx ..."
sudo rm /etc/nginx/sites-available/mainsail && ok_msg "File removed!"
fi
### remove mainsail symlink for nginx
if [ -L /etc/nginx/sites-enabled/mainsail ]; then
status_msg "Removing Mainsail Symlink for Nginx ..."
sudo rm /etc/nginx/sites-enabled/mainsail && ok_msg "File removed!"
fi
### remove mainsail nginx logs and log symlinks
for log in $(find /var/log/nginx -name "mainsail*"); do
sudo rm -f $log
done
for log in $(find ${HOME}/klipper_logs -name "mainsail*"); do
rm -f $log
done
### remove mainsail_port from ~/.kiauh.ini
sed -i "/^mainsail_port=/d" $INI_FILE
CONFIRM_MSG="Mainsail successfully removed!"
}
remove_fluidd(){
### remove fluidd dir
if [ -d $FLUIDD_DIR ]; then
status_msg "Removing Fluidd directory ..."
rm -rf $FLUIDD_DIR && ok_msg "Directory removed!"
fi
### remove fluidd config for nginx
if [ -e /etc/nginx/sites-available/fluidd ]; then
status_msg "Removing Fluidd configuration for Nginx ..."
sudo rm /etc/nginx/sites-available/fluidd && ok_msg "File removed!"
fi
### remove fluidd symlink for nginx
if [ -L /etc/nginx/sites-enabled/fluidd ]; then
status_msg "Removing Fluidd Symlink for Nginx ..."
sudo rm /etc/nginx/sites-enabled/fluidd && ok_msg "File removed!"
fi
### remove mainsail nginx logs and log symlinks
for log in $(find /var/log/nginx -name "fluidd*"); do
sudo rm -f $log
done
for log in $(find ${HOME}/klipper_logs -name "fluidd*"); do
rm -f $log
done
### remove fluidd_port from ~/.kiauh.ini
sed -i "/^fluidd_port=/d" $INI_FILE
CONFIRM_MSG="Fluidd successfully removed!"
}
#############################################################
#############################################################
remove_octoprint(){
###remove all octoprint services
if ls /etc/systemd/system/octoprint*.service 2>/dev/null 1>&2; then
status_msg "Removing OctoPrint Services ..."
for service in $(ls /etc/systemd/system/octoprint*.service | cut -d"/" -f5)
do
status_msg "Removing $service ..."
sudo systemctl stop $service
sudo systemctl disable $service
sudo rm -f $SYSTEMDDIR/$service
ok_msg "OctoPrint Service removed!"
done
### reloading units
sudo systemctl daemon-reload
sudo systemctl reset-failed
fi
### remove sudoers file
if [ -f /etc/sudoers.d/octoprint-shutdown ]; then
sudo rm -rf /etc/sudoers.d/octoprint-shutdown
fi
### remove OctoPrint directory
if [ -d ${HOME}/OctoPrint ]; then
status_msg "Removing OctoPrint directory ..."
rm -rf ${HOME}/OctoPrint && ok_msg "Directory removed!"
fi
###remove .octoprint directories
if ls -d ${HOME}/.octoprint* 2>/dev/null 1>&2; then
for folder in $(ls -d ${HOME}/.octoprint*)
do
status_msg "Removing $folder ..." && rm -rf $folder && ok_msg "Done!"
done
fi
### remove octoprint_port from ~/.kiauh.ini
sed -i "/^octoprint_port=/d" $INI_FILE
CONFIRM_MSG=" OctoPrint successfully removed!"
}
#############################################################
#############################################################
remove_nginx(){
if ls /lib/systemd/system/nginx.service 2>/dev/null 1>&2; then
status_msg "Stopping Nginx service ..."
sudo systemctl stop nginx && sudo systemctl disable nginx
ok_msg "Service stopped and disabled!"
status_msg "Purging Nginx from system ..."
sudo apt-get purge nginx nginx-common -y
sudo update-rc.d -f nginx remove
CONFIRM_MSG=" Nginx successfully removed!"
else
ERROR_MSG=" Looks like Nginx was already removed!\n Skipping..."
fi
}
remove_klipperscreen(){
source_kiauh_ini
### remove KlipperScreen dir
if [ -d $KLIPPERSCREEN_DIR ]; then
status_msg "Removing KlipperScreen directory ..."
rm -rf $KLIPPERSCREEN_DIR && ok_msg "Directory removed!"
fi
### remove KlipperScreen VENV dir
if [ -d $KLIPPERSCREEN_ENV_DIR ]; then
status_msg "Removing KlipperScreen VENV directory ..."
rm -rf $KLIPPERSCREEN_ENV_DIR && ok_msg "Directory removed!"
fi
### remove KlipperScreen service
if [ -e /etc/systemd/system/KlipperScreen.service ]; then
status_msg "Removing KlipperScreen service ..."
sudo systemctl stop KlipperScreen
sudo systemctl disable KlipperScreen
sudo rm -f $SYSTEMDDIR/KlipperScreen.service
###reloading units
sudo systemctl daemon-reload
sudo systemctl reset-failed
ok_msg "KlipperScreen Service removed!"
fi
### remove KlipperScreen log
if [ -e /tmp/KlipperScreen.log ]; then
status_msg "Removing KlipperScreen log file ..."
rm -f /tmp/KlipperScreen.log && ok_msg "File removed!"
fi
### remove KlipperScreen log symlink in config dir
if [ -e $klipper_cfg_loc/KlipperScreen.log ]; then
status_msg "Removing KlipperScreen log symlink ..."
rm -f $klipper_cfg_loc/KlipperScreen.log && ok_msg "File removed!"
fi
CONFIRM_MSG="KlipperScreen successfully removed!"
}
remove_MoonrakerTelegramBot(){
source_kiauh_ini
### remove MoonrakerTelegramBot dir
if [ -d $MOONRAKER_TELEGRAM_BOT_DIR ]; then
status_msg "Removing MoonrakerTelegramBot directory ..."
rm -rf $MOONRAKER_TELEGRAM_BOT_DIR && ok_msg "Directory removed!"
fi
### remove MoonrakerTelegramBot VENV dir
if [ -d $MOONRAKER_TELEGRAM_BOT_ENV_DIR ]; then
status_msg "Removing MoonrakerTelegramBot VENV directory ..."
rm -rf $MOONRAKER_TELEGRAM_BOT_ENV_DIR && ok_msg "Directory removed!"
fi
### remove MoonrakerTelegramBot service
if [ -e /etc/systemd/system/moonraker-telegram-bot.service ]; then
status_msg "Removing MoonrakerTelegramBot service ..."
sudo systemctl stop moonraker-telegram-bot
sudo systemctl disable moonraker-telegram-bot
sudo rm -f $SYSTEMDDIR/moonraker-telegram-bot.service
###reloading units
sudo systemctl daemon-reload
sudo systemctl reset-failed
ok_msg "MoonrakerTelegramBot Service removed!"
fi
### remove MoonrakerTelegramBot log
if [ -e /tmp/telegram.log ] || [ -e ${HOME}/klipper_logs/telegram.log ]; then
status_msg "Removing MoonrakerTelegramBot log file ..."
rm -f "/tmp/telegram.log" "${HOME}/klipper_logs/telegram.log" && ok_msg "File removed!"
fi
### remove MoonrakerTelegramBot log symlink in config dir
if [ -e $klipper_cfg_loc/telegram.log ]; then
status_msg "Removing MoonrakerTelegramBot log symlink ..."
rm -f $klipper_cfg_loc/telegram.log && ok_msg "File removed!"
fi
CONFIRM_MSG="MoonrakerTelegramBot successfully removed!"
}
remove_mjpg-streamer(){
### remove MJPG-Streamer service
if [ -e $SYSTEMDDIR/webcamd.service ]; then
status_msg "Removing MJPG-Streamer service ..."
sudo systemctl stop webcamd && sudo systemctl disable webcamd
sudo rm -f $SYSTEMDDIR/webcamd.service
###reloading units
sudo systemctl daemon-reload
sudo systemctl reset-failed
ok_msg "MJPG-Streamer Service removed!"
fi
### remove webcamd from /usr/local/bin
if [ -e "/usr/local/bin/webcamd" ]; then
sudo rm -f "/usr/local/bin/webcamd"
fi
### remove MJPG-Streamer directory
if [ -d ${HOME}/mjpg-streamer ]; then
status_msg "Removing MJPG-Streamer directory ..."
rm -rf ${HOME}/mjpg-streamer
ok_msg "MJPG-Streamer directory removed!"
fi
### remove webcamd log and symlink
[ -f "/var/log/webcamd.log" ] && sudo rm -f "/var/log/webcamd.log"
[ -L "${HOME}/klipper_logs/webcamd.log" ] && rm -f "${HOME}/klipper_logs/webcamd.log"
CONFIRM_MSG="MJPG-Streamer successfully removed!"
}
remove_prettygcode(){
pgconf="/etc/nginx/sites-available/pgcode.local.conf"
pgconfsl="/etc/nginx/sites-enabled/pgcode.local.conf"
if [ -d ${HOME}/pgcode ] || [ -f $pgconf ] || [ -L $pgconfsl ]; then
status_msg "Removing PrettyGCode for Klipper ..."
rm -rf ${HOME}/pgcode
sudo rm -f $pgconf
sudo rm -f $pgconfsl
sudo systemctl restart nginx
CONFIRM_MSG="PrettyGCode for Klipper successfully removed!"
else
ERROR_MSG="PrettyGCode for Klipper not found!\n Skipping..."
fi
}

111
scripts/rollback.sh Executable file
View File

@@ -0,0 +1,111 @@
save_klipper_state(){
source_kiauh_ini
#read current klipper state
cd $KLIPPER_DIR
COMMIT_STATE=$(git rev-parse --short HEAD)
if [ "$GET_BRANCH" = "master" ]; then
ORI_OLD=$previous_origin_state
ORI_NEW=$COMMIT_STATE
sed -i "/previous_origin_state=/s/$ORI_OLD/$ORI_NEW/" $INI_FILE
elif [ "$GET_BRANCH" = "scurve-shaping" ]; then
SHA_OLD=$previous_shaping_state
SHA_NEW=$COMMIT_STATE
sed -i "/previous_shaping_state=/s/$SHA_OLD/$SHA_NEW/" $INI_FILE
elif [ "$GET_BRANCH" = "scurve-smoothing" ]; then
SMO_OLD=$previous_smoothing_state
SMO_NEW=$COMMIT_STATE
sed -i "/previous_smoothing_state=/s/$SMO_OLD/$SMO_NEW/" $INI_FILE
fi
}
load_klipper_state(){
source_kiauh_ini
print_branch
cd $KLIPPER_DIR
CURRENT_COMMIT=$(git rev-parse --short=8 HEAD)
if [ "$GET_BRANCH" = "origin/master" ] || [ "$GET_BRANCH" = "master" ]; then
PREVIOUS_COMMIT=$previous_origin_state
elif [ "$GET_BRANCH" = "scurve-shaping" ]; then
PREVIOUS_COMMIT=$previous_shaping_state
elif [ "$GET_BRANCH" = "scurve-smoothing" ]; then
PREVIOUS_COMMIT=$previous_smoothing_state
fi
CURRENT_COMMIT_DATE=$(git show -s --format=%cd --date=short $CURRENT_COMMIT)
if [ "$PREVIOUS_COMMIT" != "0" ]; then
PREVIOUS_COMMIT_DATE=$(git show -s --format=%cd --date=short $PREVIOUS_COMMIT)
fi
if [ "$PREVIOUS_COMMIT" = "0" ]; then
CURR_UI=$(echo -e "${green}$CURRENT_COMMIT from $CURRENT_COMMIT_DATE${default}")
PREV_UI=$(echo -e "${red}None${default} ")
else
if [ "$CURRENT_COMMIT" = "$PREVIOUS_COMMIT" ]; then
CURR_UI=$(echo -e "${green}$CURRENT_COMMIT from $CURRENT_COMMIT_DATE${default}")
PREV_UI=$(echo -e "${green}$PREVIOUS_COMMIT from $PREVIOUS_COMMIT_DATE${default}")
else
CURR_UI=$(echo -e "${yellow}$CURRENT_COMMIT from $CURRENT_COMMIT_DATE${default}")
PREV_UI=$(echo -e "${yellow}$PREVIOUS_COMMIT from $PREVIOUS_COMMIT_DATE${default}")
fi
fi
rollback_ui
rollback_klipper
}
rollback_ui(){
top_border
echo -e "| $(title_msg "~~~~~~~~~~~~~ [ Rollback Menu ] ~~~~~~~~~~~~~") | "
hr
echo -e "| If serious errors occured after updating Klipper, | "
echo -e "| you can use this menu to return to the previously | "
echo -e "| used commit from which you have updated. | "
bottom_border
top_border
echo -e "| Active branch: ${green}$PRINT_BRANCH${default} | "
hr
echo -e "| Currently on commit: | "
echo -e "| $CURR_UI | "
hr
echo -e "| Commit last updated from: | "
echo -e "| $PREV_UI | "
back_footer
}
rollback_klipper(){
if [ "$PREVIOUS_COMMIT" != "0" ] && [ "$CURRENT_COMMIT" != "$PREVIOUS_COMMIT" ]; then
while true; do
echo -e "${cyan}"
read -p "###### Do you want to rollback to $PREVIOUS_COMMIT? (Y/n): " yn
echo -e "${default}"
case "$yn" in
Y|y|Yes|yes|"")
clear
print_header
status_msg "Rolling back to $PREVIOUS_COMMIT ..."
git reset --hard $PREVIOUS_COMMIT -q
ok_msg "Rollback complete!"; echo
load_klipper_state
break;;
N|n|No|no) clear; advanced_menu; break;;
B|b) clear; advanced_menu; break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
else
while true; do
echo -e "${cyan}"
read -p "Perform action: " action; echo
echo -e "${default}"
case "$action" in
B|b)
clear; advanced_menu; break;;
*)
clear
print_header
print_unkown_cmd
print_msg && clear_msg
rollback_ui;;
esac
done
fi
}

602
scripts/status.sh Normal file → Executable file
View File

@@ -1,65 +1,134 @@
kiauh_status(){
if [ -d "${SRCDIR}/kiauh/.git" ]; then
cd ${SRCDIR}/kiauh
if git branch -a | grep "* master" -q; then
git fetch -q
if [[ "$(git rev-parse --short=8 origin/master)" != "$(git rev-parse --short=8 HEAD)" ]]; then
KIAUH_UPDATE_AVAIL="true"
fi
fi
fi
}
check_system_updates(){
SYS_UPDATE=$(apt list --upgradeable 2>/dev/null | sed "1d")
if [ ! -z "$SYS_UPDATE" ]; then
# add system updates to the update all array for the update all function in the updater
SYS_UPDATE_AVAIL="true" && update_arr+=(update_system)
DISPLAY_SYS_UPDATE="${yellow}System upgrade available!${default}"
else
SYS_UPDATE_AVAIL="false"
DISPLAY_SYS_UPDATE="${green}System up to date! ${default}"
fi
}
klipper_status(){
kcount=0
klipper_data=(
SERVICE
$KLIPPER_DIR
$KLIPPY_ENV_DIR
$KLIPPER_SERVICE1
$KLIPPER_SERVICE2
)
#count+1 for each found data-item from array
### count amount of klipper service files in /etc/systemd/system
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "^klipper(\-[[:digit:]]+)?\.service$" | wc -l)
### a fix to detect an existing "legacy" klipper init.d installation
if [ -f /etc/init.d/klipper ] && [ -f /etc/init.d/klipper ]; then
SERVICE_FILE_COUNT=1
fi
### remove the "SERVICE" entry from the klipper_data array if a klipper service is installed
[ $SERVICE_FILE_COUNT -gt 0 ] && unset klipper_data[0]
### count+1 for each found data-item from array
for kd in "${klipper_data[@]}"
do
if [ -e $kd ]; then
kcount=$(expr $kcount + 1)
fi
done
### display status
if [ "$kcount" == "${#klipper_data[*]}" ]; then
KLIPPER_STATUS="${green}Installed!${default} "
KLIPPER_STATUS="$(printf "${green}Installed: %-5s${default}" $SERVICE_FILE_COUNT)"
elif [ "$kcount" == 0 ]; then
KLIPPER_STATUS="${red}Not installed!${default} "
KLIPPER_STATUS="${red}Not installed!${default} "
else
KLIPPER_STATUS="${yellow}Incomplete!${default} "
KLIPPER_STATUS="${yellow}Incomplete!${default} "
fi
}
dwc2_status(){
dcount=0
dwc2_data=(
$DWC2FK_DIR
$WEB_DWC2
dwc_data=(
SERVICE
$DWC2_DIR
$TORNADO_DIR1
$TORNADO_DIR2
$DWC2FK_DIR
$DWC_ENV_DIR
)
### count amount of dwc service files in /etc/systemd/system
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "^dwc(\-[[:digit:]]+)?\.service$" | wc -l)
### remove the "SERVICE" entry from the dwc_data array if a dwc service is installed
[ $SERVICE_FILE_COUNT -gt 0 ] && unset dwc_data[0]
#count+1 for each found data-item from array
for dd in "${dwc2_data[@]}"
for dd in "${dwc_data[@]}"
do
if [ -e $dd ]; then
dcount=$(expr $dcount + 1)
fi
done
if [ "$dcount" == "${#dwc2_data[*]}" ]; then
DWC2_STATUS="${green}Installed!${default} "
if [ "$dcount" == "${#dwc_data[*]}" ]; then
DWC2_STATUS="$(printf "${green}Installed: %-5s${default}" $SERVICE_FILE_COUNT)"
elif [ "$dcount" == 0 ]; then
DWC2_STATUS="${red}Not installed!${default} "
DWC2_STATUS="${red}Not installed!${default} "
else
DWC2_STATUS="${yellow}Incomplete!${default} "
DWC2_STATUS="${yellow}Incomplete!${default} "
fi
}
moonraker_status(){
mrcount=0
moonraker_data=(
SERVICE
$MOONRAKER_DIR
$MOONRAKER_ENV_DIR
)
### count amount of moonraker service files in /etc/systemd/system
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "^moonraker(\-[[:digit:]]+)?\.service$" | wc -l)
### remove the "SERVICE" entry from the moonraker_data array if a moonraker service is installed
[ $SERVICE_FILE_COUNT -gt 0 ] && unset moonraker_data[0]
### count+1 for each found data-item from array
for mrd in "${moonraker_data[@]}"
do
if [ -e $mrd ]; then
mrcount=$(expr $mrcount + 1)
fi
done
### display status
if [ "$mrcount" == "${#moonraker_data[*]}" ]; then
MOONRAKER_STATUS="$(printf "${green}Installed: %-5s${default}" $SERVICE_FILE_COUNT)"
elif [ "$mrcount" == 0 ]; then
MOONRAKER_STATUS="${red}Not installed!${default} "
else
MOONRAKER_STATUS="${yellow}Incomplete!${default} "
fi
}
mainsail_status(){
mcount=0
mainsail_data=(
$MAINSAIL_SERVICE1
$MAINSAIL_SERVICE2
$MAINSAIL_DIR
#${HOME}/.klippy_api_key
#${HOME}/.moonraker_api_key
#${HOME}/moonraker-env
/etc/nginx/sites-available/mainsail
/etc/nginx/sites-enabled/mainsail
/etc/init.d/nginx
/etc/default/nginx
$NGINX_SA/mainsail
$NGINX_SE/mainsail
)
#count+1 for each found data-item from array
for md in "${mainsail_data[@]}"
@@ -69,158 +138,491 @@ mainsail_status(){
fi
done
if [ "$mcount" == "${#mainsail_data[*]}" ]; then
MAINSAIL_STATUS="${green}Installed!${default} "
MAINSAIL_STATUS="${green}Installed!${default} "
elif [ "$mcount" == 0 ]; then
MAINSAIL_STATUS="${red}Not installed!${default} "
MAINSAIL_STATUS="${red}Not installed!${default} "
else
MAINSAIL_STATUS="${yellow}Incomplete!${default} "
MAINSAIL_STATUS="${yellow}Incomplete!${default} "
fi
}
fluidd_status(){
fcount=0
fluidd_data=(
$FLUIDD_DIR
$NGINX_SA/fluidd
$NGINX_SE/fluidd
)
#count+1 for each found data-item from array
for fd in "${fluidd_data[@]}"
do
if [ -e $fd ]; then
fcount=$(expr $fcount + 1)
fi
done
if [ "$fcount" == "${#fluidd_data[*]}" ]; then
FLUIDD_STATUS="${green}Installed!${default} "
elif [ "$fcount" == 0 ]; then
FLUIDD_STATUS="${red}Not installed!${default} "
else
FLUIDD_STATUS="${yellow}Incomplete!${default} "
fi
}
octoprint_status(){
ocount=0
octoprint_data=(
SERVICE
$OCTOPRINT_DIR
)
### count amount of octoprint service files in /etc/systemd/system
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "^octoprint(\-[[:digit:]]+)?\.service$" | wc -l)
### remove the "SERVICE" entry from the octoprint_data array if a octoprint service is installed
[ $SERVICE_FILE_COUNT -gt 0 ] && unset octoprint_data[0]
#count+1 for each found data-item from array
for op in "${octoprint_data[@]}"
do
if [ -e $op ]; then
ocount=$(expr $ocount + 1)
fi
done
### display status
if [ "$ocount" == "${#octoprint_data[*]}" ]; then
OCTOPRINT_STATUS="$(printf "${green}Installed: %-5s${default}" $SERVICE_FILE_COUNT)"
elif [ "$ocount" == 0 ]; then
OCTOPRINT_STATUS="${red}Not installed!${default} "
else
OCTOPRINT_STATUS="${yellow}Incomplete!${default} "
fi
}
klipperscreen_status(){
klsccount=0
klipperscreen_data=(
SERVICE
$KLIPPERSCREEN_DIR
$KLIPPERSCREEN_ENV_DIR
)
### count amount of klipperscreen_data service files in /etc/systemd/system
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "KlipperScreen" | wc -l)
### remove the "SERVICE" entry from the klipperscreen_data array if a KlipperScreen service is installed
[ $SERVICE_FILE_COUNT -gt 0 ] && unset klipperscreen_data[0]
#count+1 for each found data-item from array
for klscd in "${klipperscreen_data[@]}"
do
if [ -e $klscd ]; then
klsccount=$(expr $klsccount + 1)
fi
done
if [ "$klsccount" == "${#klipperscreen_data[*]}" ]; then
KLIPPERSCREEN_STATUS="${green}Installed!${default} "
elif [ "$klsccount" == 0 ]; then
KLIPPERSCREEN_STATUS="${red}Not installed!${default} "
else
KLIPPERSCREEN_STATUS="${yellow}Incomplete!${default} "
fi
}
MoonrakerTelegramBot_status(){
mtbcount=0
MoonrakerTelegramBot_data=(
SERVICE
$MOONRAKER_TELEGRAM_BOT_DIR
$MOONRAKER_TELEGRAM_BOT_ENV_DIR
)
### count amount of MoonrakerTelegramBot_data service files in /etc/systemd/system
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "moonraker-telegram-bot" | wc -l)
### remove the "SERVICE" entry from the MoonrakerTelegramBot_data array if a MoonrakerTelegramBot service is installed
[ $SERVICE_FILE_COUNT -gt 0 ] && unset MoonrakerTelegramBot_data[0]
#count+1 for each found data-item from array
for mtbd in "${MoonrakerTelegramBot_data[@]}"
do
if [ -e $mtbd ]; then
mtbcount=$(expr $mtbcount + 1)
fi
done
if [ "$mtbcount" == "${#MoonrakerTelegramBot_data[*]}" ]; then
MOONRAKER_TELEGRAM_BOT_STATUS="${green}Installed!${default} "
elif [ "$mtbcount" == 0 ]; then
MOONRAKER_TELEGRAM_BOT_STATUS="${red}Not installed!${default} "
else
MOONRAKER_TELEGRAM_BOT_STATUS="${yellow}Incomplete!${default} "
fi
}
#############################################################
#############################################################
### reading the klipper branch the user is currently on
read_branch(){
if [ -d $KLIPPER_DIR ] && [ -d $KLIPPER_DIR/.git ]; then
if [ -d $KLIPPER_DIR/.git ]; then
cd $KLIPPER_DIR
GET_BRANCH=$(git branch -a | head -1 | cut -d " " -f5 | cut -d ")" -f1)
#if reading the branch gives an empty string
#we are on non-detached HEAD state on origin/master
#and need to set GET_BRANCH to make a non-empty string
if [ -z $GET_BRANCH ]; then
GET_BRANCH="origin/master"
GET_BRANCH="$(git branch | grep "*" | cut -d"*" -f2 | cut -d" " -f2)"
### try to fix a detached HEAD state and read the correct branch from the output you get
if [ "$(echo $GET_BRANCH | grep "HEAD" )" ]; then
DETACHED_HEAD="true"
GET_BRANCH=$(git branch | grep "HEAD" | rev | cut -d" " -f1 | rev | cut -d")" -f1 | cut -d"/" -f2)
### try to identify the branch when the HEAD was detached at a single commit
### will only work if its either master, scurve-shaping or scurve-smoothing branch
if [[ $GET_BRANCH =~ [[:alnum:]] ]]; then
if [ "$(git branch -r --contains $GET_BRANCH | grep "master")" ]; then
GET_BRANCH="master"
elif [ "$(git branch -r --contains $GET_BRANCH | grep "scurve-shaping")" ]; then
GET_BRANCH="scurve-shaping"
elif [ "$(git branch -r --contains $GET_BRANCH | grep "scurve-smoothing")" ]; then
GET_BRANCH="scurve-smoothing"
fi
fi
fi
else
GET_BRANCH=""
fi
}
#prints the current klipper branch in the main menu
print_branch(){
read_branch
if [ "$GET_BRANCH" == "origin/master" ]; then
PRINT_BRANCH="${cyan}$GET_BRANCH${default} "
elif [ "$GET_BRANCH" == "dmbutyugin/scurve-shaping" ]; then
PRINT_BRANCH="${cyan}scurve-shaping${default} "
elif [ "$GET_BRANCH" == "dmbutyugin/scurve-smoothing" ]; then
PRINT_BRANCH="${cyan}scurve-smoothing${default} "
elif [ "$GET_BRANCH" == "Arksine/work-web_server-20200131" ]; then
PRINT_BRANCH="${cyan}moonraker${default} "
elif [ "$GET_BRANCH" == "Arksine/dev-moonraker-testing" ]; then
PRINT_BRANCH="${cyan}dev-moonraker${default} "
if [ ! -z "$GET_BRANCH" ]; then
PRINT_BRANCH="$(printf "%-16s" "$GET_BRANCH")"
else
PRINT_BRANCH="${red}----${default} "
PRINT_BRANCH="${red}--------------${default} "
fi
}
read_local_klipper_commit(){
if [ -d $KLIPPER_DIR ] && [ -d $KLIPPER_DIR/.git ]; then
cd $KLIPPER_DIR
LOCAL_COMMIT=$(git rev-parse --short=8 HEAD)
LOCAL_COMMIT=$(git describe HEAD --always --tags | cut -d "-" -f 1,2)
else
LOCAL_COMMIT=""
LOCAL_COMMIT=$NONE
fi
}
read_remote_klipper_commit(){
read_branch
if [ ! -z $GET_BRANCH ];then
REMOTE_COMMIT=$(git rev-parse --short=8 $GET_BRANCH)
if [ ! -z "$GET_BRANCH" ];then
if [ "$GET_BRANCH" = "origin/master" ] || [ "$GET_BRANCH" = "master" ]; then
git fetch origin -q
REMOTE_COMMIT=$(git describe origin/master --always --tags | cut -d "-" -f 1,2)
elif [ "$GET_BRANCH" = "scurve-shaping" ]; then
git fetch dmbutyugin scurve-shaping -q
REMOTE_COMMIT=$(git describe dmbutyugin/scurve-shaping --always --tags | cut -d "-" -f 1,2)
elif [ "$GET_BRANCH" = "scurve-smoothing" ]; then
git fetch dmbutyugin scurve-smoothing -q
REMOTE_COMMIT=$(git describe dmbutyugin/scurve-smoothing --always --tags | cut -d "-" -f 1,2)
fi
else
REMOTE_COMMIT=""
REMOTE_COMMIT=$NONE
fi
}
compare_klipper_versions(){
read_local_klipper_commit
read_remote_klipper_commit
#echo "Local: $LOCAL_COMMIT"
#echo "Remote: $REMOTE_COMMIT"
unset KLIPPER_UPDATE_AVAIL
read_local_klipper_commit && read_remote_klipper_commit
if [ "$LOCAL_COMMIT" != "$REMOTE_COMMIT" ]; then
LOCAL_COMMIT="${yellow}$LOCAL_COMMIT${default}"
REMOTE_COMMIT="${green}$REMOTE_COMMIT${default}"
LOCAL_COMMIT="${yellow}$(printf "%-12s" "$LOCAL_COMMIT")${default}"
REMOTE_COMMIT="${green}$(printf "%-12s" "$REMOTE_COMMIT")${default}"
# add klipper to the update all array for the update all function in the updater
KLIPPER_UPDATE_AVAIL="true" && update_arr+=(update_klipper)
else
LOCAL_COMMIT="${green}$LOCAL_COMMIT${default}"
REMOTE_COMMIT="${green}$REMOTE_COMMIT${default}"
LOCAL_COMMIT="${green}$(printf "%-12s" "$LOCAL_COMMIT")${default}"
REMOTE_COMMIT="${green}$(printf "%-12s" "$REMOTE_COMMIT")${default}"
KLIPPER_UPDATE_AVAIL="false"
fi
#if detached head was found, force the user with warn message to update klipper
if [ "$DETACHED_HEAD" == "true" ]; then
LOCAL_COMMIT="${red}$(printf "%-12s" "Need update!")${default}"
fi
}
#############################################################
#############################################################
read_dwc2fk_versions(){
if [ -d $DWC2FK_DIR ] && [ -d $DWC2FK_DIR/.git ]; then
cd $DWC2FK_DIR
LOCAL_DWC2FK_COMMIT=$(git rev-parse --short=8 HEAD)
REMOTE_DWC2FK_COMMIT=$(git rev-parse --short=8 origin/master)
git fetch origin master -q
LOCAL_DWC2FK_COMMIT=$(git describe HEAD --always --tags | cut -d "-" -f 1,2)
REMOTE_DWC2FK_COMMIT=$(git describe origin/master --always --tags | cut -d "-" -f 1,2)
else
LOCAL_DWC2FK_COMMIT=""
REMOTE_DWC2FK_COMMIT=""
LOCAL_DWC2FK_COMMIT=$NONE
REMOTE_DWC2FK_COMMIT=$NONE
fi
}
compare_dwc2fk_versions(){
unset DWC2FK_UPDATE_AVAIL
read_dwc2fk_versions
#echo "Local: $LOCAL_DWC2FK_COMMIT"
#echo "Remote: $REMOTE_DWC2FK_COMMIT"
if [ "$LOCAL_DWC2FK_COMMIT" != "$REMOTE_DWC2FK_COMMIT" ]; then
LOCAL_DWC2FK_COMMIT="${yellow}$LOCAL_DWC2FK_COMMIT${default}"
REMOTE_DWC2FK_COMMIT="${green}$REMOTE_DWC2FK_COMMIT${default}"
LOCAL_DWC2FK_COMMIT="${yellow}$(printf "%-12s" "$LOCAL_DWC2FK_COMMIT")${default}"
REMOTE_DWC2FK_COMMIT="${green}$(printf "%-12s" "$REMOTE_DWC2FK_COMMIT")${default}"
# add dwc2fk to the update all array for the update all function in the updater
DWC2FK_UPDATE_AVAIL="true" && update_arr+=(update_dwc2fk)
else
LOCAL_DWC2FK_COMMIT="${green}$LOCAL_DWC2FK_COMMIT${default}"
REMOTE_DWC2FK_COMMIT="${green}$REMOTE_DWC2FK_COMMIT${default}"
LOCAL_DWC2FK_COMMIT="${green}$(printf "%-12s" "$LOCAL_DWC2FK_COMMIT")${default}"
REMOTE_DWC2FK_COMMIT="${green}$(printf "%-12s" "$REMOTE_DWC2FK_COMMIT")${default}"
DWC2FK_UPDATE_AVAIL="false"
fi
}
read_local_dwc2_version(){
if [ -e $DWC2_DIR/web/version ]; then
DWC2_LOCAL_VER=$(head -n 1 $DWC2_DIR/web/version)
unset DWC2_VER_FOUND
if [ -e $DWC2_DIR/.version ]; then
DWC2_VER_FOUND="true"
DWC2_LOCAL_VER=$(head -n 1 $DWC2_DIR/.version)
else
DWC2_LOCAL_VER=""
DWC2_VER_FOUND="false" && unset DWC2_LOCAL_VER
fi
}
read_remote_dwc2_version(){
DWC2_REMOTE_VER=$(curl -s https://api.github.com/repositories/28820678/releases/latest | grep tag_name | cut -d'"' -f4)
#remote checks don't work without curl installed!
if [[ ! $(dpkg-query -f'${Status}' --show curl 2>/dev/null) = *\ installed ]]; then
DWC2_REMOTE_VER=$NONE
else
get_dwc_ver
DWC2_REMOTE_VER=$DWC2_VERSION
fi
}
compare_dwc2_versions(){
read_local_dwc2_version
read_remote_dwc2_version
#echo "Local: $DWC2_LOCAL_VER"
#echo "Remote: $DWC2_REMOTE_VER"
if [ "$DWC2_LOCAL_VER" != "$DWC2_REMOTE_VER" ]; then
DWC2_LOCAL_VER="${yellow}$DWC2_LOCAL_VER${default}"
DWC2_REMOTE_VER="${green}$DWC2_REMOTE_VER${default}"
unset DWC2_UPDATE_AVAIL
read_local_dwc2_version && read_remote_dwc2_version
if [[ $DWC2_VER_FOUND = "true" ]] && [[ $DWC2_LOCAL_VER == $DWC2_REMOTE_VER ]]; then
#printf fits the string for displaying it in the ui to a total char length of 12
DWC2_LOCAL_VER="${green}$(printf "%-12s" "$DWC2_LOCAL_VER")${default}"
DWC2_REMOTE_VER="${green}$(printf "%-12s" "$DWC2_REMOTE_VER")${default}"
elif [[ $DWC2_VER_FOUND = "true" ]] && [[ $DWC2_LOCAL_VER != $DWC2_REMOTE_VER ]]; then
DWC2_LOCAL_VER="${yellow}$(printf "%-12s" "$DWC2_LOCAL_VER")${default}"
DWC2_REMOTE_VER="${green}$(printf "%-12s" "$DWC2_REMOTE_VER")${default}"
# add dwc to the update all array for the update all function in the updater
DWC2_UPDATE_AVAIL="true" && update_arr+=(update_dwc2)
else
DWC2_LOCAL_VER="${green}$DWC2_LOCAL_VER${default}"
DWC2_REMOTE_VER="${green}$DWC2_REMOTE_VER${default}"
DWC2_LOCAL_VER=$NONE
DWC2_REMOTE_VER="${green}$(printf "%-12s" "$DWC2_REMOTE_VER")${default}"
DWC2_UPDATE_AVAIL="false"
fi
}
#############################################################
#############################################################
read_moonraker_versions(){
if [ -d $MOONRAKER_DIR ] && [ -d $MOONRAKER_DIR/.git ]; then
cd $MOONRAKER_DIR
git fetch origin master -q
LOCAL_MOONRAKER_COMMIT=$(git describe HEAD --always --tags | cut -d "-" -f 1,2)
REMOTE_MOONRAKER_COMMIT=$(git describe origin/master --always --tags | cut -d "-" -f 1,2)
else
LOCAL_MOONRAKER_COMMIT=$NONE
REMOTE_MOONRAKER_COMMIT=$NONE
fi
}
compare_moonraker_versions(){
unset MOONRAKER_UPDATE_AVAIL
read_moonraker_versions
if [ "$LOCAL_MOONRAKER_COMMIT" != "$REMOTE_MOONRAKER_COMMIT" ]; then
LOCAL_MOONRAKER_COMMIT="${yellow}$(printf "%-12s" "$LOCAL_MOONRAKER_COMMIT")${default}"
REMOTE_MOONRAKER_COMMIT="${green}$(printf "%-12s" "$REMOTE_MOONRAKER_COMMIT")${default}"
# add moonraker to the update all array for the update all function in the updater
MOONRAKER_UPDATE_AVAIL="true" && update_arr+=(update_moonraker)
else
LOCAL_MOONRAKER_COMMIT="${green}$(printf "%-12s" "$LOCAL_MOONRAKER_COMMIT")${default}"
REMOTE_MOONRAKER_COMMIT="${green}$(printf "%-12s" "$REMOTE_MOONRAKER_COMMIT")${default}"
MOONRAKER_UPDATE_AVAIL="false"
fi
}
read_local_mainsail_version(){
if [ -e $MAINSAIL_DIR/version ]; then
MAINSAIL_LOCAL_VER=$(head -n 1 $MAINSAIL_DIR/version)
unset MAINSAIL_VER_FOUND
if [ -e $MAINSAIL_DIR/.version ]; then
MAINSAIL_VER_FOUND="true"
MAINSAIL_LOCAL_VER=$(head -n 1 $MAINSAIL_DIR/.version)
else
MAINSAIL_LOCAL_VER=""
MAINSAIL_VER_FOUND="false" && unset MAINSAIL_LOCAL_VER
fi
}
read_remote_mainsail_version(){
get_mainsail_ver
MAINSAIL_REMOTE_VER=$MAINSAIL_VERSION
}
compare_mainsail_versions(){
read_local_mainsail_version
read_remote_mainsail_version
#echo "Local: $MAINSAIL_LOCAL_VER"
#echo "Remote: $MAINSAIL_REMOTE_VER"
if [ "$MAINSAIL_LOCAL_VER" != "$MAINSAIL_REMOTE_VER" ]; then
MAINSAIL_LOCAL_VER="${yellow}$MAINSAIL_LOCAL_VER${default}"
MAINSAIL_REMOTE_VER="${green}$MAINSAIL_REMOTE_VER${default}"
#remote checks don't work without curl installed!
if [[ ! $(dpkg-query -f'${Status}' --show curl 2>/dev/null) = *\ installed ]]; then
MAINSAIL_REMOTE_VER=$NONE
else
MAINSAIL_LOCAL_VER="${green}$MAINSAIL_LOCAL_VER${default}"
MAINSAIL_REMOTE_VER="${green}$MAINSAIL_REMOTE_VER${default}"
get_mainsail_ver
MAINSAIL_REMOTE_VER=$MAINSAIL_VERSION
fi
}
compare_mainsail_versions(){
unset MAINSAIL_UPDATE_AVAIL
read_local_mainsail_version && read_remote_mainsail_version
if [[ $MAINSAIL_VER_FOUND = "true" ]] && [[ $MAINSAIL_LOCAL_VER == $MAINSAIL_REMOTE_VER ]]; then
#printf fits the string for displaying it in the ui to a total char length of 12
MAINSAIL_LOCAL_VER="${green}$(printf "%-12s" "$MAINSAIL_LOCAL_VER")${default}"
MAINSAIL_REMOTE_VER="${green}$(printf "%-12s" "$MAINSAIL_REMOTE_VER")${default}"
elif [[ $MAINSAIL_VER_FOUND = "true" ]] && [[ $MAINSAIL_LOCAL_VER != $MAINSAIL_REMOTE_VER ]]; then
MAINSAIL_LOCAL_VER="${yellow}$(printf "%-12s" "$MAINSAIL_LOCAL_VER")${default}"
MAINSAIL_REMOTE_VER="${green}$(printf "%-12s" "$MAINSAIL_REMOTE_VER")${default}"
# add mainsail to the update all array for the update all function in the updater
MAINSAIL_UPDATE_AVAIL="true" && update_arr+=(update_mainsail)
else
MAINSAIL_LOCAL_VER=$NONE
MAINSAIL_REMOTE_VER="${green}$(printf "%-12s" "$MAINSAIL_REMOTE_VER")${default}"
MAINSAIL_UPDATE_AVAIL="false"
fi
}
read_local_fluidd_version(){
unset FLUIDD_VER_FOUND
if [ -e $FLUIDD_DIR/.version ]; then
FLUIDD_VER_FOUND="true"
FLUIDD_LOCAL_VER=$(head -n 1 $FLUIDD_DIR/.version)
else
FLUIDD_VER_FOUND="false" && unset FLUIDD_LOCAL_VER
fi
}
read_remote_fluidd_version(){
#remote checks don't work without curl installed!
if [[ ! $(dpkg-query -f'${Status}' --show curl 2>/dev/null) = *\ installed ]]; then
FLUIDD_REMOTE_VER=$NONE
else
get_fluidd_ver
FLUIDD_REMOTE_VER=$FLUIDD_VERSION
fi
}
compare_fluidd_versions(){
unset FLUIDD_UPDATE_AVAIL
read_local_fluidd_version && read_remote_fluidd_version
if [[ $FLUIDD_VER_FOUND = "true" ]] && [[ $FLUIDD_LOCAL_VER == $FLUIDD_REMOTE_VER ]]; then
#printf fits the string for displaying it in the ui to a total char length of 12
FLUIDD_LOCAL_VER="${green}$(printf "%-12s" "$FLUIDD_LOCAL_VER")${default}"
FLUIDD_REMOTE_VER="${green}$(printf "%-12s" "$FLUIDD_REMOTE_VER")${default}"
elif [[ $FLUIDD_VER_FOUND = "true" ]] && [[ $FLUIDD_LOCAL_VER != $FLUIDD_REMOTE_VER ]]; then
FLUIDD_LOCAL_VER="${yellow}$(printf "%-12s" "$FLUIDD_LOCAL_VER")${default}"
FLUIDD_REMOTE_VER="${green}$(printf "%-12s" "$FLUIDD_REMOTE_VER")${default}"
# add fluidd to the update all array for the update all function in the updater
FLUIDD_UPDATE_AVAIL="true" && update_arr+=(update_fluidd)
else
FLUIDD_LOCAL_VER=$NONE
FLUIDD_REMOTE_VER="${green}$(printf "%-12s" "$FLUIDD_REMOTE_VER")${default}"
FLUIDD_UPDATE_AVAIL="false"
fi
}
read_klipperscreen_versions(){
if [ -d $KLIPPERSCREEN_DIR ] && [ -d $KLIPPERSCREEN_DIR/.git ]; then
cd $KLIPPERSCREEN_DIR
git fetch origin master -q
LOCAL_KLIPPERSCREEN_COMMIT=$(git describe HEAD --always --tags | cut -d "-" -f 1,2)
REMOTE_KLIPPERSCREEN_COMMIT=$(git describe origin/master --always --tags | cut -d "-" -f 1,2)
else
LOCAL_KLIPPERSCREEN_COMMIT=$NONE
REMOTE_KLIPPERSCREEN_COMMIT=$NONE
fi
}
compare_klipperscreen_versions(){
unset KLIPPERSCREEN_UPDATE_AVAIL
read_klipperscreen_versions
if [ "$LOCAL_KLIPPERSCREEN_COMMIT" != "$REMOTE_KLIPPERSCREEN_COMMIT" ]; then
LOCAL_KLIPPERSCREEN_COMMIT="${yellow}$(printf "%-12s" "$LOCAL_KLIPPERSCREEN_COMMIT")${default}"
REMOTE_KLIPPERSCREEN_COMMIT="${green}$(printf "%-12s" "$REMOTE_KLIPPERSCREEN_COMMIT")${default}"
KLIPPERSCREEN_UPDATE_AVAIL="true"
update_arr+=(update_klipperscreen)
else
LOCAL_KLIPPERSCREEN_COMMIT="${green}$(printf "%-12s" "$LOCAL_KLIPPERSCREEN_COMMIT")${default}"
REMOTE_KLIPPERSCREEN_COMMIT="${green}$(printf "%-12s" "$REMOTE_KLIPPERSCREEN_COMMIT")${default}"
KLIPPERSCREEN_UPDATE_AVAIL="false"
fi
}
read_MoonrakerTelegramBot_versions(){
if [ -d $MOONRAKER_TELEGRAM_BOT_DIR ] && [ -d $MOONRAKER_TELEGRAM_BOT_DIR/.git ]; then
cd $MOONRAKER_TELEGRAM_BOT_DIR
git fetch origin master -q
LOCAL_MOONRAKER_TELEGRAM_BOT_COMMIT=$(git describe HEAD --always --tags | cut -d "-" -f 1,2)
REMOTE_MOONRAKER_TELEGRAM_BOT_COMMIT=$(git describe origin/master --always --tags | cut -d "-" -f 1,2)
else
LOCAL_MOONRAKER_TELEGRAM_BOT_COMMIT=$NONE
REMOTE_MOONRAKER_TELEGRAM_BOT_COMMIT=$NONE
fi
}
compare_MoonrakerTelegramBot_versions(){
unset MOONRAKER_TELEGRAM_BOT_UPDATE_AVAIL
read_MoonrakerTelegramBot_versions
if [ "$LOCAL_MOONRAKER_TELEGRAM_BOT_COMMIT" != "$REMOTE_MOONRAKER_TELEGRAM_BOT_COMMIT" ]; then
LOCAL_MOONRAKER_TELEGRAM_BOT_COMMIT="${yellow}$(printf "%-12s" "$LOCAL_MOONRAKER_TELEGRAM_BOT_COMMIT")${default}"
REMOTE_MOONRAKER_TELEGRAM_BOT_COMMIT="${green}$(printf "%-12s" "$REMOTE_MOONRAKER_TELEGRAM_BOT_COMMIT")${default}"
# add moonraker telegram bot to the update all array for the update all function in the updater
MOONRAKER_TELEGRAM_BOT_UPDATE_AVAIL="true" && update_arr+=(update_MoonrakerTelegramBot)
else
LOCAL_MOONRAKER_TELEGRAM_BOT_COMMIT="${green}$(printf "%-12s" "$LOCAL_MOONRAKER_TELEGRAM_BOT_COMMIT")${default}"
REMOTE_MOONRAKER_TELEGRAM_BOT_COMMIT="${green}$(printf "%-12s" "$REMOTE_MOONRAKER_TELEGRAM_BOT_COMMIT")${default}"
MOONRAKER_TELEGRAM_BOT_UPDATE_AVAIL="false"
fi
}
#############################################################
#############################################################
read_pgc_versions(){
PGC_DIR="${HOME}/pgcode"
if [ -d $PGC_DIR ] && [ -d $PGC_DIR/.git ]; then
cd $PGC_DIR
git fetch origin main -q
LOCAL_PGC_COMMIT=$(git describe HEAD --always --tags | cut -d "-" -f 1,2)
REMOTE_PGC_COMMIT=$(git describe origin/main --always --tags | cut -d "-" -f 1,2)
else
LOCAL_PGC_COMMIT=$NONE
REMOTE_PGC_COMMIT=$NONE
fi
}
compare_pgc_versions(){
unset PGC_UPDATE_AVAIL
read_pgc_versions
if [ "$LOCAL_PGC_COMMIT" != "$REMOTE_PGC_COMMIT" ]; then
LOCAL_PGC_COMMIT="${yellow}$(printf "%-12s" "$LOCAL_PGC_COMMIT")${default}"
REMOTE_PGC_COMMIT="${green}$(printf "%-12s" "$REMOTE_PGC_COMMIT")${default}"
# add PGC to the update all array for the update all function in the updater
PGC_UPDATE_AVAIL="true" && update_arr+=(update_pgc_for_klipper)
else
LOCAL_PGC_COMMIT="${green}$(printf "%-12s" "$LOCAL_PGC_COMMIT")${default}"
REMOTE_PGC_COMMIT="${green}$(printf "%-12s" "$REMOTE_PGC_COMMIT")${default}"
PGC_UPDATE_AVAIL="false"
fi
}
#############################################################
#############################################################
#display this as placeholder if no version/commit could be fetched
NONE="${red}$(printf "%-12s" "--------")${default}"
ui_print_versions(){
unset update_arr
check_system_updates
compare_klipper_versions
compare_dwc2fk_versions
compare_dwc2_versions
compare_moonraker_versions
compare_mainsail_versions
}
compare_fluidd_versions
compare_klipperscreen_versions
compare_MoonrakerTelegramBot_versions
compare_pgc_versions
}

26
scripts/switch_branch.sh Normal file → Executable file
View File

@@ -1,7 +1,7 @@
switch_to_origin(){
switch_to_master(){
cd $KLIPPER_DIR
status_msg "Switching...Please wait ..."; echo
git fetch origin -q && git checkout origin/master -q
git fetch origin -q && git checkout master; echo
}
switch_to_scurve_shaping(){
@@ -10,7 +10,7 @@ switch_to_scurve_shaping(){
if ! git remote | grep dmbutyugin -q; then
git remote add dmbutyugin $DMBUTYUGIN_REPO
fi
git fetch dmbutyugin -q && git checkout $BRANCH_SCURVE_SHAPING -q
git fetch dmbutyugin -q && git checkout scurve-shaping; echo
}
switch_to_scurve_smoothing(){
@@ -19,23 +19,5 @@ switch_to_scurve_smoothing(){
if ! git remote | grep dmbutyugin -q; then
git remote add dmbutyugin $DMBUTYUGIN_REPO
fi
git fetch dmbutyugin -q && git checkout $BRANCH_SCURVE_SMOOTHING -q
}
switch_to_moonraker(){
cd $KLIPPER_DIR
status_msg "Switching...Please wait ..."; echo
if ! git remote | grep Arksine -q; then
git remote add Arksine $ARKSINE_REPO
fi
git fetch Arksine -q && git checkout $BRANCH_MOONRAKER -q
}
switch_to_dev_moonraker(){
cd $KLIPPER_DIR
status_msg "Switching...Please wait ..."; echo
if ! git remote | grep Arksine -q; then
git remote add Arksine $ARKSINE_REPO
fi
git fetch Arksine -q && git checkout $BRANCH_DEV_MOONRAKER -q
git fetch dmbutyugin -q && git checkout scurve-smoothing; echo
}

View File

@@ -1,154 +0,0 @@
### set up some UI stuff
#ui total width = 57 chars
top_border(){
echo -e "/=======================================================\ "
}
bottom_border(){
echo -e "\=======================================================/"
}
hr(){
echo -e "|-------------------------------------------------------|"
}
quit_footer(){
hr
echo -e "| ${red}Q) Quit${default} | "
bottom_border
}
print_header(){
top_border
echo -e "| $(title_msg "~~~~~~~~~~~~~~~~~ [ KIAUH ] ~~~~~~~~~~~~~~~~~") |"
echo -e "| $(title_msg " Klipper Installation And Update Helper ") |"
echo -e "| $(title_msg "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") |"
bottom_border
}
main_ui(){
top_border
echo -e "| $(title_msg "~~~~~~~~~~~~~~~ [ Main Menu ] ~~~~~~~~~~~~~~~") |"
hr
echo -e "| 0) [System status] | |"
echo -e "| | Klipper: $KLIPPER_STATUS|"
echo -e "| 1) [Install] | Branch: $PRINT_BRANCH|"
echo -e "| 2) [Update] | |"
echo -e "| 3) [Remove] | DWC2: $DWC2_STATUS|"
echo -e "| | Mainsail: $MAINSAIL_STATUS|"
echo -e "| 4) [Advanced] | Octoprint: #### WIP #### |"
echo -e "| 5) [Backup] | |"
quit_footer
}
install_ui(){
top_border
echo -e "| $(title_msg "~~~~~~~~~~~ [ Installation Menu ] ~~~~~~~~~~~") | "
hr
echo -e "| You need this menu usually only for installing | "
echo -e "| all necessary dependencies for the various | "
echo -e "| functions on a completely fresh system. | "
hr
echo -e "| Firmware: | | "
echo -e "| 1) [Klipper] | | "
echo -e "| | | "
echo -e "| Webinterface: | | "
echo -e "| 2) [DWC2] | | "
echo -e "| 3) [Mainsail] | | "
echo -e "| | | "
quit_footer
}
update_ui(){
top_border
echo -e "| $(title_msg "~~~~~~~~~~~~~~ [ Update Menu ] ~~~~~~~~~~~~~~") | "
hr
echo -e "| It's a good idea to check the following website | "
echo -e "| for important software changes to the config file | "
echo -e "| BEFORE updating your klipper installation: | "
echo -e "| | "
echo -e "| ${yellow}https://www.klipper3d.org/Config_Changes.html${default} | "
bottom_border
top_border
echo -e "| 0) $BB4U_STATUS| "
hr
echo -e "| | Local Vers: | Remote Vers: | "
echo -e "| Firmware: | | | "
echo -e "| 1) [Klipper] | $(echo "$LOCAL_COMMIT") | $(echo "$REMOTE_COMMIT") | "
echo -e "| | | | "
echo -e "| Webinterface: | | | "
echo -e "| 2) [DWC2-for-Klipper] | $(echo "$LOCAL_DWC2FK_COMMIT") | $(echo "$REMOTE_DWC2FK_COMMIT") | "
echo -e "| 3) [DWC2 Web UI] | $(echo "$DWC2_LOCAL_VER") | $(echo "$DWC2_REMOTE_VER") | "
echo -e "| 4) [Mainsail] | $(echo "$MAINSAIL_LOCAL_VER") | $(echo "$MAINSAIL_REMOTE_VER") | "
echo -e "| | | | "
quit_footer
}
remove_ui(){
top_border
echo -e "| $(title_msg "~~~~~~~~~~~~~~ [ Remove Menu ] ~~~~~~~~~~~~~~") | "
hr
echo -e "| Files and directories which remain untouched: | "
echo -e "| --> ~/printer.cfg | "
echo -e "| --> ~/backup | "
echo -e "| You need remove them manually if you wish so. | "
hr
echo -e "| 1) [Klipper] | | "
echo -e "| 2) [DWC2-for-Klipper] | | "
echo -e "| 3) [Mainsail] | | "
echo -e "| | | "
quit_footer
}
advanced_ui(){
top_border
echo -e "| $(title_msg "~~~~~~~~~~~~~ [ Advanced Menu ] ~~~~~~~~~~~~~") | "
hr
echo -e "| 1) [Switch Klipper version] | "
echo -e "| | "
echo -e "| 2) [Build Firmware] | "
echo -e "| 3) [Flash MCU] | "
echo -e "| 4) [Get Printer-ID] | "
echo -e "| 5) [Write Printer-ID to printer.cfg] | "
echo -e "| 6) [Write DWC2-for-klipper config] | "
echo -e "| | "
echo -e "| x) [Enable/Disable Octoprint service] | "
echo -e "| | "
quit_footer
}
backup_ui(){
top_border
echo -e "| $(title_msg "~~~~~~~~~~~~~~ [ Backup Menu ] ~~~~~~~~~~~~~~") | "
hr
echo -e "| | "
hr
echo -e "| 1) [ ] | "
echo -e "| 2) [ ] | "
echo -e "| 3) [ ] | "
echo -e "| 4) [ ] | "
echo -e "| 5) [ ] | "
echo -e "| 6) [ ] | "
echo -e "| 7) [ ] | "
echo -e "| | "
quit_footer
}
switch_ui(){
top_border
echo -e "| $(title_msg "~~~~~~~~~ [ Switch Klipper Branch ] ~~~~~~~~~") |"
bottom_border
echo
echo -e " $(title_msg "Active branch: ")${green}$GET_BRANCH${default}"
echo
top_border
echo -e "| 1) [--> origin/master] | "
echo -e "| | "
echo -e "| 2) [--> scurve-shaping] | "
echo -e "| 3) [--> scurve-smoothing] | "
echo -e "| | "
echo -e "| 4) [--> moonraker] | "
echo -e "| 5) [--> dev-moonraker] | "
quit_footer
}

179
scripts/ui/advanced_menu.sh Executable file
View File

@@ -0,0 +1,179 @@
advanced_ui(){
top_border
echo -e "| ${yellow}~~~~~~~~~~~~~ [ Advanced Menu ] ~~~~~~~~~~~~~${default} | "
hr
if [ ! "$OPRINT_SERVICE_STATUS" == "" ]; then
echo -e "| 0) $OPRINT_SERVICE_STATUS| "
hr
echo -e "| | | "
fi
echo -e "| Klipper: | Mainsail: | "
echo -e "| 1) [Switch Branch] | 7) [Theme installer] | "
echo -e "| 2) [Rollback] | | "
echo -e "| | System: | "
echo -e "| Firmware: | 8) [Change hostname] | "
echo -e "| 3) [Build only] | | "
echo -e "| 4) [Flash only] | Extensions: | "
echo -e "| 5) [Build + Flash] | 9) [Shell Command] | "
echo -e "| 6) [Get MCU ID] | | "
echo -e "| | CustomPiOS: | "
echo -e "| | 10) [Migration Helper] | "
back_footer
}
advanced_menu(){
read_octoprint_service_status
do_action "" "advanced_ui"
while true; do
read -p "${cyan}Perform action:${default} " action; echo
case "$action" in
0)
clear
print_header
toggle_octoprint_service
read_octoprint_service_status
print_msg && clear_msg
advanced_ui;;
1)
do_action "switch_menu";;
2)
do_action "load_klipper_state" "advanced_ui";;
3)
do_action "build_fw" "advanced_ui";;
4)
clear && print_header
check_usergroup_dialout
do_action "select_flash_method" "advanced_ui";;
5)
clear && print_header
check_usergroup_dialout
status_msg "Please wait..."
build_fw && select_flash_method
print_msg && clear_msg
advanced_ui;;
6)
do_action "select_mcu_connection" "advanced_ui";;
7)
do_action "ms_theme_menu";;
8)
clear
print_header
create_custom_hostname && set_hostname
print_msg && clear_msg
advanced_ui;;
9)
do_action "setup_gcode_shell_command" "advanced_ui";;
10)
do_action "migration_menu";;
B|b)
clear; main_menu; break;;
*)
deny_action "advanced_ui";;
esac
done
advanced_menu
}
#############################################################
#############################################################
switch_ui(){
top_border
echo -e "| $(title_msg "~~~~~~~~~ [ Switch Klipper Branch ] ~~~~~~~~~") |"
bottom_border
echo
echo -e " $(title_msg "Active Branch: ")${green}$GET_BRANCH${default}"
echo
top_border
echo -e "| | "
echo -e "| KevinOConnor: | "
echo -e "| 1) [--> master] | "
echo -e "| | "
echo -e "| dmbutyugin: | "
echo -e "| 2) [--> scurve-shaping] | "
echo -e "| 3) [--> scurve-smoothing] | "
back_footer
}
switch_menu(){
if [ -d $KLIPPER_DIR ]; then
read_branch
do_action "" "switch_ui"
while true; do
read -p "${cyan}Perform action:${default} " action; echo
case "$action" in
1)
clear
print_header
switch_to_master
read_branch
print_msg && clear_msg
switch_ui;;
2)
clear
print_header
switch_to_scurve_shaping
read_branch
print_msg && clear_msg
switch_ui;;
3)
clear
print_header
switch_to_scurve_smoothing
read_branch
print_msg && clear_msg
switch_ui;;
4)
clear
print_header
switch_to_moonraker
read_branch
print_msg && clear_msg
switch_ui;;
B|b)
clear; advanced_menu; break;;
*)
deny_action "switch_ui";;
esac
done
else
ERROR_MSG="No Klipper directory found! Download Klipper first!"
fi
}
#############################################################
#############################################################
migration_ui(){
top_border
echo -e "| $(title_msg "~~~~~~~~~ [ CustomPiOS Migration ] ~~~~~~~~~~") | "
hr
echo -e "| This function will help you to migrate a vanilla | "
echo -e "| MainsailOS or FluiddPi image to a newer state. | "
blank_line
echo -e "| Only use this function if you use MainsailOS 0.4.0 | "
echo -e "| or lower, or FluiddPi v1.13.0 or lower. | "
blank_line
echo -e "| Please have a look at the KIAUH changelog for more | "
echo -e "| details on what this function will do. | "
hr
echo -e "| | "
echo -e "| 1) [Migrate MainsailOS] | "
echo -e "| 2) [Migrate FluiddPi] | "
echo -e "| | "
back_footer
}
migration_menu(){
print_msg && clear_msg
migration_ui
while true; do
read -p "${cyan}Perform action:${default} " action; echo
case "$action" in
1) migrate_custompios "mainsail"; migration_menu;;
2) migrate_custompios "fluiddpi"; migration_menu;;
B|b) clear; advanced_menu; break;;
*) print_unkown_cmd; migration_menu;;
esac
done
}

53
scripts/ui/backup_menu.sh Executable file
View File

@@ -0,0 +1,53 @@
backup_ui(){
top_border
echo -e "| $(title_msg "~~~~~~~~~~~~~~ [ Backup Menu ] ~~~~~~~~~~~~~~") | "
hr
echo -e "| ${yellow}Backup location: ~/kiauh-backups${default} | "
hr
echo -e "| Configuration folder: | Klipper Webinterface: | "
echo -e "| 0) [Klipper configs] | 4) [Mainsail] | "
echo -e "| | 5) [Fluidd] | "
echo -e "| Firmware: | | "
echo -e "| 1) [Klipper] | HDMI Screen: | "
echo -e "| | 6) [KlipperScreen] | "
echo -e "| Klipper API: | | "
echo -e "| 2) [Moonraker] | Other: | "
echo -e "| 3) [Moonraker DB] | 7) [Duet Web Control] | "
echo -e "| | 8) [OctoPrint] | "
echo -e "| | 9) [MoonrakerTelegramBot] | "
back_footer
}
backup_menu(){
do_action "" "backup_ui"
while true; do
read -p "${cyan}Perform action:${default} " action; echo
case "$action" in
0)
do_action "backup_klipper_config_dir" "backup_ui";;
1)
do_action "backup_klipper" "backup_ui";;
2)
do_action "backup_moonraker" "backup_ui";;
3)
do_action "backup_moonraker_database" "backup_ui";;
4)
do_action "backup_mainsail" "backup_ui";;
5)
do_action "backup_fluidd" "backup_ui";;
6)
do_action "backup_klipperscreen" "backup_ui";;
7)
do_action "backup_dwc2" "backup_ui";;
8)
do_action "backup_octoprint" "backup_ui";;
9)
do_action "backup_MoonrakerTelegramBot" "backup_ui";;
B|b)
clear; main_menu; break;;
*)
deny_action "backup_ui";;
esac
done
backup_menu
}

75
scripts/ui/general_ui.sh Executable file
View File

@@ -0,0 +1,75 @@
#ui total width = 57 chars
top_border(){
echo -e "/=======================================================\\"
}
bottom_border(){
echo -e "\=======================================================/"
}
blank_line(){
echo -e "| |"
}
hr(){
echo -e "|-------------------------------------------------------|"
}
quit_footer(){
hr
echo -e "| ${red}Q) Quit${default} |"
bottom_border
}
back_footer(){
hr
echo -e "| ${green}B) « Back${default} |"
bottom_border
}
back_help_footer(){
hr
echo -e "| ${green}B) « Back${default} | ${yellow}H) Help [?]${default} |"
bottom_border
}
print_header(){
top_border
echo -e "| $(title_msg "~~~~~~~~~~~~~~~~~ [ KIAUH ] ~~~~~~~~~~~~~~~~~") |"
echo -e "| $(title_msg " Klipper Installation And Update Helper ") |"
echo -e "| $(title_msg "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") |"
bottom_border
}
kiauh_update_msg(){
top_border
echo -e "|${green} New KIAUH update available! ${default}| "
hr
echo -e "|${green} View Changelog: https://git.io/JnmlX ${default}| "
blank_line
echo -e "|${yellow} It is recommended to keep KIAUH up to date. Updates ${default}| "
echo -e "|${yellow} usually contain bugfixes, important changes or new ${default}| "
echo -e "|${yellow} features. Please consider updating! ${default}| "
bottom_border
}
################################################################################
#******************************************************************************#
################################################################################
### TODO: rework other menus to make use of the following functions too and make them more readable
do_action(){
clear && print_header
### $1 is the action the user wants to fire
$1
print_msg && clear_msg
### $2 is the menu the user usually gets directed back to after an action is completed
$2
}
deny_action(){
clear && print_header
print_unkown_cmd
print_msg && clear_msg
$1
}

55
scripts/ui/install_menu.sh Executable file
View File

@@ -0,0 +1,55 @@
install_ui(){
top_border
echo -e "| ${green}~~~~~~~~~~~ [ Installation Menu ] ~~~~~~~~~~~${default} | "
hr
echo -e "| You need this menu usually only for installing | "
echo -e "| all necessary dependencies for the various | "
echo -e "| functions on a completely fresh system. | "
hr
echo -e "| Firmware: | Touchscreen GUI: | "
echo -e "| 1) [Klipper] | 5) [KlipperScreen] | "
echo -e "| | | "
echo -e "| Klipper API: | Other: | "
echo -e "| 2) [Moonraker] | 6) [Duet Web Control] | "
echo -e "| | 7) [OctoPrint] | "
echo -e "| Klipper Webinterface: | 8) [PrettyGCode] | "
echo -e "| 3) [Mainsail] | 9) [Telegram Bot] | "
echo -e "| 4) [Fluidd] | | "
echo -e "| | Webcam: | "
echo -e "| | 10) [MJPG-Streamer] | "
back_footer
}
install_menu(){
do_action "" "install_ui"
while true; do
read -p "${cyan}Perform action:${default} " action; echo
case "$action" in
1)
do_action "klipper_setup_dialog" "install_ui";;
2)
do_action "moonraker_setup_dialog" "install_ui";;
3)
do_action "install_webui mainsail" "install_ui";;
4)
do_action "install_webui fluidd" "install_ui";;
5)
do_action "install_klipperscreen" "install_ui";;
6)
do_action "dwc_setup_dialog" "install_ui";;
7)
do_action "octoprint_setup_dialog" "install_ui";;
8)
do_action "install_pgc_for_klipper" "install_ui";;
9)
do_action "install_MoonrakerTelegramBot" "install_ui";;
10)
do_action "install_mjpg-streamer" "install_ui";;
B|b)
clear; main_menu; break;;
*)
deny_action "install_ui";;
esac
done
install_menu
}

92
scripts/ui/main_menu.sh Executable file
View File

@@ -0,0 +1,92 @@
main_ui(){
#[ $KIAUH_UPDATE_REMIND="true" ] && kiauh_update_reminder
top_border
echo -e "| $(title_msg "~~~~~~~~~~~~~~~ [ Main Menu ] ~~~~~~~~~~~~~~~") |"
hr
echo -e "| 0) [Upload Log] | Klipper: $KLIPPER_STATUS|"
echo -e "| | Branch: ${cyan}$PRINT_BRANCH${default}|"
echo -e "| 1) [Install] | |"
echo -e "| 2) [Update] | Moonraker: $MOONRAKER_STATUS|"
echo -e "| 3) [Remove] | |"
echo -e "| 4) [Advanced] | Mainsail: $MAINSAIL_STATUS|"
echo -e "| 5) [Backup] | Fluidd: $FLUIDD_STATUS|"
echo -e "| | KlipperScreen: $KLIPPERSCREEN_STATUS|"
echo -e "| 6) [Settings] | Telegram Bot: $MOONRAKER_TELEGRAM_BOT_STATUS|"
echo -e "| | |"
echo -e "| | DWC2: $DWC2_STATUS|"
echo -e "| ${cyan}$KIAUH_VER${default}| Octoprint: $OCTOPRINT_STATUS|"
quit_footer
}
print_kiauh_version(){
cd ${SRCDIR}/kiauh
KIAUH_VER=$(git describe HEAD --always --tags | cut -d "-" -f 1,2)
KIAUH_VER="$(printf "%-20s" "$KIAUH_VER")"
}
kiauh_update_dialog(){
kiauh_update_msg
read -p "${cyan}Do you want to update now? (Y/n):${default} " yn
while true; do
case "$yn" in
Y|y|Yes|yes|"")
do_action "update_kiauh"
break;;
N|n|No|no) break;;
*)
deny_action "kiauh_update_dialog";;
esac
done
}
main_menu(){
print_header
#print KIAUH update msg if update available
if [ "$KIAUH_UPDATE_AVAIL" = "true" ]; then
kiauh_update_dialog
fi
#check install status
print_kiauh_version
klipper_status
moonraker_status
dwc2_status
fluidd_status
mainsail_status
octoprint_status
klipperscreen_status
MoonrakerTelegramBot_status
print_branch
print_msg && clear_msg
main_ui
while true; do
read -p "${cyan}Perform action:${default} " action; echo
case "$action" in
"start klipper") do_action_service "start" "klipper"; main_ui;;
"stop klipper") do_action_service "stop" "klipper"; main_ui;;
"restart klipper") do_action_service "restart" "klipper"; main_ui;;
"start moonraker") do_action_service "start" "moonraker"; main_ui;;
"stop moonraker") do_action_service "stop" "moonraker"; main_ui;;
"restart moonraker")do_action_service "restart" "moonraker"; main_ui;;
"start dwc") do_action_service "start" "dwc"; main_ui;;
"stop dwc") do_action_service "stop" "dwc"; main_ui;;
"restart dwc") do_action_service "restart" "dwc"; main_ui;;
"start octoprint") do_action_service "start" "octoprint"; main_ui;;
"stop octoprint") do_action_service "stop" "octoprint"; main_ui;;
"restart octoprint") do_action_service "restart" "octoprint"; main_ui;;
update) do_action "update_kiauh" "main_ui";;
0) do_action "upload_selection" "main_ui";;
1) clear && install_menu && break;;
2) clear && update_menu && break;;
3) clear && remove_menu && break;;
4) clear && advanced_menu && break;;
5) clear && backup_menu && break;;
6) clear && settings_menu && break;;
Q|q)
echo -e "${green}###### Happy printing! ######${default}"; echo
exit -1;;
*)
deny_action "main_ui";;
esac
done
clear; main_menu
}

58
scripts/ui/remove_menu.sh Executable file
View File

@@ -0,0 +1,58 @@
remove_ui(){
top_border
echo -e "| ${red}~~~~~~~~~~~~~~ [ Remove Menu ] ~~~~~~~~~~~~~~${default} | "
hr
echo -e "| Directories which remain untouched: | "
echo -e "| --> Your printer configuration directory | "
echo -e "| --> ~/kiauh-backups | "
echo -e "| You need remove them manually if you wish so. | "
hr
echo -e "| Firmware: | Touchscreen GUI: | "
echo -e "| 1) [Klipper] | 5) [KlipperScreen] | "
echo -e "| | | "
echo -e "| Klipper API: | Other: | "
echo -e "| 2) [Moonraker] | 6) [Duet Web Control] | "
echo -e "| | 7) [OctoPrint] | "
echo -e "| Klipper Webinterface: | 8) [PrettyGCode] | "
echo -e "| 3) [Mainsail] | 9) [Telegram Bot] | "
echo -e "| 4) [Fluidd] | | "
echo -e "| | 10) [MJPG-Streamer] | "
echo -e "| | 11) [NGINX] | "
back_footer
}
remove_menu(){
do_action "" "remove_ui"
while true; do
read -p "${cyan}Perform action:${default} " action; echo
case "$action" in
1)
do_action "remove_klipper" "remove_ui";;
2)
do_action "remove_moonraker" "remove_ui";;
3)
do_action "remove_mainsail" "remove_ui";;
4)
do_action "remove_fluidd" "remove_ui";;
5)
do_action "remove_klipperscreen" "remove_ui";;
6)
do_action "remove_dwc2" "remove_ui";;
7)
do_action "remove_octoprint" "remove_ui";;
8)
do_action "remove_prettygcode" "remove_ui";;
9)
do_action "remove_MoonrakerTelegramBot" "remove_ui";;
10)
do_action "remove_mjpg-streamer" "remove_ui";;
11)
do_action "remove_nginx" "remove_ui";;
B|b)
clear; main_menu; break;;
*)
deny_action "remove_ui";;
esac
done
remove_menu
}

44
scripts/ui/settings_menu.sh Executable file
View File

@@ -0,0 +1,44 @@
settings_ui(){
source_kiauh_ini
top_border
echo -e "| $(title_msg "~~~~~~~~~~~~ [ KIAUH Settings ] ~~~~~~~~~~~~~") | "
hr
echo -e "| ${red}Caution:${default} | "
echo -e "| When you change the config folder, be aware that ALL | "
echo -e "| Klipper and Moonraker services will be STOPPED, | "
echo -e "| reconfigured and then restarted again. | "
blank_line
echo -e "| ${red}DO NOT change the folder during printing!${default} | "
hr
blank_line
echo -e "| ${cyan}● Current Klipper config folder:${default} | "
printf "|%-55s|\n" " $klipper_cfg_loc"
blank_line
hr
if [ -z $klipper_cfg_loc ]; then
echo -e "| ${red}N/A) Install Klipper with KIAUH first to unlock!${default} | "
else
echo -e "| 1) Change config folder | "
fi
back_footer
}
settings_menu(){
do_action "" "settings_ui"
while true; do
read -p "${cyan}Perform action:${default} " action; echo
case "$action" in
1)
if [ ! -z $klipper_cfg_loc ]; then
do_action "change_klipper_cfg_path" "settings_ui"
else
deny_action "settings_ui"
fi;;
B|b)
clear; main_menu; break;;
*)
deny_action "settings_ui";;
esac
done
settings_ui
}

68
scripts/ui/update_menu.sh Executable file
View File

@@ -0,0 +1,68 @@
update_ui(){
ui_print_versions
top_border
echo -e "| ${green}~~~~~~~~~~~~~~ [ Update Menu ] ~~~~~~~~~~~~~~${default} | "
hr
echo -e "| 0) $BB4U_STATUS| "
hr
echo -e "| a) [Update all] | | | "
echo -e "| | Local Vers: | Remote Vers: | "
echo -e "| Klipper/Klipper API: |---------------|--------------| "
echo -e "| 1) [Klipper] | $LOCAL_COMMIT | $REMOTE_COMMIT | "
echo -e "| 2) [Moonraker] | $LOCAL_MOONRAKER_COMMIT | $REMOTE_MOONRAKER_COMMIT | "
echo -e "| | | | "
echo -e "| Klipper Webinterface: |---------------|--------------| "
echo -e "| 3) [Mainsail] | $MAINSAIL_LOCAL_VER | $MAINSAIL_REMOTE_VER | "
echo -e "| 4) [Fluidd] | $FLUIDD_LOCAL_VER | $FLUIDD_REMOTE_VER | "
echo -e "| | | | "
echo -e "| Touchscreen GUI: |---------------|--------------| "
echo -e "| 5) [KlipperScreen] | $LOCAL_KLIPPERSCREEN_COMMIT | $REMOTE_KLIPPERSCREEN_COMMIT | "
echo -e "| | | | "
echo -e "| Other: |---------------|--------------| "
echo -e "| 6) [DWC2-for-Klipper] | $LOCAL_DWC2FK_COMMIT | $REMOTE_DWC2FK_COMMIT | "
echo -e "| 7) [DWC2 Web UI] | $DWC2_LOCAL_VER | $DWC2_REMOTE_VER | "
echo -e "| 8) [PrettyGCode] | $LOCAL_PGC_COMMIT | $REMOTE_PGC_COMMIT | "
echo -e "| 9) [Telegram Bot] | $LOCAL_MOONRAKER_TELEGRAM_BOT_COMMIT | $REMOTE_MOONRAKER_TELEGRAM_BOT_COMMIT | "
echo -e "| |------------------------------| "
echo -e "| 10) [System] | $DISPLAY_SYS_UPDATE | "
back_footer
}
update_menu(){
read_bb4u_stat
do_action "" "update_ui"
while true; do
read -p "${cyan}Perform action:${default} " action; echo
case "$action" in
0)
do_action "toggle_backups" "update_ui";;
1)
do_action "update_klipper" "update_ui";;
2)
do_action "update_moonraker" "update_ui";;
3)
do_action "update_mainsail" "update_ui";;
4)
do_action "update_fluidd" "update_ui";;
5)
do_action "update_klipperscreen" "update_ui";;
6)
do_action "update_dwc2fk" "update_ui";;
7)
do_action "update_dwc2" "update_ui";;
8)
do_action "update_pgc_for_klipper" "update_ui";;
9)
do_action "update_MoonrakerTelegramBot" "update_ui";;
10)
do_action "update_system" "update_ui";;
a)
do_action "update_all" "update_ui";;
B|b)
clear; main_menu; break;;
*)
deny_action "update_ui";;
esac
done
update_menu
}

364
scripts/update.sh Normal file → Executable file
View File

@@ -1,77 +1,341 @@
#TODO
# - update the correct branch
# - version checks before updating
update_kiauh(){
if [ "$KIAUH_UPDATE_AVAIL" = "true" ]; then
status_msg "Updating KIAUH ..."
cd ${SRCDIR}/kiauh
### force reset kiauh before updating
git reset --hard
git pull && ok_msg "Update complete! Please restart KIAUH."
exit -1
fi
}
#WIP
update_check(){
read_local_commit
read_remote_commit
update_all(){
while true; do
if [ "${#update_arr[@]}" = "0" ]; then
CONFIRM_MSG="Everything is already up to date!"
echo; break
fi
echo
top_border
echo -e "| The following installations will be updated: |"
if [ "$KLIPPER_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● Klipper${default} |"
fi
if [ "$DWC2FK_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● DWC2-for-Klipper-Socket${default} |"
fi
if [ "$DWC2_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● Duet Web Control${default} |"
fi
if [ "$MOONRAKER_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● Moonraker${default} |"
fi
if [ "$MAINSAIL_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● Mainsail${default} |"
fi
if [ "$FLUIDD_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● Fluidd${default} |"
fi
if [ "$KLIPPERSCREEN_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● KlipperScreen${default} |"
fi
if [ "$PGC_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● PrettyGCode for Klipper${default} |"
fi
if [ "$MOONRAKER_TELEGRAM_BOT_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● MoonrakerTelegramBot${default} |"
fi
if [ "$SYS_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● System${default} |"
fi
bottom_border
if [ "${#update_arr[@]}" != "0" ]; then
read -p "${cyan}###### Do you want to proceed? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
for update in ${update_arr[@]}
do
$update
done
break;;
N|n|No|no)
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
fi
done
}
update_log_paths(){
### update services to make use of moonrakers new log_path option
### https://github.com/Arksine/moonraker/commit/829b3a4ee80579af35dd64a37ccc092a1f67682a
shopt -s extglob # enable extended globbing
source_kiauh_ini
LPATH="${HOME}/klipper_logs"
[ ! -d "$LPATH" ] && mkdir -p "$LPATH"
FILE="$SYSTEMDDIR/$1?(-*([0-9])).service"
for file in $(ls $FILE); do
[ "$1" == "klipper" ] && LOG="klippy"
[ "$1" == "moonraker" ] && LOG="moonraker"
if [ ! "$(grep "\-l" $file)" ]; then
status_msg "Updating $file ..."
sudo sed -i -r "/ExecStart=/ s|$| -l $LPATH/$LOG.log|" $file
ok_msg "$file updated!"
elif [ "$(grep "\-l \/tmp\/$LOG" $file)" ]; then
status_msg "Updating $file ..."
sudo sed -i -r "/ExecStart=/ s|-l \/tmp\/$LOG|-l $LPATH/$LOG|" $file
ok_msg "$file updated!"
fi
done
sudo systemctl daemon-reload
# patch log_path entry if not found
dir1="$klipper_cfg_loc"
dir2="$klipper_cfg_loc/printer_*"
for conf in $(find $dir1 $dir2 -name "moonraker.conf" 2> /dev/null); do
if ! grep -q "log_path" $conf; then
status_msg "Patching $conf"
sed -i "/^config_path/a log_path: $LPATH" $conf
ok_msg "OK!"
fi
done
# create symlink for mainsail and fluidd nginx logs
symlink_webui_nginx_log "mainsail"
symlink_webui_nginx_log "fluidd"
# create symlink for webcamd log
if [ -f "/var/log/webcamd.log" ] && [ ! -L "$LPATH/webcamd.log" ]; then
status_msg "Creating symlink for '/var/log/webcamd.log' ..."
ln -s "/var/log/webcamd.log" "$LPATH"
ok_msg "OK!"
fi
shopt -u extglob # disable extended globbing
}
migrate_custompios(){
### migrate vanilla mainsailOS 0.4.0 / fluiddPI v1.13.0
### and older to be in sync with newer releases
WEBCAMD_SRC="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mjpgstreamer/filesystem/root/usr/local/bin/webcamd"
MJPG_SERV_SRC="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mjpgstreamer/filesystem/root/etc/systemd/system/webcamd.service"
KL_SERV_SRC="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/klipper/filesystem/root/etc/systemd/system/klipper.service"
NGINX_CFG1="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mainsail/filesystem/root/etc/nginx/conf.d/upstreams.conf"
NGINX_CFG2="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mainsail/filesystem/root/etc/nginx/sites-available/mainsail"
LOG_ROTATE_KLIPPER="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/klipper/filesystem/root/etc/logrotate.d/klipper"
LOG_ROTATE_MOONRAKER="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/moonraker/filesystem/root/etc/logrotate.d/moonraker"
LOG_ROTATE_WEBCAMD="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mjpgstreamer/filesystem/root/etc/logrotate.d/webcamd"
if [ "$1" == "mainsail" ]; then
OS_VER="MainsailOS"
MACRO_CFG="mainsail.cfg"
fi
if [ "$1" == "fluiddpi" ]; then
OS_VER="FluiddPi"
MACRO_CFG="client_macros.cfg"
fi
if [ ! -f "/boot/$1.txt" ] || [ ! -f "/etc/init.d/klipper" ]; then
# abort function if there is no sign of an old CustomPiOS anymore
ERROR_MSG="No vanilla $OS_VER found. Aborting..." && return 0
fi
status_msg "Starting migration of $OS_VER... Please wait..."
if [ -d "${HOME}/klipper_logs" ]; then
# delete an existing klipper_logs directory
# shouldn't be there in the first place if its a true vanilla CustomPiOS
status_msg "Recreate '~/klipper_logs' directory..."
rm -rf "${HOME}/klipper_logs" && mkdir "${HOME}/klipper_logs"
ok_msg "OK!"
fi
if [ -f "/boot/$1.txt" ]; then
# replace old webcamd.service and webcamd
status_msg "Migrating MJPG-Streamer..."
sudo systemctl stop webcamd
sudo rm -f "/etc/systemd/system/webcamd.service"
sudo rm -f "/root/bin/webcamd"
sudo wget $WEBCAMD_SRC -O "/usr/local/bin/webcamd"
sudo wget $MJPG_SERV_SRC -O "/etc/systemd/system/webcamd.service"
sudo sed -i "s/MainsailOS/$OS_VER/" "/etc/systemd/system/webcamd.service"
sudo chmod +x "/usr/local/bin/webcamd"
# move mainsail.txt/fluiddpi.txt from boot to klipper_config and rename it
sudo mv "/boot/$1.txt" "${HOME}/klipper_config/webcam.txt"
sudo chown pi:pi "${HOME}/klipper_config/webcam.txt"
sudo systemctl daemon-reload
sudo systemctl restart webcamd
ok_msg "OK!"
fi
if [ -f "/etc/init.d/klipper" ] && [ ! -f "/etc/systemd/system/klipper.service" ]; then
# replace klipper SysVinit service with systemd service
status_msg "Migrating Klipper Service..."
sudo systemctl stop klipper
sudo update-rc.d -f klipper remove
sudo rm -f "/etc/init.d/klipper"
sudo rm -f "/etc/default/klipper"
sudo wget $KL_SERV_SRC -O "/etc/systemd/system/klipper.service"
sudo systemctl enable klipper.service
sudo systemctl daemon-reload
sudo systemctl restart klipper
ok_msg "OK!"
fi
if [ -f "/etc/systemd/system/moonraker.service" ]; then
# update new log path in existing moonraker service
status_msg "Updating Moonraker Service..."
sudo systemctl stop moonraker
update_log_paths "moonraker"
sudo systemctl restart moonraker
ok_msg "OK!"
fi
if [ -f "/etc/nginx/conf.d/upstreams.conf" ]; then
[ "$1" == "mainsail" ] && cfg="mainsail"
[ "$1" == "fluiddpi" ] && cfg="fluidd"
# update nginx upstreams.conf and mainsail/fluidd config file
status_msg "Updating NGINX configurations..."
sudo systemctl stop nginx
sudo rm -f "/etc/nginx/conf.d/upstreams.conf"
sudo rm -f "/etc/nginx/sites-available/$cfg"
sudo wget $NGINX_CFG1 -O "/etc/nginx/conf.d/upstreams.conf"
sudo wget $NGINX_CFG2 -O "/etc/nginx/sites-available/$cfg"
sudo sed -i "s/mainsail/$cfg/g" "/etc/nginx/sites-available/$cfg"
sudo systemctl restart nginx
ok_msg "OK!"
fi
if [ -f "${HOME}/klipper_config/$MACRO_CFG" ]; then
# update macro files
status_msg "Updating $MACRO_CFG ..."
MACRO_CFG_PATH="${HOME}/klipper_config/$MACRO_CFG"
sed -i "/SAVE_GCODE_STATE NAME=PAUSE_state/d" $MACRO_CFG_PATH
sed -i "/RESTORE_GCODE_STATE NAME=PAUSE_state/d" $MACRO_CFG_PATH
ok_msg "OK!"
fi
if [ -d "/etc/logrotate.d" ]; then
# download logrotate configs
status_msg "Setting up logrotations..."
sudo wget $LOG_ROTATE_KLIPPER -O "/etc/logrotate.d/klipper"
sudo wget $LOG_ROTATE_MOONRAKER -O "/etc/logrotate.d/moonraker"
sudo wget $LOG_ROTATE_WEBCAMD -O "/etc/logrotate.d/webcamd"
ok_msg "OK!"
fi
ok_msg "Migration done!"
}
update_klipper(){
stop_klipper
bb4u_klipper
do_action_service "stop" "klipper"
if [ ! -d $KLIPPER_DIR ]; then
cd ${HOME} && git clone $KLIPPER_REPO
else
bb4u "klipper"
read_branch
save_klipper_state
status_msg "Updating $GET_BRANCH"
#fetching origin/master -> error
#rewriting origin/master to origin
if [ "$GET_BRANCH" == "origin/master" ]; then
FETCH_BRANCH="origin"
else
FETCH_BRANCH=$(echo "$GET_BRANCH" | cut -d "/" -f1)
cd $KLIPPER_DIR
if [ "$DETACHED_HEAD" == "true" ]; then
git checkout $GET_BRANCH
unset DETACHED_HEAD
fi
status_msg "Fetching from $FETCH_BRANCH"
git fetch $FETCH_BRANCH -q && ok_msg "Fetch successfull!"
status_msg "Checking out $GET_BRANCH"
git checkout $GET_BRANCH -q && ok_msg "Checkout successfull!" && echo; ok_msg "Update complete!"
### pull latest files from github
git pull
### read PKGLIST and install possible new dependencies
install_klipper_packages
### install possible new python dependencies
KLIPPER_REQ_TXT="$KLIPPER_DIR/scripts/klippy-requirements.txt"
$KLIPPY_ENV/bin/pip install -r $KLIPPER_REQ_TXT
fi
start_klipper; echo
update_log_paths "klipper"
ok_msg "Update complete!"
do_action_service "restart" "klipper"
}
update_dwc2fk(){
stop_klipper
bb4u_dwc2fk
do_action_service "stop" "dwc"
bb4u "dwc2"
if [ ! -d $DWC2FK_DIR ]; then
cd ${HOME} && git clone $DWC2FK_REPO
else
cd $DWC2FK_DIR && git pull
#create a web_dwc2.py symlink if not already existing
if [ -d $KLIPPER_DIR/klippy/extras ] && [ ! -e $WEB_DWC2 ]; then
status_msg "Creating web_dwc2.py symlink ..."
ln -s $DWC2FK_DIR/web_dwc2.py $WEB_DWC2 && ok_msg "Symlink created!"
fi
fi
start_klipper
do_action_service "start" "dwc"
}
update_dwc2(){
bb4u_dwc2
#check dependencies
dep=(wget gzip tar curl)
dep_check
#execute operation
GET_DWC2_URL=`curl -s https://api.github.com/repositories/28820678/releases/latest | grep browser_download_url | cut -d'"' -f4`
if [ ! -d $DWC2_DIR/web ]; then
mkdir -p $DWC2_DIR/web
fi
cd $DWC2_DIR/web
status_msg "Downloading DWC2 Web UI ..."
wget -q $GET_DWC2_URL && ok_msg "Download complete!"
status_msg "Unzipping archive ..."
unzip -q -o *.zip && for f_ in $(find . | grep '.gz');do gunzip -f ${f_};done && ok_msg "Done!"
status_msg "Writing version to file ..."
echo $GET_DWC2_URL | cut -d/ -f8 > $DWC2_DIR/web/version && ok_msg "Done!"
status_msg "Do a little cleanup ..."
rm -rf DuetWebControl-SD.zip && ok_msg "Done!"
bb4u "dwc2"
download_dwc_webui
}
update_mainsail(){
stop_klipper
bb4u_mainsail
bb4u "mainsail"
status_msg "Updating Mainsail ..."
install_mainsail
start_klipper
mainsail_setup
match_nginx_configs
symlink_webui_nginx_log "mainsail"
}
update_fluidd(){
bb4u "fluidd"
status_msg "Updating Fluidd ..."
fluidd_setup
match_nginx_configs
symlink_webui_nginx_log "fluidd"
}
update_moonraker(){
do_action_service "stop" "moonraker"
bb4u "moonraker"
status_msg "Updating Moonraker ..."
### pull latest files from github
cd "$MOONRAKER_DIR" && git pull
### read PKGLIST and install possible new dependencies
install_moonraker_packages
### install possible new python dependencies
MR_REQ_TXT="$MOONRAKER_DIR/scripts/moonraker-requirements.txt"
"$MOONRAKER_ENV"/bin/pip install -r "$MR_REQ_TXT"
update_log_paths "moonraker"
### required due to https://github.com/Arksine/moonraker/issues/349
moonraker_polkit
ok_msg "Update complete!"
do_action_service "restart" "moonraker"
}
update_klipperscreen(){
stop_klipperscreen
cd $KLIPPERSCREEN_DIR
KLIPPERSCREEN_OLDREQ_MD5SUM=$(md5sum $KLIPPERSCREEN_DIR/scripts/KlipperScreen-requirements.txt | cut -d " " -f1)
git pull origin master -q && ok_msg "Fetch successfull!"
git checkout -f master && ok_msg "Checkout successfull"
#KLIPPERSCREEN_NEWREQ_MD5SUM=$(md5sum $KLIPPERSCREEN_DIR/scripts/KlipperScreen-requirements.txt)
if [[ $(md5sum $KLIPPERSCREEN_DIR/scripts/KlipperScreen-requirements.txt | cut -d " " -f1) != $KLIPPERSCREEN_OLDREQ_MD5SUM ]]; then
status_msg "New dependecies detected..."
PYTHONDIR="${HOME}/.KlipperScreen-env"
$PYTHONDIR/bin/pip install -r $KLIPPERSCREEN_DIR/scripts/KlipperScreen-requirements.txt
ok_msg "Dependencies have been installed!"
fi
ok_msg "Update complete!"
start_klipperscreen
}
update_pgc_for_klipper(){
PGC_DIR="${HOME}/pgcode"
status_msg "Updating PrettyGCode for Klipper ..."
cd $PGC_DIR && git pull
ok_msg "Update complete!"
}
update_MoonrakerTelegramBot(){
source_kiauh_ini
export klipper_cfg_loc
stop_MoonrakerTelegramBot
cd $MOONRAKER_TELEGRAM_BOT_DIR
git pull
./scripts/install.sh
ok_msg "Update complete!"
start_MoonrakerTelegramBot
}
update_system(){
status_msg "Updating System ..."
sudo apt-get update --allow-releaseinfo-change && sudo apt-get upgrade -y
CONFIRM_MSG="Update complete! Check the log above!\n ${yellow}KIAUH will not install any dist-upgrades or\n any packages which have been kept back!${green}"
print_msg && clear_msg
}

104
scripts/upload_log.sh Executable file
View File

@@ -0,0 +1,104 @@
accept_upload_conditions(){
while true; do
top_border
echo -e "| ${red}~~~~~~~~~~~ [ Upload Agreement ] ~~~~~~~~~~~~${default} |"
hr
echo -e "| The following function will help to quickly upload |"
echo -e "| logs for debugging purposes. With confirming this |"
echo -e "| dialog, you agree that during that process your logs |"
echo -e "| will be uploaded to: ${yellow}http://paste.c-net.org/${default} |"
hr
echo -e "| ${red}PLEASE NOTE:${default} |"
echo -e "| Be aware that logs can contain network information, |"
echo -e "| private data like usernames, filenames, or other |"
echo -e "| information you may not want to make public. |"
blank_line
echo -e "| Do ${red}NOT${default} use this function if you don't agree! |"
bottom_border
read -p "${cyan}Do you accept? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
sed -i "/logupload_accepted=/s/false/true/" $INI_FILE
clear && print_header && upload_selection
;;
N|n|No|no)
clear
main_menu
break
;;
*)
clear
print_header
print_unkown_cmd
print_msg && clear_msg
accept_upload_conditions;;
esac
done
}
upload_selection(){
source_kiauh_ini
[ "$logupload_accepted" = "false" ] && accept_upload_conditions
### find all suitable logfiles for klipper
logfiles=()
klipper_logs="${HOME}/klipper_logs/klippy*.log"
moonraker_logs="${HOME}/klipper_logs/moonraker*.log"
if ls $klipper_logs 2>/dev/null 1>&2; then
for kl_log in $(find $klipper_logs); do
logfiles+=($kl_log)
done
fi
if ls $moonraker_logs 2>/dev/null 1>&2; then
for mr_log in $(find $moonraker_logs); do
logfiles+=($mr_log)
done
fi
if ls /tmp/dwc2*.log 2>/dev/null 1>&2; then
for dwc_log in $(find /tmp/dwc2*.log); do
logfiles+=($dwc_log)
done
fi
### draw interface
i=0
top_border
echo -e "| ${yellow}~~~~~~~~~~~~~~~ [ Log Upload ] ~~~~~~~~~~~~~~${default} |"
hr
echo -e "| You can choose the following files for uploading: |"
for log in ${logfiles[@]}; do
printf "| $i) %-50s|\n" "${logfiles[$i]}"
i=$((i + 1))
done
back_footer
while true; do
read -p "${cyan}Please select:${default} " choice
if [ $choice = "b" ] || [ $choice = "B" ]; then
clear && main_menu && break
elif [ $choice -le ${#logfiles[@]} ]; then
upload_log "${logfiles[$choice]}"
upload_selection
else
clear && print_header
ERROR_MSG="File not found!" && print_msg && clear_msg
upload_selection
fi
done
}
upload_log(){
if [ -f "$1" ]; then
clear && print_header
status_msg "Uploading $1 ..."
LINK=$(curl -s --upload-file $1 'http://paste.c-net.org/')
[ ! -z "$LINK" ] && ok_msg "$1 upload successfull!"
echo -e "\n${cyan}###### Here is your link:${default}"
echo -e ">>>>>> $LINK\n"
unset LINK
else
clear && print_header
ERROR_MSG="File not found!" && print_msg && clear_msg
upload_selection
fi
}