summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2014-02-28 09:32:05 (GMT)
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2014-03-05 11:04:16 (GMT)
commit4f4c23e079853e931563b513f6ae772623ec5d46 (patch)
tree22aab02a2086d6963331f7fbab8045444e02b4b8
parent84797ecf96f96c8659fbfc16f88577ab0b4125ca (diff)
downloadbaserock-chroot-4f4c23e079853e931563b513f6ae772623ec5d46.tar.gz
Add tool to simplify entering baserock chroots
-rwxr-xr-xenter-baserock23
1 files changed, 23 insertions, 0 deletions
diff --git a/enter-baserock b/enter-baserock
new file mode 100755
index 0000000..f5b6951
--- /dev/null
+++ b/enter-baserock
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+SCHROOT_BASE="${SCHROOT_BASE:-/etc/schroot}"
+SCHROOT_CONF="${SCHROOT_CONF:-${SCHROOT_BASE}/schroot.conf}"
+BASEROCK_BASE="${BASEROCK_BASE:-/opt/baserock/chroots}"
+
+baserock_default () {
+ (cd "${BASEROCK_BASE}" && ls -d */default) 2>/dev/null | sed -e's@/default$@@' | head -1
+}
+
+CHOSEN="$1"
+
+if test "x$CHOSEN" = "x"; then
+ CHOSEN=$(baserock_default)
+fi
+
+if test "x$CHOSEN" = "x"; then
+ echo "No default found, cannot enter baserock without a tag"
+ exit 1
+fi
+
+cd /
+exec sudo -H schroot -c "baserock-$CHOSEN"