summaryrefslogtreecommitdiff
path: root/scripts/files/elements/ubuntu-pxc/pre-install.d/10-percona-apt-key
blob: d323645510c1d21a44caed027b2d88d4af82edaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash

# CONTEXT: GUEST during PRE-CONSTRUCTION as ROOT
# PURPOSE: Setup apt-repo list so that we can connect to Percona's repo

set -e
set -o xtrace

[ -n "${GUEST_USERNAME}" ] || die "GUEST_USERNAME needs to be set to the user for the guest image"
[ -n "${RELEASE}" ] || die "RELEASE must be set to either Precise or Quantal"

#5  add Percona GPG key
if [ ! -e /home/${GUEST_USERNAME}/.gnupg ]; then
    mkdir -p /home/${GUEST_USERNAME}/.gnupg
fi

# sometimes the primary key server is unavailable and we should try an
# alternate.  see
# https://bugs.launchpad.net/percona-server/+bug/907789.  Disable
# shell errexit so we can interrogate the exit code and take action
# based on the exit code. We will reenable it later.
function get_key_robust() {
    KEY=$1
    set +e

    apt-key adv --keyserver hkp://keys.gnupg.net --recv-keys ${KEY}

    if [ "$?" -ne "0" ];
    then
        echo "Trying alternate keyserver hkp://keyserver.ubuntu.com"
        set -e
        apt-key adv --keyserver hkp://keyserver.ubuntu.com --recv-keys ${KEY}
    fi

    set -e
}

get_key_robust 1C4CBDCDCD2EFD2A
get_key_robust 9334A25F8507EFA5

# add Percona repo
# creates the percona sources list
cat <<EOL > /etc/apt/sources.list.d/percona.list
deb http://repo.percona.com/apt $RELEASE main
deb-src http://repo.percona.com/apt $RELEASE main
EOL

# force an update
apt-get update