~fginther/+junk/cloud-worker

« back to all changes in this revision

Viewing changes to charms/precise/jenkins-slave/hooks/slave-relation-changed

  • Committer: Francis Ginther
  • Date: 2014-08-16 14:21:24 UTC
  • Revision ID: francis.ginther@canonical.com-20140816142124-hzpf11jzz65cgmrr
Deployment and charms for a jenkins cloud worker.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
 
 
3
set -e
 
4
 
 
5
# Setup connection to master instance once set
 
6
url=$(relation-get url)
 
7
 
 
8
if [ "x$url" = "x" ]; then
 
9
        juju-log "Master hasn't exported its url yet, exiting..."
 
10
        exit 0
 
11
fi
 
12
 
 
13
# Set the slave hostname to match the juju unit
 
14
# in the jenkins master instance
 
15
slavehost=`echo ${JUJU_UNIT_NAME} | sed s,/,-,`
 
16
 
 
17
juju-log "Configuring jenkins-slave with $url..."
 
18
sed -i -e "s!^JENKINS_HOSTNAME.*!JENKINS_HOSTNAME=${slavehost}!" \
 
19
       -e "s!^#*JENKINS_URL.*!JENKINS_URL=${url}!" \
 
20
        /etc/default/jenkins-slave
 
21
 
 
22
juju-log "Restarting jenkins-slave..."
 
23
# Startup the jenkins-slave service
 
24
stop jenkins-slave 2>/dev/null || true
 
25
start jenkins-slave