#!/bin/bash

cd build/firmware

if [ $1 == "start" ]; then
	if [ ! -d "unified" ]; then
		git clone https://github.com/opensprinkler/opensprinklergen2 unified
	fi
	cd unified
	./build_demo.sh
	./OpenSprinkler >/dev/null 2>&1 &
	echo $! > pid
	sleep 5
else
	kill -9 `cat unified/pid`
	rm unified/pid
	sleep 5
fi

#!/bin/bash

cd build/firmware

if [ $1 == "start" ]; then
	git clone https://github.com/opensprinkler/opensprinklergen2 unified
	cd unified
	./build_demo.sh
	./OpenSprinkler >/dev/null 2>&1 &
	echo $! > pid
	sleep 5
else
	kill -9 `cat unified/pid`
	rm unified/pid
	sleep 5
fi

--- 
+++ 
@@ -3,7 +3,9 @@
 cd build/firmware
 
 if [ $1 == "start" ]; then
-	git clone https://github.com/opensprinkler/opensprinklergen2 unified
+	if [ ! -d "unified" ]; then
+		git clone https://github.com/opensprinkler/opensprinklergen2 unified
+	fi
 	cd unified
 	./build_demo.sh
 	./OpenSprinkler >/dev/null 2>&1 &
Test: Check if directory exists before cloning demo
