Skip to content

Instantly share code, notes, and snippets.

@frafra
Created March 5, 2025 12:37
Show Gist options
  • Save frafra/0a9a2da7bd12d9b0263f18ca88f9da50 to your computer and use it in GitHub Desktop.
Save frafra/0a9a2da7bd12d9b0263f18ca88f9da50 to your computer and use it in GitHub Desktop.
Snippets for IPT
#!/bin/bash
set -eu
OLD_PASSWORD="old_endoded_pwd"
NEW_PASSWORD="new_endoded_pwd"
filter='(.resource.sources | (.sqlsource, .sqlsources[])? | select(.password == $old).password) |= $new'
for file in */resource.xml; do
xq --xml-output --arg old "$OLD_PASSWORD" --arg new "$NEW_PASSWORD" "$filter" "$file" > "${file}.tmp"
if cmp -s <(xq --xml-output . "$file") "${file}.tmp"; then
rm "${file}.tmp"
else
mv "${file}.tmp" "$file"
echo "Updated password in: $file"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment