forked from dolenle/OpenSprinkler-Firmware-Hunter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·63 lines (49 loc) · 1.79 KB
/
build.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
#!/bin/bash
while getopts ":s" opt; do
case $opt in
s)
SILENT=true
command shift
;;
esac
done
echo "Building OpenSprinkler..."
if [ "$1" == "demo" ]; then
echo "Installing required libraries..."
apt-get install -y libmosquitto-dev
echo "Compiling firmware..."
g++ -o OpenSprinkler -DDEMO -m32 main.cpp OpenSprinkler.cpp program.cpp server.cpp utils.cpp weather.cpp gpio.cpp etherport.cpp mqtt.cpp -lpthread -lmosquitto
elif [ "$1" == "osbo" ]; then
echo "Installing required libraries..."
apt-get install -y libmosquitto-dev
echo "Compiling firmware..."
g++ -o OpenSprinkler -DOSBO main.cpp OpenSprinkler.cpp program.cpp server.cpp utils.cpp weather.cpp gpio.cpp etherport.cpp mqtt.cpp -lpthread -lmosquitto
else
echo "Installing required libraries..."
apt-get install -y libmosquitto-dev
echo "Compiling firmware..."
g++ -o OpenSprinkler -DOSPI main.cpp OpenSprinkler.cpp program.cpp server.cpp utils.cpp weather.cpp gpio.cpp etherport.cpp mqtt.cpp -lpthread -lmosquitto
fi
if [ ! "$SILENT" = true ] && [ -f OpenSprinkler.launch ] && [ ! -f /etc/init.d/OpenSprinkler.sh ]; then
read -p "Do you want to start OpenSprinkler on startup? " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 0
fi
echo "Adding OpenSprinkler launch script..."
# Get current directory (binary location)
pushd `dirname $0` > /dev/null
DIR=`pwd`
popd > /dev/null
# Update binary location in start up script
sed -e 's,\_\_OpenSprinkler\_Path\_\_,'"$DIR"',g' OpenSprinkler.launch > OpenSprinkler.sh
# Make file executable
chmod +x OpenSprinkler.sh
# Move start up script to init.d directory
sudo mv OpenSprinkler.sh /etc/init.d/
# Add to auto-launch on system startup
sudo update-rc.d OpenSprinkler.sh defaults
# Start the deamon now
sudo /etc/init.d/OpenSprinkler.sh start
fi
echo "Done!"