~hloeung/jenkins-agent-charm/reactive-rewrite-remove-bundled-charmhelpers

« back to all changes in this revision

Viewing changes to hooks/install

  • Committer: Neale Pickett
  • Date: 2015-08-05 22:14:01 UTC
  • mfrom: (11.1.6 jenkins-slave-kitsune)
  • Revision ID: neale.pickett@canonical.com-20150805221401-wjdqtk1z23wyqqgj
[josepht,r=neale] Allow supplying URL of jekins master

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
set -eu
4
4
 
 
5
 
 
6
# Install the slave if it is not installed already.
5
7
install_slave () {
6
 
        juju-log "Installing jenkins-slave..."
7
 
        apt-get -y install -qq jenkins-slave wget
 
8
    juju-log "Installing jenkins-slave..."
 
9
    if [[ ! -f /etc/init/jenkins-slave.conf ]]
 
10
    then
 
11
        if [[ "$(apt-cache madison jenkins-slave)" =~ .*jenkins-slave.* ]]
 
12
        then
 
13
            apt-get -y install -qq jenkins-slave wget
 
14
        else
 
15
            # This series doesn't provide a jenkins.
 
16
            # Install the same slave package as the precise Jenkins master.
 
17
            apt-get -y install -qq wget adduser default-jre-headless upstart-job
 
18
            dpkg -i files/jenkins-slave_*.deb
 
19
        fi
 
20
    else
 
21
        juju-log "Jenkins-slave is already installed"
 
22
    fi
8
23
}
9
 
[[ -f /etc/init/jenkins-slave.conf ]] || install_slave
10
 
 
11
 
# Install some tools - can get set up deployment time
 
24
 
 
25
 
 
26
# Install extra packages needed by the slave.
12
27
install_tools () {
13
 
        juju-log "Installing tools..."
14
 
        apt-get -y install -qq `config-get tools`
15
 
}
 
28
    juju-log "Installing tools..."
 
29
    apt-get -y install -qq $(config-get tools)
 
30
}
 
31
 
 
32
 
 
33
# Configure slave
 
34
setup_slave () {
 
35
    # If a master_url value is specified, use that to configure the slave.
 
36
    master_url="$(config-get master_url)"
 
37
    if [ -n "${master_url}" ]; then
 
38
        juju-log "Using 'master_url' to configure the slave."
 
39
        hooks/configure-slave "${master_url}"
 
40
    else
 
41
        juju-log "No 'master_url' set; not configuring slave at this time."
 
42
    fi
 
43
}
 
44
 
 
45
# Execute any hook overlay which may be provided
 
46
# by forks of this charm.
 
47
install_extra_hooks () {
 
48
    juju-log "Installing hooks..."
 
49
    if [[ -d hooks/install.d ]]
 
50
    then
 
51
        for i in $(ls -1 hooks/install.d/*)
 
52
        do
 
53
            if [[ -x "$i" ]]
 
54
            then
 
55
                source "./$i"
 
56
            fi
 
57
        done
 
58
    else
 
59
        juju-log "No extra hooks found."
 
60
    fi
 
61
}
 
62
 
 
63
 
 
64
install_slave
16
65
install_tools
17
 
 
18
 
# Execute any hook overlay which may be provided
19
 
# by forks of this charm
20
 
if [ -d hooks/install.d ]
21
 
then
22
 
    for i in `ls -1 hooks/install.d/*`
23
 
    do
24
 
        [[ -x $i ]] && . ./$i
25
 
    done
26
 
fi
27
 
 
 
66
setup_slave
 
67
install_extra_hooks
28
68
exit 0