-
Notifications
You must be signed in to change notification settings - Fork 13
/
install_for_mainsailos.sh
executable file
·72 lines (51 loc) · 1.89 KB
/
install_for_mainsailos.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
#!/bin/bash
echo "#####################################"
echo "DGUS for Klipper (MainsailOS Install)"
echo "#####################################"
#Check that script is exectuted in klipper-dgus folder
if [ "${0%/*}" != "." ]
then echo "The script needs to be runned from 'klipper-dgus' folder"
exit
fi
#Install python3-venv
echo -e "\nInstalling python3-venv package"
sudo apt-get install python3-venv -y
echo -e "\nCreating Python Virtual Environment"
if [ -d ./venv ]; then
echo "Found existing Python Virtual Environment"
echo "Removing it..."
rm -rf ./venv
fi
python3 -m venv venv
echo "Created Python Virtual Environment"
echo -e "\nActivating Python Virtual Environment"
source ./venv/bin/activate
echo -e "\nInstalling python dependencies"
pip3 install -r requirements.txt
echo -e "\nCopying config to klipper_config"
conf_dir=/home/$(whoami)/printer_data/config/dgus_display
mkdir -p $conf_dir
cp config/* $conf_dir
echo -e "\nCreating systemd service (autostart)"
#replace variables in template
cp klipper_dgus.service.templ klipper_dgus.service.tmp
dgus_dir=$(pwd)
user=$(whoami)
#set dgus-klipper folder in service
sed -i "s|<dgus_dir>|$dgus_dir|g" klipper_dgus.service.tmp
sed -i "s|<config_dir>|$conf_dir|g" klipper_dgus.service.tmp
sed -i "s|<user>|$user|g" klipper_dgus.service.tmp
echo -e "\nInstalling DGUS for Klipper Service"
sudo cp klipper_dgus.service.tmp /etc/systemd/system/klipper_dgus.service
rm klipper_dgus.service.tmp
echo -e "\nReloading systemd services..."
sudo systemctl daemon-reload
echo -e "\nEnabling dgus_klipper.service"
sudo systemctl enable klipper_dgus.service
echo -e "\nStarting initial configuration"
echo -e "\n"
python3 src/config_edit.py -c $conf_dir
echo -e "\nDisplay should be available in arround 15 seconds"
sudo systemctl start klipper_dgus
echo -e "\nYou also need to include the 'dgus_display_macros.cfg' file in your printer.cfg"
exit