forked from ekozan/vcore-idex
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
135 lines (121 loc) · 3.75 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Prevent running as root.
if [ ${UID} == 0 ]; then
echo -e "DO NOT RUN THIS SCRIPT AS 'root' !"
echo -e "If 'root' privileges needed, you will prompted for sudo password."
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 )"
# Default Parameters
MAINSAIL_DIR="${HOME}/mainsail"
CONFIG_DIR="${HOME}/printer_data/config"
KLIPPY_EXTRAS="${HOME}/klipper/klippy/extras"
KLIPPY_KINEMATICS="${HOME}/klipper/klippy/kinematics"
function start_klipper {
sudo systemctl restart klipper
}
function stop_klipper {
if [ "$(sudo systemctl list-units --full -all -t service --no-legend | grep -F "klipper.service")" ]; then
sudo systemctl stop klipper
else
echo "Klipper service not found, please install Klipper first"
exit 1
fi
}
function link_custom_folder {
if [ -d "${CONFIG_DIR}" ]; then
if [ -d "${CONFIG_DIR}/custom" ]; then
echo -e "${CONFIG_DIR}/custom already exists, skipping..."
else
ln -s ${SRCDIR}/klipper_config/custom ${CONFIG_DIR}/custom
echo -e "custom folder linked"
fi
else
echo -e "ERROR: ${CONFIG_DIR} not found."
exit 1
fi
}
function copy_variables_file {
if [ -d "${CONFIG_DIR}" ]; then
if [ ! -e "${CONFIG_DIR}/ratos-variables.cfg" ]
then
cp "${SRCDIR}/klipper_config/ratos-variables.cfg" "${CONFIG_DIR}/ratos-variables.cfg"
echo -e "variables file copied"
fi
else
echo -e "ERROR: ${CONFIG_DIR} not found."
exit 1
fi
}
function copy_board_files {
if [ -d "${CONFIG_DIR}" ]; then
sudo cp -av "${SRCDIR}/klipper_config/RatOS/boards/btt-ebb42-12b" "${CONFIG_DIR}/RatOS/boards"
echo -e "BTT EBB42 V1.2 board files copied"
sudo cp -av "${SRCDIR}/klipper_config/RatOS/boards/btt-ebb36-12b" "${CONFIG_DIR}/RatOS/boards"
echo -e "BTT EBB36 V1.2 board files copied"
else
echo -e "ERROR: ${CONFIG_DIR} not found."
exit 1
fi
}
function copy_example_cfg {
if [ -d "${CONFIG_DIR}" ]; then
cp "${SRCDIR}/klipper_config/printer.cfg" "${CONFIG_DIR}/idex_printer.cfg"
echo -e "example idex_printer.cfg copied"
else
echo -e "ERROR: ${CONFIG_DIR} not found."
exit 1
fi
}
function link_klippy_extras {
if [ -d "${KLIPPY_EXTRAS}" ]; then
rm -f "${KLIPPY_EXTRAS}/zoffsetprobe.py"
ln -sf "${SRCDIR}/klippy/extras/zoffsetprobe.py" "${KLIPPY_EXTRAS}/zoffsetprobe.py"
else
echo -e "ERROR: ${KLIPPY_EXTRAS} not found."
exit 1
fi
}
function link_klippy_kinematics {
if [ -d "${KLIPPY_KINEMATICS}" ]; then
rm -f "${KLIPPY_KINEMATICS}/hybrid_corexy.py"
ln -sf "${SRCDIR}/klippy/kinematics/hybrid_corexy.py" "${KLIPPY_KINEMATICS}/hybrid_corexy.py"
else
echo -e "ERROR: ${KLIPPY_KINEMATICS} not found."
exit 1
fi
}
function copy_modified_release_info {
if [ -d "${MAINSAIL_DIR}" ]; then
cp "${SRCDIR}/assets/release_info.json" "${MAINSAIL_DIR}/release_info.json"
echo -e "modified release_info.json copied"
else
echo -e "ERROR: ${MAINSAIL_DIR} not found."
fi
}
function update_udev_rules {
if [ -d "${CONFIG_DIR}" ]; then
sudo ~/printer_data/config/RatOS/scripts/ratos-update.sh
echo -e "Udev rules updated"
else
echo -e "ERROR: ${CONFIG_DIR} not found."
exit 1
fi
}
echo -e "V-Core RatOS IDEX"
stop_klipper
link_custom_folder
copy_variables_file
copy_board_files
copy_example_cfg
link_klippy_extras
link_klippy_kinematics
copy_modified_release_info
update_udev_rules
start_klipper
echo -e ""
echo -e "Installation finished!"
echo -e ""
exit 0