DietPi version information Topic is solved

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
svh1985
Posts: 5
Joined: Sat Oct 27, 2018 11:39 am

DietPi version information

Post by svh1985 »

Hi there,

Is there a command to output the installed version of DietPi?
And also; is there a similar command to check the latest one available?

I want to add this information to my Home Assistant overview like this:
Screenshot 2019-05-15 at 14.15.45.png
Screenshot 2019-05-15 at 14.15.45.png (29.02 KiB) Viewed 1795 times
Thanks!
User avatar
MichaIng
Site Admin
Posts: 3089
Joined: Sat Nov 18, 2017 6:21 pm

Re: DietPi version information

Post by MichaIng »

@svh1985
/DietPi/dietpi/.version contains the installed version info. This is sourced to the login bash session, so you can run:
echo "$G_DIETPI_VERSION_CORE.$G_DIETPI_VERSION_SUB.$G_DIETPI_VERSION_RC"

From within programs/scripts you either need to source the file as well or use grep/mawk/sed or something similar to scrape the version string.
svh1985
Posts: 5
Joined: Sat Oct 27, 2018 11:39 am

Re: DietPi version information

Post by svh1985 »

Perfect that works!
And what about getting the latest version that is available to download? I want to create a notification in Home Assistant to notify me when a new version of DietPi is available. 8)

Is this the place where DietPi checks the latest version available:
https://raw.githubusercontent.com/Micha ... _version-6

Thanks!!
User avatar
MichaIng
Site Admin
Posts: 3089
Joined: Sat Nov 18, 2017 6:21 pm

Re: DietPi version information

Post by MichaIng »

If the update check (dietpi-update 2, runs on boot and as daily cron job, if not disabled via dietpi.txt) will create the file /DietPi/dietpi/.update_available with exactly this version string inside, if an update is available.

And yep, the file you linked is the one that is checked for updates, when you are on master branch (default, stable).
User avatar
cpcnw
Posts: 24
Joined: Wed Jun 29, 2016 8:31 am

Re: DietPi version information

Post by cpcnw »

> echo "$G_DIETPI_VERSION_CORE.$G_DIETPI_VERSION_SUB.$G_DIETPI_VERSION_RC"

Would welcome tips on assigning the full DietPi version to a PHP variable :)
User avatar
MichaIng
Site Admin
Posts: 3089
Joined: Sat Nov 18, 2017 6:21 pm

Re: DietPi version information

Post by MichaIng »

In PHP you'd need to read the version digits from /boot/dietpi/.version. Not sure if there is some shell like key=value interpreter, as this the format of this file. In the Allo web UI we execute sed as shell command three times, which is quite inefficient, but I'm no PHP expert and hence not sure whether there is a more efficient method ;).
User avatar
cpcnw
Posts: 24
Joined: Wed Jun 29, 2016 8:31 am

Re: DietPi version information

Post by cpcnw »

Thanks. I got some help with this but the following working for me;

Code: Select all

$dpver=vsprintf('%d.%d.%d', parse_ini_file('/DietPi/dietpi/.version'));
echo $dpver;
My version is 7.3.2

I'd like to compare this and create an 'update available' type message / flag. I don't see a /DietPi/dietpi/.update_available but I do see that there are packages available. It would be nice to cobble all this together like;

Installed Version: 7.3.2
Current Version: 7.3.3
Packages Available: 25

Any tips :)
User avatar
Joulinar
Posts: 5096
Joined: Sat Nov 16, 2019 12:49 am

Re: DietPi version information

Post by Joulinar »

Hi,

Folder /DietPi/ depreciated and is not existing anymore. DietPi scripts are located in /boot/dietpi now
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
cpcnw
Posts: 24
Joined: Wed Jun 29, 2016 8:31 am

Re: DietPi version information

Post by cpcnw »

I'm on 7.3.2 and /DietPi certainly is present here although /boot/dietpi/.version reflects same number as /DietPi/dietpi/.version
User avatar
cpcnw
Posts: 24
Joined: Wed Jun 29, 2016 8:31 am

Re: DietPi version information

Post by cpcnw »

Sorry - just seen its a simlink :)
Post Reply