-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathOpen Inverter.sh
executable file
·60 lines (51 loc) · 1.35 KB
/
Open Inverter.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
#!/usr/bin/env bash
checkUSB()
{
echo "\nReminder: Use RS232-TTL adapter, USB-RS232 is not enough\n"
shopt -s nocasematch
for i in {0..30} ; do
serial=$(ls /dev/ttyUSB* | tail -n 1) || echo ""
if [[ $serial == *"usb"* ]]; then
echo "{
\"serial\": {
\"port\": \"$serial\",
\"web\": 8080,
\"timeout\": 12,
\"speed\": 115200
}
}" > "$(dirname "$0")/Web/js/serial.json"
/usr/bin/firefox http://localhost:8080;bash
return
fi
echo "... Waiting for USB-RS232-TTL"
if [[ $i -eq 1 ]]; then
/usr/bin/firefox http://localhost:8080/connect.html;bash
fi
sleep 2
done
}
if [[ $(type -p php) ]]; then
if id -nG "$USER" | grep -qw "dialout"; then
echo "Permissions OK"
else
echo "... Fixing dialout permissions"
sudo usermod -a -G dialout $USER
sudo usermod -a -G tty $USER
fi
for file in ./Linux/*; do
chmod +x "$file"
done
if [[ $(php -m | grep curl) == "curl" ]]; then
echo "PHP Installed"
else
echo "PHP-CURL not Installed ...Install? [Y/n]"; read
./Linux/php.sh
fi
killall php
php -S 0.0.0.0:8080 -t "$(dirname "$0")/Web/" &
sleep 4
checkUSB
else
echo "PHP not Installed ...Install? [Y/n]"; read
./Linux/php.sh
fi