Skip to content

Instantly share code, notes, and snippets.

@nzambello
Last active September 7, 2018 14:06
Show Gist options
  • Save nzambello/dd983d662e0faf1689aad784df0dd031 to your computer and use it in GitHub Desktop.
Save nzambello/dd983d662e0faf1689aad784df0dd031 to your computer and use it in GitHub Desktop.
Bash script to switch between Plone DB
#!/bin/bash
if [[ $# != 1 ]];
then
echo "Illegal number of parameters, needed 1"
exit 1
fi
if [[ -d $1 ]];
then
if [[ -d ./filestorage/$1 ]];
then
currentDB=$(readlink ./filestorage/Data.fs | cut -d "/" -f2)
if [[ -e ./blobstorage ]];
then
rm -f ./blobstorage
fi
ln -sf "./$1" ./blobstorage
ln -sf "./$1/Data.fs" ./filestorage/Data.fs
if [[ -d ./filestorage/"$currentDB" ]];
then
cp ./filestorage/Data.fs.index ./filestorage/"$currentDB"/
fi
if [[ -f ./filestorage/Data.fs.index ]];
then
rm -f ./filestorage/Data.fs.index || return
fi
cp "./filestorage/$1/Data.fs.index" ./filestorage/Data.fs.index
echo "Changed DB to $1"
else
echo "Directory structure non regular"
exit 2
fi
else
echo "Directories not found"
exit 3
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment