Author Archives: Al

VirtualBox how to start all VMs headless

vboxmanage list vms | cut -f 2 -d ‘”‘ | xargs -I{} vboxheadless -s “{}”

Setting up vim for Puppet

mkdir -p ~/.vim/autoload ~/.vim/bundle && \
curl -LSso ~/.vim/autoload/pathogen.vim
git clone git:// ~/.vim/bundle/puppet
# ~/.vimrc
execute pathogen#infect()
syntax on
filetype plugin indent on

Uploading and updating an Image to Confluence using the REST API

If you have automated systems sometimes it is useful to have them interact with your documentation from time to time.  Using the Confluence REST API you can upload an image as an attachment to the page and later update it if required.  If you follow the Atlassian documentation you end up getting a denied request for the update as it wishes for the new file to have a different filename.
Below are the curl lines to post and then update the image.  Change your page ID and attachment ID as required:

curl -D- -k -u $user:$pass -p -H "X-Atlassian-Token: nocheck" -X POST \ 
 -F file=@cake.jpg https://confluence.domain.tld/confluence/rest/api/content/$page_id/child/attachment
curl -D- -k -u $user:$pass -p -H "X-Atlassian-Token: nocheck" -X POST \
 -F file=@cake.jpg https://confluence.domain.tld/confluence/rest/api/content/$page_id/child/attachment/$attach_id/data

In the first request you should have a JSON response with Results->ID->att123456 – the attach_id to be used above is just the numeric part of this string, i.e. 123456.