aboutsummaryrefslogtreecommitdiff
path: root/control/deploy-control-node
blob: 0fd6c8a4a084bdb17c2426fa1ccceb4a37f669dd (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
###############################################################################
# Copyright (c) 2011 Linaro
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
###############################################################################
#
# This scripts deploys updates to master node
# of linaro-cloud-buildd infrastructure
#

set -ex
TSTAMP=`date '+%Y%m%dT%H%M'`

function header() {
    echo "======================================"
    echo $1
    echo "======================================"
}

function bzr_deploy() {
    bzr_repo=$1
    deploy_dir=$2
    owner=$3
    if [ -e $deploy_dir -a ! -h $deploy_dir ]; then
        sudo mv $deploy_dir $deploy_dir.old
    fi
    bzr branch $bzr_repo /tmp/$deploy_dir.new
    sudo mv /tmp/$deploy_dir.new $deploy_dir.new
    revno=`bzr revno $deploy_dir.new`
    sudo mv $deploy_dir.new $deploy_dir-r$revno-$TSTAMP
    sudo ln -sfn $deploy_dir-r$revno-$TSTAMP $deploy_dir
    sudo chown -R $owner $deploy_dir-r$revno-$TSTAMP
}

# be sure to execute in deployment dir
cd

function deploy_mirror() {
    header "Deploying linaro-android-mirror"
    running_repos=`ps ax|grep bin/repo|grep -v grep || true`
    if [ -n "$running_repos" ]; then
        echo "There appear to be mirror operations in progress currently:"
        echo $running_repos
        echo
        echo "Press Ctrl+C and ensure all outstanding operations are completed"
        echo "Press Enter to continue anyway"
        read dummy
    fi

    linaro-android-mirror/linaro-android-mirror stop
    bzr_deploy ${MIRROR_BRANCH:-"lp:linaro-android-mirror"} linaro-android-mirror ubuntu
    linaro-android-mirror/linaro-android-mirror start
}

function deploy_frontend() {
    header "Deploying linaro-android-frontend"
    sudo service apache2 stop
    cd ~build-system-frontend
    bzr_deploy ${FRONTEND_BRANCH:-"lp:linaro-android-frontend"} frontend build-system-frontend
    (cd frontend; sudo -u build-system-frontend make)
    sudo -u build-system-frontend ln -s ../settings_prod.py frontend/
    sudo service apache2 start
}

deploy_mirror
deploy_frontend