I am trying to install Dietpi on my Raspberry 4 non-interactively with the parameter AUTO_SETUP_AUTOMATED=1. Thereby I install InfluxDB using the parameter AUTO_SETUP_INSTALL_SOFTWARE_ID=74 at the same time. The automatic setup and installation of Dietpi including InfluxDB works without problems.
But now I want to create an admin user and an initial database for Influx right at the end of the installation using the /boot/Automation_Custom_Script.sh script. For this I have modified /boot/Automation_Custom_Script.sh as follows:
#!/bin/bash # Create InfluxDB User + Password and DB sleep 5 influx -execute "CREATE USER admin WITH PASSWORD 't0pSecret!' WITH ALL PRIVILEGES" influx -execute $'CREATE DATABASE "sensor_database"'
Unfortunately, neither the user nor the database are created after the automated installation is complete. In the logs I get the following errors:
Failed to connect to http://localhost:8086: Get http://localhost:8086/ping: dial tcp [::1]:8086: connect: connection refused Please check your connection settings and ensure 'influxd' is running. Failed to connect to http://localhost:8086: Get http://localhost:8086/ping: dial tcp [::1]:8086: connect: connection refused Please check your connection settings and ensure 'influxd' is running.
It seems that the influxd service is not yet started at the time /boot/Automation_Custom_Script.sh is executed. I also don’t seem to have access to the dietpi-services command in the script, which I could use to start Influx:
/root/AUTO_CustomScript.sh: line 11: dietpi-services: command not found
Now the question is if and how it is possible that I can create a user and a database automatically after installing Dietpi and the InfluxDB service non-interactively.