Skip to content

Instantly share code, notes, and snippets.

@pigeonflight
Last active June 13, 2018 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pigeonflight/e4f2074b155b9c97ec84bb7e42624710 to your computer and use it in GitHub Desktop.
Save pigeonflight/e4f2074b155b9c97ec84bb7e42624710 to your computer and use it in GitHub Desktop.
plu: Plone ulility, a little experimental wrapper, written in bash for managing theme uploads through an ssh tunnel

Currently this only provides plu-up, a small utility, written in bash, for managing the upload of themes to a Plone site. It depends on plonetheme-upload. The goal is to make it as easy as possible to update a theme on a plone site from the commandline.

Using the prefix "plu-", provides a short, and hopefully inituitive, namespace for "plone command-line utilties". I hope that the plu- namespace can be used for other utilities. This could also be thought of as a proving ground. If a plu- utility makes sense, we'd try to eventually roll it into the plone-cli project.

I needed to integrate some ssh-tunnelling "magic" (documented here: https://stackoverflow.com/questions/2241063/bash-script-to-setup-a-temporary-ssh-tunnel). Hopefully this is useful to others.

Installation

Install the dependency (we assume you know how to work with npm):

npm i -g plonetheme-upload

download the pl-config file. Customize the pl-config file to match your server and plone instance information.

wget https://goo.gl/MYrZ9i -O ~/.plu-config

Edit the settings of $HOME/.plu-config to match your plone instance and server settings.

export plone_ssh_user=plone
export plone_server="example.com"
export plone_target_port=8080
export plone_local_port=8081
export plone_instance_path=test

Add to your bash_profile.

echo '. $HOME/.plu-config' >> ~/.bash_profile
. ~/.bash_profile

Usage

To upload a theme, simpling "point" the plu-up utility at your theme directory. It will invoke plonetheme-upload and push the theme to your server.

pl-up path/to/theme

If you prefer you can use the more explicit plu-upload which is an alias for plu-up

plu-upload path/to/theme
export plone_ssh_user=plone
export plone_server="example.com"
export plone_target_port=8080
export plone_local_port=8081
export plone_instance_path=test
plu-up() {
echo "------------ setting up tunnel";
ssh -M -S plone-ssh-ctrl-socket -fnNT -L $plone_local_port:localhost:$plone_target_port $plone_ssh_user@$plone_server;
echo "------------ uploading theme";
plonetheme-upload $1 http://127.0.0.1:$plone_local_port/$plone_instance_path;
echo "------------ closing tunnel";
ssh -S plone-ssh-ctrl-socket -O exit $plone_ssh_user@$plone_server;
}
alias plu-upload=plu-up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment