Install files save script (Linux)

All kinds of 'OS' scripts

Moderator: leecollings

Post Reply
lost
Posts: 616
Joined: Thursday 10 November 2016 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Install files save script (Linux)

Post by lost »

Hello,

For those that may want to save Domoticz stable/beta install files, as experience proves this may be useful as builds are not kept (most probably because this would need huge storage & have a cost), here is my small bash scripts that saves current install archives locally:

Code: Select all

#!/bin/bash
# Scripts that'll download all Domoticz install files for current stable or beta release.

# Editable settings, if base download URL or supported OS/ARCH change someday...
# Base URL can be checked in domoticz/update[beta|release].sh scripts. 
DZ_DNLD_URL='https://www.domoticz.com/download.php?'
SYSTEMS='linux windows'
MACHINES='aarch64 armv7l x86_64 x86'

error()
{
 echo $1
 exit 1
}

usage()
{
  echo "Usage : $0 [b|s] ; Download all Domoticz beta/stable install archives..."
  exit 0
}

# Non foolproof args check:
[ $# -ne 1 ] && usage

case $1 in
  b | B) channel='beta';;
  s | S) channel='stable';;
  *)
    echo "Try better next time !"
    usage;;
esac

# Create install archives save directory:
today=$(date +"%y%m%d")
dirTd=$channel'_'$today
mkdir $dirTd || error "Could not make directory : $dirTd"
echo "Getting files for $channel/$today -> $dirTd/ ..."

# Download channel archives for all machine/system combinations:
for machine in $MACHINES
do
  for system in $SYSTEMS
  do
    dz_url="${DZ_DNLD_URL}channel=${channel}&type=release&system=${system}&machine=${machine}"
    #echo "Download ${system}/${machine} from ${dz_url}..."
    wget -4 -q -O $dirTd/domoticz_${channel}_${system}_${machine}.tgz --no-check-certificate ${dz_url}
    [ $? -ne 0 ] && echo "No $channel file for ${system}/${machine}..." || echo "Done, ${channel} for ${system}/${machine} !"
  done
done

# Remove zero-sized files that may result from non supported machine/system combinations...
find $dirTd -maxdepth 1 -size 0c -delete
 
echo "That's All Folks!!!"
exit 0
Save this as get_dz_installs.sh for instance then make it executable using:

Code: Select all

chmod +x get_dz_installs.sh
and call it with either "s" (stable) or "b" (beta) parameter from directory where file was saved:

Code: Select all

./get_dz_installs.sh s
(or)
./get_dz_installs.sh s
This'll build a dated release directory with all supported archs/os install files inside, for instance:

Code: Select all

$ tree stable_240116/
stable_240116/
├── domoticz_stable_linux_aarch64.tgz
├── domoticz_stable_linux_armv7l.tgz
├── domoticz_stable_linux_x86_64.tgz
└── domoticz_stable_windows_x86.tgz
So, if needed, the file for your system/machine may be extracted as done by upgrade scripts. Take care that downgrade may cause DB version issues, so always better to save whole current domoticz tree before any version change attempt...
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Install files save script (Linux)

Post by waltervl »

Builds are being kept for major releases in the GitHub repository. Eg https://github.com/domoticz/domoticz/re ... tag/2024.2
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Kedi
Posts: 536
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: Install files save script (Linux)

Post by Kedi »

Why would you save tgz files of systems that you don't have.
Beside the update script saves all in the domoticz dir into a tgz file in the backup dir.
Logic will get you from A to B. Imagination will take you everywhere.
lost
Posts: 616
Joined: Thursday 10 November 2016 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Install files save script (Linux)

Post by lost »

Kedi wrote: Tuesday 16 January 2024 19:30 Why would you save tgz files of systems that you don't have.
Answer was in the post that was pointing to this one in the 2024.2 topic that is no more there (send failed?)!
Raspberries are almost always out of stock, so in case of HW failure the need to move to a low cost PC (for instance) may be needed with the exact same version that was installed on another architecture.
Another reason is this have already proved useful for others.
User avatar
gizmocuz
Posts: 2350
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Install files save script (Linux)

Post by gizmocuz »

Domoticz stable versions now also make a backup, so there is no reason for this script correct?
Quality outlives Quantity!
lost
Posts: 616
Joined: Thursday 10 November 2016 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Install files save script (Linux)

Post by lost »

gizmocuz wrote: Wednesday 17 January 2024 8:10 Domoticz stable versions now also make a backup, so there is no reason for this script correct?
Yes, that's less useful now. Could anyway help setting the exact same version that was running if domoticz host must be changed someday (HW failure...) for another model/arch (if my PI3B fails, for instance, I'll probably go to an Intel SBC as some are now a better bargain than raspberries+no Linux support issues like chinese ARM based alternatives), as well as issues screwing domoticz/storage with DBs/scripts otherwise saved but not the whole tree.
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Install files save script (Linux)

Post by Egregius »

Wouldn't it be better to first check if there's a newer version available?
This url will give you that info:
http://ip:port/json.htm?type=command&param=checkforupdate&forced=true
lost
Posts: 616
Joined: Thursday 10 November 2016 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Install files save script (Linux)

Post by lost »

Egregius wrote: Wednesday 17 January 2024 8:58 Wouldn't it be better to first check if there's a newer version available?
Did not know about this url, looks that's also undocumented (only getversion is, but response now depends on who's logged/user setup so not easy to use).

Could be done, but this does not handle beta (but maybe there's another undocumented API for this) & if not used from the machine that hosts domoticz, will need it's IP... On top of parsing json from bash this may make the script a bit complex for the use-case IMO.
Kedi
Posts: 536
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: Install files save script (Linux)

Post by Kedi »

I have a somewhat smarter solution.
Change the updatebeta and/or updaterelease script from Domoticz to you liking.
And instead of the present

Code: Select all

rm domoticz_beta.tgz
you could change that in

Code: Select all

mv domoticz_beta.tgz <something else>
and save that on an other place.
This way you have a backup from the current dir and a tgz installation file of Domoticz of the new environment.
Latest and previous stables (to some extend) are present at github.

B.t.w. it might be that the contents of the dirs stable_240116 and stable_240117 might be the same.
Logic will get you from A to B. Imagination will take you everywhere.
lost
Posts: 616
Joined: Thursday 10 November 2016 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Install files save script (Linux)

Post by lost »

Kedi wrote: Wednesday 17 January 2024 10:22 instead of the present

Code: Select all

rm domoticz_beta.tgz
you could change that in

Code: Select all

mv domoticz_beta.tgz <something else>
and save that on an other place.
Yes, could be, but would only save current used system archive (so not keeping exact same version that may be installed on a new HW with different arch/os, if needed) & may cause issues to users unaware of the added feature in such automatic upgrade script with low storage: This would need further checks before proceeding & some auto-removal management as we're not in a user managed process there, supposed to know what he's doing... There's no install script provided to use these archives as well, so this targets users that are already confident with Linux CLI anyway.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests