Skip to content

Commit

Permalink
Update raspotify-crash-report-generator.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLG1979 authored Dec 12, 2022
1 parent 5944f43 commit f5bd851
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions raspotify/usr/bin/raspotify-crash-report-generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ username="LIBRESPOT_USERNAME"
password="LIBRESPOT_PASSWORD"

librespot="LIBRESPOT_"
tmp_dir="TMPDIR"

logs=$(journalctl -u raspotify --since "1min ago" -q)

fail_count=$(echo "$logs" | grep -o "raspotify.service: Failed" | wc -l)
# Discovery already has retries built into it in librespot.
discovery_fail_count=$(echo "$logs" | grep -o "Could not initialise discovery:" | wc -l)

{
echo -e "-- System Info --\n"
Expand All @@ -25,9 +26,22 @@ fail_count=$(echo "$logs" | grep -o "raspotify.service: Failed" | wc -l)
} >$crash_report 2>/dev/null

while read -r line; do
if { [[ $line = $librespot* ]] && [[ $line != $username* ]] && [[ $line != $password* ]]; } || [[ $line = $tmp_dir* ]]; then
echo "$line" >>$crash_report 2>/dev/null
fi
stripped_line=$(echo "$line" | awk '{$1=$1};1')

case $stripped_line in
$username*)
echo "$username=XXXXXXXX" >>$crash_report 2>/dev/null
;;
$password*)
echo "$password=XXXXXXXX" >>$crash_report 2>/dev/null
;;
$librespot*)
echo "$stripped_line" >>$crash_report 2>/dev/null
;;
*)
:
;;
esac
done <$config

{
Expand All @@ -41,7 +55,7 @@ done <$config

systemctl reset-failed raspotify

if [ "$fail_count" -lt 6 ]; then
if [ "$fail_count" -lt 6 ] && [ "$discovery_fail_count" -eq 0 ]; then
sleep 10
systemctl restart raspotify
fi

0 comments on commit f5bd851

Please sign in to comment.