Skip to content

Commit 53018f2

Browse files
committed
20220602 InfluxDB 2 - old-menu branch - PR 2 of 3
Adds InfluxDB 2 container. Documentation on Master branch. `menu.sh` changes: 1. Adds InfluxDB 2 to menu. 2. Removes problematic if-test, renames `armhf_keys` array to `keylist`, removes `sys_arch` declaration. Rationale: - Original code fragments: ``` declare -a armhf_keys=( ... ) sys_arch=$(uname -m) ``` ``` if [ $(echo "$sys_arch" | grep -c "arm") ]; then keylist=("${armhf_keys[@]}") else echo "your architecture is not supported yet" exit fi ``` - Analysis: 1. The if test always succeeds because it is testing the exit-code of `grep` rather than the value returned by the `-c` option. 2. This explains why the old menu has been working when `uname -m` returns "aarch64" on Pis with a 64-bit kernel (if not necessarily a 64-bit user mode). It also explains why old-menu works on macOS with Docker Desktop when `uname -m` returns "x86_64" (or who-knows-what on M1 Macs). The logical conclusion is that the intended "architecture check" was never necessary and should be removed. Removal continues the current desirable multi-arch behaviour whereas repairing the code would break any system that wasn't full 32-bit arm. 3. The only effect of the if-test always succeeding is to copy `armhf_keys` to `keylist`. Aside from its declaration, the if-test is the only place `armhf_keys` is referenced so the copy operation can be avoided by renaming `armhf_keys` to `keylist`, and removing the if-test entirely. The only place `keylist` is referenced is the for-loop immediately below the if-test. Also, `keylist` implies nothing about platform architecture so it is a better descriptor than `armhf_keys`. It's really an index-lookup mechanism. 4. Finally, aside from its declaration/assignment, the if-test is the only place where `sys_arch` is referenced so that declaration can be removed too. 3. Pattern-matching against `./services/selection.txt` does not check for exact whole-of-line match. This means "influx" will match "influxdb2" (but not vice versa). This is actually a long-standing problem for other new-release containers like Portainer vs Portainer-CE. Signed-off-by: Phill Kelley <[email protected]>
1 parent 37937ff commit 53018f2

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

.templates/influxdb2/service.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
influxdb2:
2+
container_name: influxdb2
3+
image: "influxdb:latest"
4+
restart: unless-stopped
5+
environment:
6+
- TZ=Etc/UTC
7+
- DOCKER_INFLUXDB_INIT_USERNAME=me
8+
- DOCKER_INFLUXDB_INIT_PASSWORD=mypassword
9+
- DOCKER_INFLUXDB_INIT_ORG=myorg
10+
- DOCKER_INFLUXDB_INIT_BUCKET=mybucket
11+
- DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=my-super-secret-auth-token
12+
- DOCKER_INFLUXDB_INIT_MODE=setup
13+
# - DOCKER_INFLUXDB_INIT_MODE=upgrade
14+
ports:
15+
- "8087:8086"
16+
volumes:
17+
- ./volumes/influxdb2/data:/var/lib/influxdb2
18+
- ./volumes/influxdb2/config:/etc/influxdb2
19+
- ./volumes/influxdb2/backup:/var/lib/backup
20+
# - ./volumes/influxdb.migrate/data:/var/lib/influxdb:ro
21+
healthcheck:
22+
test: ["CMD", "influx", "ping"]
23+
interval: 30s
24+
timeout: 10s
25+
retries: 3
26+
start_period: 30s

menu.sh

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ declare -A cont_array=(
2424
[portainer_agent]="Portainer agent"
2525
[nodered]="Node-RED"
2626
[influxdb]="InfluxDB"
27+
[influxdb2]="InfluxDB 2 (requires full 64-bit OS)"
2728
[telegraf]="Telegraf (Requires InfluxDB and Mosquitto)"
2829
[chronograf]="Chronograf (Requires InfluxDB, Kapacitor optional)"
2930
[kapacitor]="Kapacitor (Requires InfluxDB)"
@@ -65,11 +66,12 @@ declare -A cont_array=(
6566
# add yours here
6667
)
6768

68-
declare -a armhf_keys=(
69+
declare -a keylist=(
6970
"portainer-ce"
7071
"portainer_agent"
7172
"nodered"
7273
"influxdb"
74+
"influxdb2"
7375
"grafana"
7476
"mosquitto"
7577
"telegraf"
@@ -109,7 +111,6 @@ declare -a armhf_keys=(
109111
"home_assistant"
110112
# add yours here
111113
)
112-
sys_arch=$(uname -m)
113114

114115
#timezones
115116
timezones() {
@@ -455,22 +456,14 @@ case $mainmenu_selection in
455456
message=$'Use the [SPACEBAR] to select which containers you would like to install'
456457
entry_options=()
457458

458-
#check architecture and display appropriate menu
459-
if [ $(echo "$sys_arch" | grep -c "arm") ]; then
460-
keylist=("${armhf_keys[@]}")
461-
else
462-
echo "your architecture is not supported yet"
463-
exit
464-
fi
465-
466459
#loop through the array of descriptions
467460
for index in "${keylist[@]}"; do
468461
entry_options+=("$index")
469462
entry_options+=("${cont_array[$index]}")
470463

471464
#check selection
472465
if [ -f ./services/selection.txt ]; then
473-
[ $(grep "$index" ./services/selection.txt) ] && entry_options+=("ON") || entry_options+=("OFF")
466+
[ $(grep "^$index\$" ./services/selection.txt) ] && entry_options+=("ON") || entry_options+=("OFF")
474467
else
475468
entry_options+=("OFF")
476469
fi

0 commit comments

Comments
 (0)