-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbrc.sh
More file actions
119 lines (91 loc) · 2.83 KB
/
brc.sh
File metadata and controls
119 lines (91 loc) · 2.83 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
#
# This is the main start download script for the Barclays Robotics Challenge build
# Can be used on any Ubuntu based build - with Arduino and Processing already installed
# Processing must be configured to use sketchbook and Arduino to use sketches in /home/roboteer or
# the user thats been used to run the config
#
confirm () {
# call with a prompt string or use a default
read -r -p "${1:-Are you sure? [y/N]} " response
case $response in
[yY][eE][sS]|[yY])
true
;;
*)
false
;;
esac
}
confirmLocal () {
# call with a prompt string or use a default
read -r -p "${1:-Are you sure? [y/N]} " response
case $response in
[lL])
true
;;
*)
false
;;
esac
}
if ! confirm "Warning do you want to download and replace your build ?" ; then
exit
fi
(set -o igncr) 2>/dev/null && set -o igncr; # this comment is needed
if confirmLocal "Local or Remote refresh ?" ; then
localRefresh=true
else
localRefresh=false
fi
MASTER_LOCATION="https://github.com/daverobertson63/RoboticsChallenge.git"
if [ $localRefresh == false ]; then
echo "You must be connected to the Internet to refresh the sketches folder"
echo "Checking to see if you are...."
command -v git >/dev/null 2>&1 || { sudo apt-get -y install git; }
echo "Platform type: " $(uname)
if [ "$(uname)" == "Darwin" ]; then
echo "Mac"
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
ping_cmd='ping -q -c'
#echo "Linux"
elif [ "$(expr substr $(uname -s) 1 19)" == "CYGWIN_NT-6.2-WOW64" ]; then
ping_cmd="$SYSTEMROOT/system32/ping -n"
#echo "Cygwin"
else
ping_cmd="$SYSTEMROOT/system32/ping -n"
fi
net_check_target="www.google.com"
connected=`$ping_cmd 1 $net_check_target &> /dev/null && echo 1 || echo 0`
if [ $connected == 0 ]; then
echo "Not connected, cannot refresh"
exit -1
fi
# Do a clone and deal with it
rm -rf RoboticsChallenge
git clone $MASTER_LOCATION
else
echo "This will be a local refresh - all sketches will be deleted"
fi
# Remove everything from the master location locally
echo "Removing all existing data... "
rm -rf sketches
rm -rf sketches.zip.*
rm -rf sketches.zip
rm -rf dhrobertson.com
rm -f refresh_remote.sh*
rm -f refresh_local.sh*
rm -rf Desktop/Re*.desktop
echo "Copying all folders to sketches"
mkdir sketches
find RoboticsChallenge -maxdepth 1 -mindepth 1 -type d -exec cp -r {} sketches \;
rm -rf sketches/.git
rm -rf sketches/Demos
rm -rf sketches/Projects
rm -rf sketches/Testing
# Copy the latest script down to replace this one running
cp "RoboticsChallenge/BRC Refresh.desktop" ~/Desktop
echo "Fully Installed - restart Arduino or Processing to test"
echo "Upgrading brc.sh - this will only work next time you run"
cp RoboticsChallenge/brc.sh .
chmod +x brc.sh