summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Sherwood <paul.sherwood@codethink.co.uk>2014-11-29 11:12:58 +0000
committerPaul Sherwood <paul.sherwood@codethink.co.uk>2014-11-30 01:45:20 +0000
commiteefd9ac027ec2d3fff9aac4e5399113697f2441a (patch)
treebb6297d14815f29603513628634cbe70db53d234
parent778f4b6a95dc3510d9d2d70866d5142691da1a78 (diff)
downloaddefinitions-baserock/ps/cycle-from-chroot.tar.gz
Make cycle.sh usable for build/deploys onto target (eg from chroot)baserock/ps/cycle-from-chroot
This re-write runs all of the system-version-manager commands on the target cluster via ssh, so in addition to self-upgrades, cycle.sh can now be used to upgrade a target device (eg a devboard) while working in Baserock VM or chroot
-rwxr-xr-xscripts/cycle.sh27
1 files changed, 16 insertions, 11 deletions
diff --git a/scripts/cycle.sh b/scripts/cycle.sh
index c0e2aa67..ca6983eb 100755
--- a/scripts/cycle.sh
+++ b/scripts/cycle.sh
@@ -14,6 +14,8 @@
# 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
@@ -38,24 +40,27 @@ if [ ! -z "$3" ] ; then
fi
fi
-if system-version-manager get-running | grep -q "^$newversion$"; then
- echo "You are currently running the $newversion system."
+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
-set -e
-set -v
-
-runningversion=`system-version-manager get-running`
-system-version-manager set-default $runningversion
-if system-version-manager list | grep -q "^$newversion$"; then
- system-version-manager remove $newversion
+$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"
-morph deploy --upgrade "$2" self.HOSTNAME=$(hostname) self.VERSION_LABEL=$newversion
-system-version-manager list
+host=`ssh $location hostname`
+morph deploy --upgrade "$2" self.HOSTNAME=$host self.VERSION_LABEL=$newversion
+$svm "list"