@@ -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
5450fi
51+
5552if [ "$(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
6057fi
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")"
6465fi
66+
6567if [ -x "/home/osmc/steamlink/startup.sh" ]
6668 then sudo -u osmc /home/osmc/steamlink/startup.sh
6769fi
0 commit comments