-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathinstall.sh
executable file
·61 lines (49 loc) · 2.08 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
#!/bin/bash
# Copyright (C) Cartographer3D 2023-2024
# Based upon the fantastic Beacon eddy current scanner support
# Copyright (C) 2020-2023 Matt Baker <[email protected]>
# Copyright (C) 2020-2023 Lasse Dalegaard <[email protected]>
# Copyright (C) 2023 Beacon <beacon3d.com>
# This file may be distributed under the terms of the GNU GPLv3 license.
KDIR="${HOME}/klipper"
KENV="${HOME}/klippy-env"
IS_K1_OS=0
if grep -Fqs "ID=buildroot" /etc/os-release; then
KDIR="/usr/share/klipper"
KENV="/usr/share/klippy-env"
IS_K1_OS=1
fi
PYTHON_EXEC="$KENV/bin/python"
BKDIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
if [ ! -d "$KDIR" ] || [ ! -d "$KENV" ]; then
echo "Cartographer: klipper or klippy env doesn't exist"
exit 1
fi
# skip trying to setup requirements if running from a K1
if [[ $IS_K1_OS -ne 1 ]]; then
# install Cartographer requirements to env
echo "Cartographer: installing python requirements to env, this may take 10+ minutes."
"${KENV}/bin/pip" install -r "${BKDIR}/requirements.txt"
fi
# update link to scanner.py, cartographer.py & idm.py
echo "Cartographer: linking modules into klipper"
for file in idm.py cartographer.py scanner.py; do
if [ -e "${KDIR}/klippy/extras/${file}" ]; then
rm "${KDIR}/klippy/extras/${file}"
fi
ln -s "${BKDIR}/${file}" "${KDIR}/klippy/extras/${file}"
if ! grep -q "klippy/extras/${file}" "${KDIR}/.git/info/exclude"; then
echo "klippy/extras/${file}" >> "${KDIR}/.git/info/exclude"
fi
done
python_version=$($PYTHON_EXEC -c 'import sys; print(".".join(map(str, sys.version_info[:3])))')
echo "Python version in Klippy environment: $python_version"
# Extract the major version number
major_version=$(echo $python_version | cut -d '.' -f1)
# Check if Python version is less than 3
if [ "$major_version" -lt 3 ]; then
# Display upgrade message in red and require acknowledgment
echo -e "\033[0;31mFor Cartographer to work, you will need to upgrade your Python environment to Python 3.\033[0m"
read -p "Press enter to acknowledge..."
fi
echo "Cartographer Probe: installation successful."