forked from feelfreelinux/octo4a
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-klipper.sh
57 lines (46 loc) · 1.64 KB
/
setup-klipper.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
#!/bin/bash
COL='\033[1;32m'
NC='\033[0m' # No Color
echo -e "${COL}Setting up klipper for Octo4a v2.x"
# Prepare venv for klipper
python3 -m venv ~/klipper-venv
echo -e "${COL}\nDownloading klipper...\n${NC}"
cd ~/
git clone https://github.com/KevinOConnor/klipper
~/klipper-venv/bin/pip install -r ./klipper/scripts/klippy-requirements.txt
# Prepare necessary directories
mkdir ~/printer_data/
mkdir ~/printer_data/logs
mkdir ~/printer_data/gcodes
mkdir ~/printer_data/systemd
mkdir ~/printer_data/comms
touch ~/printer.cfg
echo -e "${COL}\nInserting configurations...\n${NC}"
mkdir -p /mnt/external/extensions/klipper
cat << EOF > /mnt/external/extensions/klipper/manifest.json
{
"title": "Klipper plugin",
"description": "Runs Klipper"
}
EOF
cat << EOF > /mnt/external/extensions/klipper/start.sh
#!/bin/sh
KLIPPER_ARGS="/root/klipper/klippy/klippy.py /root/printer.cfg -l /root/printer_data/logs/klippy.log -I /root/printer_data/comms/klippy.serial -a /root/printer_data/comms/klippy.sock"
LD_PRELOAD=/home/octoprint/ioctl-hook.so /root/klipper-venv/bin/python \$KLIPPER_ARGS &
EOF
cat << EOF > /mnt/external/extensions/klipper/kill.sh
#!/bin/sh
pkill -f 'klippy\.py'
EOF
chmod +x /mnt/external/extensions/klipper/start.sh
chmod +x /mnt/external/extensions/klipper/kill.sh
chmod 777 /mnt/external/extensions/klipper/start.sh
chmod 777 /mnt/external/extensions/klipper/kill.sh
cat << EOF
${COL}
Klipper installed!
Please kill the app and restart it again to see it in extension settings${NC}
Set your OctoKlipper plugin settings:
Serial Port: /root/printer_data/comms/klippy.serial
Klipper Log File: /root/printer_data/logs/klippy.log
EOF