#!/bin/bash # enter-baserock -- Tool to enter a Baserock chroot using schroot # Copyright (C) 2014 Codethink Ltd # # 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; either version 2 of the License, or # (at your option) any later version. # # 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. 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"