1
1
#! /bin/bash
2
2
3
+ declare -A cont_array=(
4
+ [portainer]=" Portainer"
5
+ [nodered]=" Node-RED"
6
+ [influxdb]=" InfluxDB"
7
+ [telegraf]=" Telegraf (Requires InfluxDB and Mosquitto)"
8
+ [grafana]=" Grafana"
9
+ [mosquitto]=" Eclipse-Mosquitto"
10
+ [postgres]=" Postgres"
11
+ [adminer]=" Adminer"
12
+ [openhab]=" openHAB"
13
+ [zigbee2mqtt]=" zigbee2mqtt"
14
+ [pihole]=" Pi-Hole"
15
+ [plex]=" Plex media server"
16
+ [tasmoadmin]=" TasmoAdmin"
17
+ [rtl_433]=" RTL_433 to mqtt"
18
+ [espruinohub]=" EspruinoHub"
19
+
20
+ )
21
+ declare -a armhf_keys=(" portainer" " nodered" " influxdb" " grafana" " mosquitto" " telegraf" " postgres" " adminer" " openhab" " zigbee2mqtt" " pihole" " plex" " tasmoadmin" " rtl_433" " espruinohub" )
22
+
23
+ sys_arch=$( uname -m)
24
+
3
25
# timezones
4
26
timezones () {
5
27
@@ -38,7 +60,7 @@ function yml_builder() {
38
60
sevice_overwrite=$( whiptail --radiolist --title " Overwrite Option" --notags \
39
61
" $1 service directory has been detected, use [SPACEBAR] to select you overwrite option" 20 78 12 \
40
62
" none" " Do not overwrite" " ON" \
41
- " env" " Preserve Environment and Config file " " OFF" \
63
+ " env" " Preserve Environment and Config files " " OFF" \
42
64
" full" " Pull full service from template" " OFF" \
43
65
3>&1 1>&2 2>&3 )
44
66
@@ -50,7 +72,7 @@ function yml_builder() {
50
72
;;
51
73
" env" )
52
74
echo " ...pulled $1 excluding env file"
53
- rsync -a -q .templates/$1 / services/$1 / --exclude ' build.sh' --exclude ' $1.env' --exclude $( * .conf)
75
+ rsync -a -q .templates/$1 / services/$1 / --exclude ' build.sh' --exclude ' $1.env' --exclude ' *.conf'
54
76
;;
55
77
" none" )
56
78
echo " ...$1 service not overwritten"
@@ -67,6 +89,8 @@ function yml_builder() {
67
89
# if an env file exists check for timezone
68
90
[ -f " ./services/$1 /$1 .env" ] && timezones ./services/$1 /$1 .env
69
91
92
+ # add new line then append service
93
+ echo " " >> docker-compose.yml
70
94
cat $service >> docker-compose.yml
71
95
72
96
# test for post build
@@ -118,23 +142,34 @@ case $mainmenu_selection in
118
142
;;
119
143
# MAINMENU Build stack ------------------------------------------------------------
120
144
" build" )
121
- container_selection=$( whiptail --title " Container Selection" --notags --separate-output --checklist \
122
- " Use the [SPACEBAR] to select which containers you would like to install" 20 78 12 \
123
- " portainer" " Portainer" " ON" \
124
- " nodered" " Node-RED" " ON" \
125
- " influxdb" " InfluxDB" " ON" \
126
- " telegraf" " Telegraf (Requires InfluxDB and Mosquitto)" " OFF" \
127
- " grafana" " Grafana" " ON" \
128
- " mosquitto" " Eclipse-Mosquitto" " ON" \
129
- " postgres" " Postgres" " OFF" \
130
- " adminer" " Adminer" " OFF" \
131
- " openhab" " openHAB" " OFF" \
132
- " zigbee2mqtt" " zigbee2mqtt" " OFF" \
133
- " pihole" " Pi-Hole" " OFF" \
134
- " plex" " Plex media server" " OFF" \
135
- " tasmoadmin" " TasmoAdmin" " OFF" \
136
- " rtl_433" " RTL_433 to mqtt" " OFF" \
137
- 3>&1 1>&2 2>&3 )
145
+
146
+ title=$' Container Selection'
147
+ message=$' Use the [SPACEBAR] to select which containers you would like to install'
148
+ entry_options=()
149
+
150
+ # check architecture and display appropriate menu
151
+ if [ $( echo " $sys_arch " | grep -c " arm" ) ]; then
152
+ keylist=(" ${armhf_keys[@]} " )
153
+ else
154
+ echo " your architecture is not supported yet"
155
+ exit
156
+ fi
157
+
158
+ # loop through the array of descriptions
159
+ for index in " ${keylist[@]} " ; do
160
+ entry_options+=(" $index " )
161
+ entry_options+=(" ${cont_array[$index]} " )
162
+
163
+ # check selection
164
+ if [ -f ./services/selection.txt ]; then
165
+ [ $( grep " $index " ./services/selection.txt) ] && entry_options+=(" ON" ) || entry_options+=(" OFF" )
166
+ else
167
+ entry_options+=(" OFF" )
168
+ fi
169
+ done
170
+
171
+ container_selection=$( whiptail --title " $title " --notags --separate-output --checklist \
172
+ " $message " 20 78 12 -- " ${entry_options[@]} " 3>&1 1>&2 2>&3 )
138
173
139
174
mapfile -t containers <<< " $container_selection"
140
175
@@ -144,10 +179,14 @@ case $mainmenu_selection in
144
179
echo " version: '2'" > docker-compose.yml
145
180
echo " services:" >> docker-compose.yml
146
181
182
+ # store last sellection
183
+ [ -f ./services/selection.txt ] && rm ./services/selection.txt
184
+ touch ./services/selection.txt
147
185
# Run yml_builder of all selected containers
148
186
for container in " ${containers[@]} " ; do
149
187
echo " Adding $container container"
150
188
yml_builder " $container "
189
+ echo " $container " >> ./services/selection.txt
151
190
done
152
191
153
192
echo " docker-compose successfully created"
@@ -221,6 +260,7 @@ case $mainmenu_selection in
221
260
" rclone" )
222
261
sudo apt install -y rclone
223
262
echo " Please run 'rclone config' to configure the rclone google drive backup"
263
+
224
264
# add enable file for rclone
225
265
[ -d ~ /IOTstack/backups ] || sudo mkdir -p ~ /IOTstack/backups/
226
266
sudo touch ~ /IOTstack/backups/rclone
0 commit comments