Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Commit 9635432

Browse files
sam-crawleyswetoast
authored andcommitted
Only update apt/install packages when required
1 parent 919b0b0 commit 9635432

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

plugin.program.steamlink/addon.py

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,37 +31,39 @@ def create_files():
3131
outfile.close()
3232
with open('/tmp/steamlink-watchdog.sh', 'w') as outfile:
3333
outfile.write("""#!/bin/bash
34-
sudo apt update # write a better update check
35-
if ! dpkg --list | grep -q gnupg; then
36-
kodi-send --action="Notification(Downloading and installing Steamlink dependencies (gnupg)... ,3000)"
37-
sudo apt install gnupg -y
38-
fi
39-
if ! dpkg --list | grep -q curl; then
40-
kodi-send --action="Notification(Downloading and installing Steamlink dependencies (curl)... ,3000)"
41-
sudo apt install curl -y
42-
fi
43-
if ! dpkg --list | grep -q libgles2; then
44-
kodi-send --action="Notification(Downloading and installing Steamlink dependencies (libgles2)... ,3000)"
45-
sudo apt install libgles2 -y
46-
fi
47-
if ! dpkg --list | grep -q libegl1; then
48-
kodi-send --action="Notification(Downloading and installing Steamlink dependencies (libegl1)... ,3000)"
49-
sudo apt install libegl1 -y
50-
fi
51-
if ! dpkg --list | grep -q libgl1-mesa-dri; then
52-
kodi-send --action="Notification(Downloading and installing Steamlink dependencies (libgl1-mesa-dri)... ,3000)"
53-
sudo apt install libgl1-mesa-dri -y
34+
35+
check_pkgs_installed() {
36+
output=$(dpkg --list $@ 2>&1)
37+
}
38+
39+
req_packages="gnupg curl libgles2 libegl1 libgl1-mesa-dri"
40+
41+
if ! check_pkgs_installed $req_packages; then
42+
sudo apt update
43+
for pkg in $req_packages; do
44+
45+
if ! check_pkgs_installed $pkg; then
46+
kodi-send --action="Notification(Downloading and installing Steamlink dependencies ($pkg)... ,3000)"
47+
sudo apt install $pkg -y
48+
fi
49+
done
5450
fi
51+
5552
if [ "$(which steamlink)" = "" ]; then
5653
kodi-send --action="Notification(Downloading and installing Steamlink Application... ,3000)"
5754
curl -o /tmp/steamlink.deb -#Of http://media.steampowered.com/steamlink/rpi/latest/steamlink.deb
5855
sudo dpkg -i /tmp/steamlink.deb
5956
rm -f /tmp/steamlink.deb
6057
fi
61-
if [ -f "/home/osmc/.wakeup" ]
62-
then /usr/bin/wakeonlan "$(cat "/home/osmc/.wakeup")"
63-
else sudo apt install wakeonlan -y; /usr/bin/wakeonlan "$(cat "/home/osmc/.wakeup")"
58+
59+
if [ -f "/home/osmc/.wakeup" ]; then
60+
if ! check_pkgs_installed wakeonlan; then
61+
sudo apt install wakeonlan -y;
62+
fi
63+
64+
/usr/bin/wakeonlan "$(cat "/home/osmc/.wakeup")"
6465
fi
66+
6567
if [ -x "/home/osmc/steamlink/startup.sh" ]
6668
then sudo -u osmc /home/osmc/steamlink/startup.sh
6769
fi

0 commit comments

Comments
 (0)