~ubuntu-langpack/langpack-o-matic/main

« back to all changes in this revision

Viewing changes to deployment/deploy.sh

  • Committer: Martin Pitt
  • Date: 2016-09-13 14:17:21 UTC
  • Revision ID: martin.pitt@canonical.com-20160913141721-6i5hmy8zmyet6qtt
Update deployment charm and script

With the charm and in the DevOps environment, building packages can now happen
directly on the instance, so drop schroot from cron.* and documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
# Deploy langpack-o-matic charm
3
 
# Author: Martin Pitt <martin.pitt@ubuntu.com>
4
 
 
5
 
set -e
6
 
 
7
 
MYDIR=$(dirname $(readlink -f $0))
8
 
 
9
 
wait_deployed() {
10
 
    echo "waiting for $1 to get deployed..."
11
 
    while true; do
12
 
        juju_status="$(juju status $1)"
13
 
        if echo "$juju_status" | grep -q 'agent-state: started' &&
14
 
           ! echo "$juju_status" | grep -q 'agent-state: pending'; then
15
 
            break
16
 
        fi
17
 
        sleep 5
18
 
    done
19
 
}
20
 
 
21
 
subordinate_charms() {
22
 
    if [ -n "$MOJO_PROJECT" ]; then
23
 
        echo 'deploying subordinate charms to $1'
24
 
        juju add-relation ksplice "$1"
25
 
        juju add-relation landscape-client "$1"
26
 
    fi
27
 
}
28
 
 
29
 
GPG_PUB_KEY=$(gpg --export -a language-packs@ubuntu.com)
30
 
GPG_SECRET_KEY=$(gpg --export-secret-keys -a language-packs@ubuntu.com)
31
 
if [ -z "$GPG_PUB_KEY" -o -z "$GPG_SECRET_KEY" ]; then
32
 
    echo "ERROR: GPG key for language-packs@ubuntu.com not available" >&2
33
 
    exit 1
34
 
fi
35
 
 
36
 
# create charm config
37
 
 
38
 
config_yaml=$(mktemp)
39
 
trap "rm $config_yaml" EXIT INT QUIT PIPE
40
 
 
41
 
#
42
 
# deploy subordinate charms for automatic machine management (only if
43
 
# $MOJO_PROJECT is set, i. e. for the production environment in ProdStack)
44
 
#
45
 
 
46
 
if [ -n "$MOJO_PROJECT" ]; then
47
 
    [ -d "$MYDIR/charms/trusty/landscape-client" ] || bzr checkout --lightweight lp:charms/trusty/landscape-client "$MYDIR/charms/trusty/landscape-client"
48
 
    [ -d "$MYDIR/charms/trusty/ksplice" ] || { echo "Please check out ksplice charm to $MYDIR/charms/trusty"; exit 1; }
49
 
 
50
 
    #
51
 
    # install/update basenode into charms
52
 
    #
53
 
    [ -d "$MYDIR/basenode" ] || { echo "Please check out basenode into $MYDIR"; exit 1; }
54
 
    for charmdir in $MYDIR/charms/trusty/*; do
55
 
        # ignore subordinate charms
56
 
        if grep -q 'subordinate:.*true' $charmdir/metadata.yaml; then
57
 
            continue
58
 
        fi
59
 
        echo "Installing basenode into $charmdir"
60
 
        rm -rf "$charmdir/exec.d/basenode"
61
 
        mkdir -p "$charmdir/exec.d"
62
 
        cp -r "$MYDIR/basenode" "$charmdir/exec.d"
63
 
    done
64
 
 
65
 
    if ! juju status | grep -q ksplice:; then
66
 
        juju deploy --repository "$MYDIR/charms" local:trusty/ksplice
67
 
        juju set ksplice accesskey=$(cat /srv/mojo/LOCAL/$MOJO_PROJECT/canonical-is-ksplice.key)
68
 
        juju set ksplice source=""
69
 
    fi
70
 
    if ! juju status | grep -q landscape-client:; then
71
 
        cat <<EOF >> "$config_yaml"
72
 
landscape-client:
73
 
  url: https://landscape.is.canonical.com/message-system
74
 
  ping-url: http://landscape.is.canonical.com/ping
75
 
  account-name: standalone
76
 
  registration-key: $(cat /srv/mojo/LOCAL/$MOJO_PROJECT/canonical-is-landscape.key)
77
 
  tags: juju-managed, devops-instance, devops-production
78
 
EOF
79
 
        juju deploy --repository "$MYDIR/charms" --config "$config_yaml" local:trusty/landscape-client
80
 
    fi
81
 
 
82
 
    #
83
 
    # deploy bootstrap-node charm
84
 
    #
85
 
 
86
 
    if ! juju status | grep -q bootstrap-node:; then
87
 
        juju deploy --repository $MYDIR/charms --to 0 local:trusty/bootstrap-node
88
 
        wait_deployed bootstrap-node
89
 
        subordinate_charms "bootstrap-node"
90
 
    fi
91
 
 
92
 
fi
93
 
 
94
 
#
95
 
# deploy langpack-o-matic charm
96
 
#
97
 
 
98
 
if juju status langpack-o-matic | grep -q 'agent-state:'; then
99
 
    echo 'WARNING: langpack-o-matic already deployed, skipping' >&2
100
 
else
101
 
    echo 'deploying langpack-o-matic'
102
 
    cat <<EOF >> "$config_yaml"
103
 
langpack-o-matic:
104
 
  gpg-public-key: |
105
 
$(echo "$GPG_PUB_KEY" | sed 's/^/    /')
106
 
  gpg-secret-key: |
107
 
$(echo "$GPG_SECRET_KEY" | sed 's/^/    /')
108
 
EOF
109
 
    juju deploy --repository "$MYDIR/charms" --constraints 'root-disk=40G' --config "$config_yaml" local:trusty/langpack-o-matic
110
 
    subordinate_charms "langpack-o-matic"
111
 
fi