Validate entire job, not just op
[ganeti_webmgr.git] / ganeti_web / util / hooks / sshkeys.sh
blob3f97bb48ca6d540f1d2b94150e65586c6f0ee990
1 #!/bin/bash
2 # Add ssh keys from a Ganeti Web Manager instance to a VM
4 set -e
6 . common.sh
8 if [ -z "${TARGET}" -o ! -d "${TARGET}" ] ; then
9 echo "Missing target directory"
10 exit 1
13 if [ -z "${GWM_SSHKEYS}" -o ! -x "${GWM_SSHKEYS}" ] ; then
14 echo "Missing Ganeti Web Manager sshkeys.py"
15 exit 1
18 if [ -z "${GWM_HOST}" ] ; then
19 echo "GWM_HOST empty"
20 exit 1
23 if [ -z "${GWM_SLUG}" ] ; then
24 echo "GWM_SLUG empty"
25 exit 1
28 if [ -z "${GWM_API_KEY}" ] ; then
29 echo "GWM_API_KEY empty"
30 exit 1
33 mkdir -p ${TARGET}/root/.ssh
34 ${GWM_SSHKEYS} ${GWM_API_KEY} ${GWM_HOST} ${GWM_SLUG} \
35 ${INSTANCE_NAME} > ${TARGET}/root/.ssh/authorized_keys
37 exit 0