Run a script on update ? Topic is solved

On various Hardware and OS systems: pi / windows / routers / nas, etc

Moderator: leecollings

Post Reply
bxlouis
Posts: 45
Joined: Wednesday 16 December 2015 14:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Belgium
Contact:

Run a script on update ?

Post by bxlouis »

Hi everybody,

I changed the "switch_icons.txt" file in pi/domoticz/www/ in order to get nice custom icons.
However, every time I update Domoticz, this file is reset and I have to manually copy/paste my custom "switch_icons.txt" file.
I would like to setup a script which detects when Domoticz is updated and copies the new file before reboot.

Is it possible ?
Can someone help me ?

Many thanks !
georgesattali
Posts: 84
Joined: Saturday 05 March 2016 16:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

Re: Run a script on update ?

Post by georgesattali »

Hello,
maybe it would be simpler to make a new virtual device that runs this script when activated ?
you would have to activate it manually each time you update Dz, but as updating keeps scripts and devices, that would be not such a great pain.
So, ... not fully automatic, but easy and functionnal.
See you,
GD
bxlouis
Posts: 45
Joined: Wednesday 16 December 2015 14:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Belgium
Contact:

Re: Run a script on update ?

Post by bxlouis »

Hi georgesattali,

Thanks for your answer! Indeed, even if it's not fully automatic, it would be a good start!
Would you have any idea about such a script? I don't know much about those.
MP en français si c'est plus simple ;)
User avatar
Egregius
Posts: 2589
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Run a script on update ?

Post by Egregius »

Put your custom files in /home/pi/custom
then create a bash script /home/pi/afterupdate.sh
make sure it's executable with chmod +x afterupdate.sh

Code: Select all

#!/bin/bash
cp /home/pi/custom/switch_icons.txt /home/pi/domoticz/www/switch_icons.txt

Call the script as on action on your dummy device with script:///home/pi/afterupdate.sh
User avatar
Egregius
Posts: 2589
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Run a script on update ?

Post by Egregius »

You can even go further with a script like this. You gave me the idea to replace stuff in the webinterface automatically, thanks :D
I like to see the whole table in devices and so, so with this I disabled paging:

Code: Select all

#!/bin/bash
find /volume1/@appstore/domoticz/www/ -type f -name "*.js" -exec sudo sed -i 's/\"iDisplayLength\" : 25,/\"iDisplayLength\" : -1,\"paging\": false,/g' {} +
find /volume1/@appstore/domoticz/www/ -type f -name "*.html" -exec sudo sed -i 's/\"iDisplayLength\" : 25,/\"iDisplayLength\" : -1,\"paging\": false,/g' {} +
find /volume1/@appstore/domoticz/www/ -type f -name "*.js" -exec sudo sed -i 's/\"iDisplayLength\": 25,/\"iDisplayLength\" : -1,\"paging\": false,/g' {} +
find /volume1/@appstore/domoticz/www/ -type f -name "*.html" -exec sudo sed -i 's/\"iDisplayLength\": 25,/\"iDisplayLength\" : -1,\"paging\": false,/g' {} +
find /volume1/@appstore/domoticz/www/ -type f -name "*.js" -exec sudo sed -i 's/\"iDisplayLength\" : 10,/\"iDisplayLength\" : -1,\"paging\": false,/g' {} +
find /volume1/@appstore/domoticz/www/ -type f -name "*.html" -exec sudo sed -i 's/\"iDisplayLength\" : 10,/\"iDisplayLength\" : -1,\"paging\": false,/g' {} +
find /volume1/@appstore/domoticz/www/ -type f -name "*.js" -exec sudo sed -i 's/\"iDisplayLength\": 10,/\"iDisplayLength\" : -1,\"paging\": false,/g' {} +
find /volume1/@appstore/domoticz/www/ -type f -name "*.html" -exec sudo sed -i 's/\"iDisplayLength\": 10,/\"iDisplayLength\" : -1,\"paging\": false,/g' {} +
find /volume1/@appstore/domoticz/www/ -type f -name "*.js" -exec sudo sed -i 's/\"iDisplayLength\" : 100,/\"iDisplayLength\" : -1,\"paging\": false,/g' {} +
find /volume1/@appstore/domoticz/www/ -type f -name "*.html" -exec sudo sed -i 's/\"iDisplayLength\" : 100,/\"iDisplayLength\" : -1,\"paging\": false,/g' {} +
This could be extended to other web interface related stuff.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests