| 
									
										
										
										
											2017-08-14 11:44:06 -04:00
										 |  |  | #!/bin/bash
 | 
					
						
							|  |  |  | # This script installs the Linux MCU code to /usr/local/bin/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if [ "$EUID" -ne 0 ]; then | 
					
						
							|  |  |  |     echo "This script must be run as root" | 
					
						
							|  |  |  |     exit -1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | set -e | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-07 19:32:23 +03:00
										 |  |  | # Setting build output directory | 
					
						
							|  |  |  | if [ -z "${1}" ]; then | 
					
						
							|  |  |  |     out='out' | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  |     out=${1} | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-14 11:44:06 -04:00
										 |  |  | # Install new micro-controller code | 
					
						
							| 
									
										
										
										
											2021-08-17 13:24:56 -04:00
										 |  |  | echo "Installing micro-controller code to /usr/local/bin/" | 
					
						
							| 
									
										
										
										
											2017-08-14 11:44:06 -04:00
										 |  |  | rm -f /usr/local/bin/klipper_mcu | 
					
						
							| 
									
										
										
										
											2023-04-07 19:32:23 +03:00
										 |  |  | cp ${out}/klipper.elf /usr/local/bin/klipper_mcu | 
					
						
							| 
									
										
										
										
											2017-08-14 11:44:06 -04:00
										 |  |  | sync | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Restart (if system install script present) | 
					
						
							|  |  |  | if [ -f /etc/init.d/klipper_pru ]; then | 
					
						
							| 
									
										
										
										
											2020-06-13 02:32:12 +02:00
										 |  |  |     echo "Attempting host PRU restart..." | 
					
						
							| 
									
										
										
										
											2017-08-14 11:44:06 -04:00
										 |  |  |     service klipper_pru restart | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2020-06-13 02:32:12 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Restart (if system install script present) | 
					
						
							|  |  |  | if [ -f /etc/init.d/klipper_mcu ]; then | 
					
						
							|  |  |  |     echo "Attempting host MCU restart..." | 
					
						
							|  |  |  |     service klipper_mcu restart | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2023-02-23 16:44:58 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | if [ -f /etc/systemd/system/klipper-mcu.service ]; then | 
					
						
							|  |  |  |     echo "Attempting host MCU restart..." | 
					
						
							|  |  |  |     systemctl restart klipper-mcu | 
					
						
							|  |  |  | fi |