-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·49 lines (40 loc) · 1.15 KB
/
install.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
#!/bin/bash
PRINTER_DATA_PATH="${HOME}/printer_data"
INSTALL_PATH="${PRINTER_DATA_PATH}/config/nb.shared"
# This installation script was inspired by and borrows from:
# https://github.com/protoloft/klipper_z_calibration/blob/master/install.sh
verify_ready()
{
if [ "$EUID" -eq 0 ]; then
echo "This script must not run as root"
exit -1
fi
}
setup_files()
{
# macros
mkdir -p "${INSTALL_PATH}"
ln -sf "${SRC_DIR}/macros" "${INSTALL_PATH}"
ln -sf "${SRC_DIR}/menus" "${INSTALL_PATH}"
# If git is being used by this machine, add shared to the gitignore
if [ -d "${PRINTER_DATA_PATH}/.git" ]; then
touch "${PRINTER_DATA_PATH}/.gitignore"
IGNORE_PRESENT=$(cat "${PRINTER_DATA_PATH}/.gitignore" | grep "config/nb.shared/" | wc -l)
if [ $IGNORE_PRESENT -eq "0" ]; then
echo "config/nb.shared/" >> "${PRINTER_DATA_PATH}/.gitignore"
fi
fi
}
restart_klipper()
{
echo "Restarting Klipper..."
sudo systemctl restart klipper
}
# Force script to exit if an error occurs
set -e
# Find SRCDIR from the pathname of this script
SRC_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/ && pwd )"
# install
verify_ready
setup_files
restart_klipper