Skip to content

Instantly share code, notes, and snippets.

@AngryAnt
Last active July 31, 2023 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AngryAnt/74c047a2b8438517c822ffdd9663aa57 to your computer and use it in GitHub Desktop.
Save AngryAnt/74c047a2b8438517c822ffdd9663aa57 to your computer and use it in GitHub Desktop.
List the home assistant modules reported missing by the nixos home assistant service since it was last started.
#!/usr/bin/env bash
set -euo pipefail
serviceName="home-assistant.service"
startTime=$(systemctl show -p ActiveEnterTimestamp "$serviceName")
startTime=$(echo $startTime | awk '{print $2 $3}')
echo "Missing modules reported since $serviceName start at $startTime:"
lines=$(journalctl -u "$serviceName" --output=cat --no-pager --since="$startTime")
regex="Unable to set up dependencies of \w+. Setup failed for dependencies: (\w+)"
allMatches=()
while IFS= read -r line; do
if [[ $line =~ $regex ]]; then
allMatches+=("${BASH_REMATCH[1]}")
fi
done <<< "$lines"
uniqueMatches=()
while IFS= read -r -d '' match; do
uniqueMatches+=("$match")
done < <(printf "%s\0" "${allMatches[@]}" | sort -uz)
for match in "${uniqueMatches[@]}"; do
echo "$match"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment