blob: ca6983ebe41b7a0f5874867d62fe3d539d9c78d8 (
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
|
#!/bin/sh
# Copyright (C) 2014 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
set -e
usage() {
echo "Usage: cycle.sh some-system some-cluster [newversion]"
echo
echo "This builds and deploys the current checked out version of"
echo "some-system, applying it as a self-upgrade to the system you"
echo "are working in, using configuration from some-cluster."
echo "The upgrade is labelled TEST by default, or [newversion] if"
echo "specified, and is set to be the default for next boot."
}
if [ -z "$1" ] || [ -z "$2" ] || [ ! -z "$4" ] ; then
usage
exit 1
fi
newversion=TEST
if [ ! -z "$3" ] ; then
newversion=$3
if (echo "$newversion" | grep ' ' > /dev/null 2>&1) ; then
echo 'Version label must not contain spaces.'
exit 1
fi
fi
location=`cat $2 | grep location | sed 's/ \+//g' | cut -d":" -f2`
svm="ssh $location system-version-manager"
runningversion=`$svm get-running'`
if [ $runningversion = $newversion ]; then
echo "$newversion is currently running at $location"
echo "Maybe you want to boot into a different system version?"
exit 1
fi
$svm "set-default $runningversion"
if $svm "list" | grep -q "^$newversion$"; then
$svm "remove $newversion"
fi
echo $(date +%Y-%m-%d\ %T) "Cyclng $location from $runningversion to $newversion"
morph gc
morph build "$1"
sed -i "s|^- morph: .*$|- morph: $1|" "$2"
host=`ssh $location hostname`
morph deploy --upgrade "$2" self.HOSTNAME=$host self.VERSION_LABEL=$newversion
$svm "list"
|