SensorsIot / IOTstack

Docker stack for getting started on IOT on the Raspberry PI
GNU General Public License v3.0
1.44k stars 307 forks source link

20220602 InfluxDB 2 - old-menu branch - PR 2 of 3 #568

Closed Paraphraser closed 2 years ago

Paraphraser commented 2 years ago

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 34226495+Paraphraser@users.noreply.github.com