-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreinstall.sh
executable file
·64 lines (47 loc) · 1.74 KB
/
reinstall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
#
# Sync a standard Klipper install with the lastest commit in master.
# Default variables for standard Klipper installations.
# YOU MAY MODIFY THESE FOR CUSTOM INSTALLATIONS.
USB_DEVICE="/dev/ttyUSB0"
# !!!
# WARNING: DO NOT MODIFY ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU'RE DOING
#!!!!
bold=`tput bold`
red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0 && tput rmso`
datetime=$(date '+%Y%m%d_%H%M%S')
backup_filename="klipper-${datetime}.tar.gz"
echo -e "${bold}${green}\nBacking up Klipper installation to ${backup_filename}...\n${reset}"
# Save a backup of the current klipper installation.
# Example filename: klipper_20190106_090208.tar.gz
tar -zcf ${backup_filename} ~/klipper
echo -e "${bold}${green}\nUpdating Klipper Codebase...\n${reset}"
# Navigate to standard Klipper install.
cd ~/klipper
# Pull the latest code on master.
git pull origin master --quiet
# Only build and flash firmware if the working tree has changed.
if [[ `git status --porcelain --untracked-files=no` ]]; then
echo -e "${bold}${green}\nUpdating Klipper...\n${reset}"
# Update Pi installation as prescribed in the Klipper documentation.
scripts/install-octopi.sh
# Compile updates.
make clean
make
# Stop Klipper service in order to flash the firmware.
sudo service klipper stop
# Flash the new firmware that we compiled earlier.
make flash FLASH_DEVICE=${USB_DEVICE}
# Start the Klipper service with new firmware.
sudo service klipper start
echo -e "${bold}${green}\nUpdate Complete...${reset}"
else
echo -e "${bold}${red}No changes since last update!${reset}"
fi
echo -e "${bold}${green}\n\nYour installation is up-to-date!\n${reset}"
# Error handling.
# Exit immediately if a command fails.
set -o nounset
set -o errexit