A few oddities with the installation scripts - user name and lsb_release

Hi all,

I’m doing a complete reinstall of EmonCMS on my RPi2 since Debian 10 is a bit out of date. The PHP kerfuffle has motivated me to patch and update things.

I’ve used the DietPI distro rather than Raspberry Pi OS and it’s mostly been trouble free, but the final steps of the ./main.sh install script have thrown up some errors. It looks to me like the script is not making use of the 'user=' variable in config.ini

DietPI’s default user is ‘dietpi’ rather than ‘pi’, and so I set this in the top of config.ini:

user=dietpi

This has been picked up in some places, with messages like:

installing emonhub drop-in User=dietpi
…
usermod: group ‘docker’ does not exist
Current user ‘dietpi’ added to docker group.
– disable docker.service for now

Now for the errors:

-- Installing /home/pi/readme.md
ln: failed to create symbolic link ‘/home/pi/’: No such file or directory

and

-- install default network module config
chown: invalid user: ‘pi:pi’

[Edit 2 update] I found more places where pi is hard coded: the service definitions in emoncms_mqtt.service and emonhub.service. Fixing those up let the services start.

The hard coded pi user would affect someone installing under Ubuntu or with a different user on RPiOS too.

It also looks like PHP hasn’t been installed because of errors in sury-php.list, which look due to be a missing lsb_release program (no ‘trixie’ in the deb line). I’ve never seen lsb_release missing before (DietPi optimisation?), but it might be worth including it in the apt packages to be installed just in case since it’s needed to create the DEB line for apt.

./php.sh: line 27: lsb_release: command not found
deb [signed-by=/usr/share/keyrings/suryphp-archive-keyring.gpg] Index of /php/ main
E: Malformed entry 1 in list file /etc/apt/sources.list.d/sury-php.list (Component)
E: The list of sources could not be read.

Once I installed lsb-release with apt, the php.sh script ran without error messages.

deb [signed-by=/usr/share/keyrings/suryphp-archive-keyring.gpg] Index of /php/ trixie main

I needed to run redis.sh, but that wasn’t enough to get rid of the “Your PHP installation appears to be missing the Redis extension” message. A manual install of php-redis using apt was needed. That looks to have pushed PHP to version 8.5, so then I needed to install the PHP 8.5 modules and restart Apache. But then the MQTT plugin didn’t work, so I set PHP back to 8.4 (sudo update-alternatives --config php) and re-ran the mqtt.sh script (had to delete the Mosquitto-PHP directory first).

I now have fresh data coming in, and it’s all on a modern OS that’s nice and light. root is using 2.9G and /var/opt/emoncms is using 216M (with data going back 7 years migrated).

The default user of pi has been an issue for a while.

Last time I used DietPi, I think I installed Apache, PHP etc from DietPi rather than the emoncms scripts (so Diet Pi can then maintain it. At one point emoncms was installable directly from DietPi.

I agree it would be better if the install scripts were more robust for non RPi systems. @TrystanLea

Might be something Claude can help with.