mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-03-29 21:03:40 +00:00
chore(dev): enhance sync-hac script to clean up broken symlinks and report changes
This commit is contained in:
parent
60c3b72932
commit
329f96f2f4
1 changed files with 26 additions and 3 deletions
|
|
@ -14,6 +14,25 @@ if [ ! -d "config/custom_components" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Clean up broken symlinks (where target no longer exists)
|
||||||
|
cleaned=0
|
||||||
|
if [ -d "custom_components" ]; then
|
||||||
|
for link in custom_components/*; do
|
||||||
|
# Skip if not a symlink
|
||||||
|
if [ ! -L "$link" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if symlink target exists
|
||||||
|
if [ ! -e "$link" ]; then
|
||||||
|
component=$(basename "$link")
|
||||||
|
rm "$link"
|
||||||
|
echo " 🗑️ Removed broken link: $component"
|
||||||
|
cleaned=$((cleaned + 1))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# Create symlinks for all integrations in config/custom_components/
|
# Create symlinks for all integrations in config/custom_components/
|
||||||
# except those that already exist in custom_components/
|
# except those that already exist in custom_components/
|
||||||
synced=0
|
synced=0
|
||||||
|
|
@ -32,8 +51,12 @@ for dir in config/custom_components/*/; do
|
||||||
synced=$((synced + 1))
|
synced=$((synced + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ $synced -eq 0 ]; then
|
if [ $synced -eq 0 ] && [ $cleaned -eq 0 ]; then
|
||||||
echo " ℹ️ No new integrations to sync"
|
echo " ℹ️ No changes needed"
|
||||||
else
|
elif [ $synced -gt 0 ] && [ $cleaned -eq 0 ]; then
|
||||||
echo " ✓ Synced $synced integration(s)"
|
echo " ✓ Synced $synced integration(s)"
|
||||||
|
elif [ $synced -eq 0 ] && [ $cleaned -gt 0 ]; then
|
||||||
|
echo " ✓ Cleaned up $cleaned broken link(s)"
|
||||||
|
else
|
||||||
|
echo " ✓ Synced $synced integration(s), cleaned up $cleaned broken link(s)"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue