Last active
July 31, 2023 17:51
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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