@Panzermann
Not sure if you want your login user (or root) to activate the pyenv environment and even if so, if you want to have the pyenv activated throughout all the shell session?
I would in every case create a script which contains pyenv activation and starts the software, this script can then be started via dietpi-postboot or systemd unit.
If this is a oneshot task, hence it does its job quickly and then exits, your could place the script into
/var/lib/dietpi/postboot.d/, which will run at the end of boot by root user.
If you want to run it as unprivileged user and/or if it is a background service that stays active in background, create a systemd unit. Here an example how we do this with Home Assistant:
Code: Select all
echo '#!/bin/dash
cd /path/to/script
export PATH="/path/to/script/.pyenv/bin:$PATH"
eval "$(pyenv init -)"' > /path/to/script/pyenv-activate.sh
Code: Select all
echo '#!/bin/dash
. /path/to/script/pyenv-activate.sh
command to start software' > /path/to/script/script_name-start.sh
Code: Select all
echo '[Unit]
Description=Script description
After=dietpi-postboot.service
[Service]
SyslogIdentifier=script_name
User=user_name
ExecStart=/path/to/script/script_name-start.sh
[Install]
WantedBy=multi-user.target' > /etc/systemd/system/script_name.service
systemctl daemon-reload
systemctl enable --now script_name
Replace
/path/to/script user_name and
script_name to your needs.
After=dietpi-postboot.service is to have it running right when login prompts appear, hence after most boot tasks have finished.