Run script after update?

So @ashtonaut you have a final working version ? :slight_smile:

I get notifications when packages are updated, yes. I’m pretty sure I also have notifications working on major OS updates, but I probably need to wait until the August update to confirm this 100%.

Can you post a complete how to please ? I use pushover too :slight_smile:

Sure, when I get a chance. All the info and code is in this thread already, but I can probably roll the essentials into a Pushover how to.

I will most likely wait until the August update to confirm a few things.

OK so all this code is ok ?

push.sh

#!/bin/bash
    
    # Uses the Pushover API to send the first command line parameter as a push notification
    
    curl -s \
      --form-string "token=YOURAPPTOKEN" \
      --form-string "message=$1" \
      --form-string "user=YOURUSERTOKEN" \
      https://api.pushover.net/1/messages.json > /dev/null

updatecheck.sh

#!/bin/bash

# Check if OSMC has just been updated
OLDVER=$(cat /home/osmc/versionid.txt)
NEWVER=$(cat /etc/os-release | grep VERSION_ID | awk -F\" '{print $(NF-1)}')

echo "Checking if OSMC has been updated..."

if [ "$OLDVER" != "$NEWVER" ]; then
  echo "OSMC has been updated, pushing notification..."
  /home/osmc/push.sh "OSMC has been updated to $NEWVER"
  echo $NEWVER > /home/osmc/versionid.txt
  exit 0
fi

echo "No update detected"

updatecheck.service

[Unit]
Description=Run the updatecheck script once on startup after networking is up
After=network-online.target

[Service]
Type=oneshot
ExecStart=/home/osmc/updatecheck.sh | systemd-cat -t updatecheck

[Install]
WantedBy=multi-user.target

But where do you save the service ?
Thanks

Service file goes in /etc/systemd/system/

Then run sudo systemctl enable updatecheck to enable and it should check each reboot.

I’m still not sure whether it’s better to run it this way, or from a hook within mediacentre.service.

Ok so I’m waiting for your news. :wink:

I wrote a HowTo post so that everything is in one place:

I’ll update the HowTo with another example if/when I can confirm the best way to notify on OSMC version updates.

Thanks :slight_smile:

I’ve updated the how-to post with instructions for pushing updates on OSMC version updates.