-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontesting_script.sh
168 lines (153 loc) · 4.57 KB
/
contesting_script.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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/bin/bash
## ---- Functions ----- ##
#Create ProgressBar function
function ProgressBar {
# Process data
let _progress=(${1}*100/${2}*100)/100
let _done=(${_progress}*4)/10
let _left=40-$_done
# Build progressbar string lengths
_done=$(printf "%${_done}s")
_left=$(printf "%${_left}s")
# Output example:
# Progress : [########################################] 100%
printf "\rProgress : [${_done// /#}${_left// /-}] ${_progress}%%"
}
# Variables
_start=1
_end=100
clear
## ---- Initial Questioning ---- ##
printf "Welcome to the NodeRed Dashboards.\nPlease hit enter to continue. "
read
echo "Are you wanting to update Node-Red?"
echo -n "Only choose no if you have installed Node-red all ready on this machine. Most people will choose Yes."
read -p "(Y/n) " flag_update
echo "Are you wanting to update the Dashboard? Note this will not delete your data."
read -p "(Y/n) " dashboard_update
# Are you a dev?
read -p "Are you planning to help develop any of the dashboards? (y/N)" flag_dev
if [[ $flag_dev == 'Y' || $flag_dev == 'y' ]] ; then
read -p "What is your Github Username?" git_username
read -p "What is your Github Email?" git_email
else
git_username=nobody
fi
## ---- Update RPI ---- ##
if [[ $flag_update != 'n' ]] && [[ $flag_update != 'N' ]]; then
echo "Updating and Upgrading your Pi to newest standards"
for number in $(seq ${_start} ${_end})
do
sleep 2
ProgressBar ${number} ${_end}
done &
bgid=$!
sudo apt-get update -qq > /dev/null && sudo apt-get full-upgrade -qq -y > /dev/null && sudo apt-get clean > /dev/null
kill $bgid
wait
ProgressBar ${_end} ${_end}
# -- Install Node-Red -- #
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) <<!
y
y
!
wait
clear
echo "**NodeRed Dashboard Status**"
echo "Updating and Upgrading your Pi to newest standards Y"
echo "Install and Update NodeRed Y"
fi
# -- Install git & Sqlite3 -- #
sudo apt-get install git sqlite3 -y -qq > /dev/null
echo "Install Git & Sqlite Y"
wait
# Configure SQLITE
cd $HOME
curl -sL https://raw.githubusercontent.com/kylekrieg/Node-Red-Contesting-Dashboard/master/schema.db > schema_init
sqlite3 qsos < schema_init
#configure NodeRed
sudo systemctl stop nodered.service
wait
cd $HOME/.node-red
npm install @node-red-contrib-themes/theme-collection --silent &> /dev/null
curl -sL -o settings.js https://raw.githubusercontent.com/kd9lsv/Node-Red-AutoScripts/master/settings.js
if [[ ! -d projects ]] ; then
mkdir projects
fi
cd projects
echo -n "Cloning the Node-Red Dashboard"
cat > .config.users.json <<EOL
{
"_": {
"editor": {
"view": {
"view-store-zoom": false,
"view-store-position": false,
"view-show-grid": true,
"view-snap-grid": true,
"view-grid-size": "20",
"view-node-status": true,
"view-node-show-label": true,
"view-show-tips": true,
"view-show-welcome-tours": true
},
"tours": {
"welcome": "3.0.0"
}
},
"git": {
"user": {
"name": "$git_username",
"email": "$git_email"
},
"workflow": {
"mode": "manual"
}
},
"debug": {
"filter": "filterAll",
"filteredNodes": []
}
}
}
EOL
if [[ $dashboard_update != 'n' ]] && [[ $dashboard_update != 'N' ]]; then
if [[ ! -d Node-Red-Contesting-Dashboard ]] ; then
git clone https://github.com/kylekrieg/Node-Red-Contesting-Dashboard.git --quiet
cd ~/.node-red/projects/Node-Red-Contesting-Dashboard
else
cd ~/.node-red/projects/Node-Red-Contesting-Dashboard
git config pull.rebase true
git restore flow.json
git pull &> /dev/null
fi
echo " Y"
echo "**The next step will take around 10 minutes. Please be patient.**"
echo -n "Install modules for Contesting Dashboard."
npm config set jobs 4
for number in $(seq ${_start} ${_end})
do
sleep 5
ProgressBar ${number} ${_end}
done &
bgid=$!
npm --prefix ~/.node-red/ install ~/.node-red/projects/Node-Red-Contesting-Dashboard/ --silent &> /dev/null
ProgressBar ${_end} ${_end}
kill $bgid
wait
cd ~/.node-red/
cat > .config.projects.json <<EOL
{
"activeProject": "Node-Red-Contesting-Dashboard",
"projects": {}
}
EOL
echo " Y"
fi
sudo systemctl enable --now nodered.service
HOSTIP=`hostname -I | cut -d ' ' -f 1`
if [ "$HOSTIP" = "" ]; then
HOSTIP="127.0.0.1"
fi
echo "Node Red has Completed. Head to http://$HOSTIP:1880/ui to access the Contest Dashboard."