#!/bin/bash

set +e
if [ -f "/etc/apt/sources.list.d/spotify.list" ]; then
  rm /etc/apt/sources.list.d/spotify.list
fi
exit 0
# Dieses Script erstellt für die Desktop-Oberfläche zusätzliche Repository
#
# spotify  

PFAD=/opt/XLinux

# Warte bis zu 30 Minuten um zu prüfen ob Computer nun Online
Z=5
while [ $Z -lt 60 ]; do
  ping -c 1 www.itmastro.de >> /dev/null 2>&1
  ONLINE=$?
  if [ $ONLINE -ne 0 ]; then
    Z=$(($Z+1));
    sleep $Z
  else
    Z=9999
  fi
done

if [ $ONLINE -ne 0 ]; then
  exit 0
fi


#Spotify
if [ ! -f "/etc/apt/sources.list.d/spotify.list" ]; then
  wget -O $PFAD/spotify.gpg "https://download.spotify.com/debian/pubkey.gpg"
  if [ "$?" == "0" ]; then
    apt-key add $PFAD/spotify.gpg
    echo "deb http://repository.spotify.com stable non-free" > /etc/apt/sources.list.d/spotify.list
  fi
  rm $PFAD/spotify.gpg
fi

exit 0
