Skip to content

Instantly share code, notes, and snippets.

@joeworkman
Created March 30, 2019 16:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joeworkman/568156d3b2890c33ca17bea21c462593 to your computer and use it in GitHub Desktop.
Save joeworkman/568156d3b2890c33ca17bea21c462593 to your computer and use it in GitHub Desktop.
This script will swap between Stacks 3 and 4. You will need to configure the `rwfolder` to be the location of your RapidWeaver addons. You will also need to create `tgz` archives of the Stacks 3 and 4 plugins so that they can be swapped. This script will always archive the plugins with every swap. This allows you to update the plugins to new ver…
#!/bin/bash
rwfolder=~/Library/Mobile\ Documents/com\~apple\~CloudDocs/RapidWeaver
cd "$rwfolder"
stacks=Stacks.rapidweaverplugin
plist=$stacks/Contents/Info.plist
version=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$plist" | cut -f1 -d.`
stacks3=Stacks3.tgz
stacks4=Stacks4.tgz
osascript -e 'quit app "RapidWeaver 8"'
uninstall () {
if [ "$1" == 3 ]; then
echo "Backup Stacks 3..."
rm "$stacks3"
tar czf "$stacks3" "$stacks"
elif [ "$1" == 1 ]; then
echo "Backup Stacks 4..."
rm "$stacks4"
tar czf "$stacks4" "$stacks"
elif [ "$1" == 4 ]; then
echo "Backup Stacks 4..."
rm "$stacks4"
tar czf "$stacks4" "$stacks"
fi
echo "Uninstalling Stacks $1..."
rm -rf "$stacks"
}
install () {
if [ "$1" == 3 ]; then
echo "Installing Stacks 3..."
tar xzf "$stacks3"
elif [ "$1" == 1 ]; then
echo "Installing Stacks 4..."
tar xzf "$stacks4"
elif [ "$1" == 4 ]; then
echo "Installing Stacks 4..."
tar xzf "$stacks4"
fi
}
echo "Stacks $version currently installed"
if [ "$1" == "$version" ]; then
echo "Requested version already installed"
elif [ "$1" == 3 ]; then
uninstall 4
install 3
elif [ "$1" == 4 ]; then
uninstall 3
install 4
else
# Swap version if no version is passed via command line
if [ "$version" == 3 ]; then
uninstall 3
install 4
elif [ "$version" == 4 ]; then
uninstall 4
install 3
fi
fi
echo "Done"
@joeworkman
Copy link
Author

CleanShot 2019-03-30 at 09 40 07

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment