Last active
December 13, 2018 07:18
-
-
Save ozzi-/d59644878bdefd5a96ba076674d9ed6d to your computer and use it in GitHub Desktop.
rewrites URLs in confluence xml export zip files and creates sensible named zips
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
#!/bin/bash | |
if ! [ -x "$(command -v zip)" ]; then | |
echo 'Error: zip is not installed.' >&2 | |
exit 1 | |
fi | |
if ! [ -x "$(command -v unzip)" ]; then | |
echo 'Error: unzip is not installed.' >&2 | |
exit 1 | |
fi | |
dir=. | |
cur=0 | |
for zip in $dir/Confluence-space-export*.zip; do | |
cur=$((cur + 1)) | |
folder=$dir"/export_"$cur | |
unzip -o -q $zip -d $folder | |
if [[ $? == 0 ]] ; then | |
pathXML=$folder"/entities.xml" | |
pathPROP=$folder"/exportDescriptor.properties" | |
if [ -e $pathXML ]; then | |
sed -i 's/https:\/\/confluence.domain.ch/http:\/\/confluence-c.domainlocal.ch/g' $pathXML | |
key=$(grep -i -e "spaceKey" $pathPROP | cut -f2 -d "=") | |
cd $folder | |
rm -rf "../"$key".zip" | |
zip -r -q "../"$key".zip" * | |
cd .. | |
rm -rf $folder | |
echo "Finished rewriting and repacking space '$key'" | |
else | |
echo $pathXML | |
echo "Confluence Space export does not contain entitites.xml. Skipping "$zip | |
fi; | |
else | |
echo "Error unzipping "$dir | |
fi; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment