-
Notifications
You must be signed in to change notification settings - Fork 1
/
install_filament.sh
87 lines (69 loc) · 2.12 KB
/
install_filament.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
#!/bin/bash
sudo apt install wiringpi
echo -e "\n\n========= Filament Runout - Installation Script ==========="
echo -e "\n\n========= pleas input your settings description on github ==========="
echo -e "\n\nyour server Ip:"
read ip
echo "your server port:"
read port
echo "your printername:"
read printer
echo "your apikey:"
read apikey
echo "your sensor (normaly open(1)/closed(0)):"
read sensor
echo "your Gpio Pin (use WiringPi Pin):"
read pin
echo "the number of sensors is?: (1,2,3...)"
read number
echo -e "\n\n========= check variables ==========="
if [ -z "$ip" ] ; then
echo 'please enter server IP!'
exit 1
fi
if [ -z "$port" ] ; then
echo 'please enter server port!'
exit 1
fi
if [ -z "$printer" ] ; then
echo 'please enter printername!'
exit 1
fi
if [ -z "$apikey" ] ; then
echo 'please enter apikey!'
exit 1
fi
if [ -z "$sensor" ] ; then
echo 'please enter sensor (normaly open (0) or closed (1))!'
exit 1
fi
if [ -z "$pin" ] ; then
echo 'please enter Gpio pin !'
exit 1
fi
if [ -z "$number" ] ; then
echo 'please enter number for sensor !'
exit 1
fi
mkdir sensor_"$number"
cd sensor_"$number"
echo -e "\n\n========= creat Filament_config.sh ==========="
sleep 1
echo "#######Server/Sensor Config#########" > Filament_config.sh
echo "ip="$ip"" >> Filament_config.sh
echo "port="$port"" >> Filament_config.sh
echo "printer="$printer"" >> Filament_config.sh
echo "apikey="$apikey"" >> Filament_config.sh
echo "sensor="$sensor"" >> Filament_config.sh
echo "pin="$pin"" >> Filament_config.sh
echo "#######Config End#########" >> Filament_config.sh
cp -l /home/pi/filament_runout_Repetier/filament.sh filament_"$number".sh
sleep 1
chmod 755 filament_"$number".sh
chmod 755 Filament_config.sh
echo -e "\n\n========= installation autostart ==========="
crontab -u pi -l | grep -v "cd /home/pi/filament_runout_Repetier/sensor_"$number" && sh filament_"$number".sh &" | crontab -u pi -
sleep 1
(crontab -u pi -l ; echo "@reboot cd /home/pi/filament_runout_Repetier/sensor_"$number" && sh filament_"$number".sh &") | crontab -u pi -
echo -e "\n\n========= installation end ==========="
exit 1