Sophie

Sophie

distrib > Fedora > 13 > i386 > media > os > by-pkgid > 3b1c70357ba64c093a73a994f980ca3c > files > 11

schroot-1.2.3-5.fc13.i686.rpm

#!/bin/sh
# Copyright © 2005-2007  Roger Leigh <rleigh@debian.org>
#
# schroot 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 3 of the License, or
# (at your option) any later version.
#
# schroot 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, see
# <http://www.gnu.org/licenses/>.
#
#####################################################################

set -e

if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then
    . "$CHROOT_SCRIPT_CONFIG"
elif [ "$2" = "ok" ]; then
    echo "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist"
    exit 1
fi

if [ $1 = "setup-start" ] || [ $1 = "setup-recover" ]; then

    if [ "$AUTH_VERBOSITY" = "verbose" ]; then
	echo "AUTH_USER=$AUTH_USER"
	echo "AUTH_VERBOSITY=$AUTH_VERBOSITY"
	echo "MOUNT_DIR=$MOUNT_DIR"
	echo "LIBEXEC_DIR=$LIBEXEC_DIR"
	echo "PID=$PID"
	echo "SESSION_ID=$SESSION_ID"
	echo "CHROOT_TYPE=$CHROOT_TYPE"
	echo "CHROOT_NAME=$CHROOT_NAME"
	echo "CHROOT_DESCRIPTION=$CHROOT_DESCRIPTION"
	echo "CHROOT_SCRIPT_CONFIG=$CHROOT_SCRIPT_CONFIG"
	echo "CHROOT_MOUNT_LOCATION=$CHROOT_MOUNT_LOCATION"
	echo "CHROOT_LOCATION=$CHROOT_LOCATION"
	echo "CHROOT_PATH=$CHROOT_PATH"
	echo "CHROOT_MOUNT_DEVICE=$CHROOT_MOUNT_DEVICE"
	if [ "$CHROOT_TYPE" = "plain" ] || [ "$CHROOT_TYPE" = "directory" ]; then
	    :
	elif [ "$CHROOT_TYPE" = "file" ]; then
	    echo "CHROOT_FILE=$CHROOT_FILE"
	    echo "CHROOT_FILE_REPACK=$CHROOT_FILE_REPACK"
	elif [ "$CHROOT_TYPE" = "block-device" ] || [ "$CHROOT_TYPE" = "lvm-snapshot" ]; then
	    echo "CHROOT_DEVICE=$CHROOT_DEVICE"
	    echo "CHROOT_MOUNT_OPTIONS=$CHROOT_MOUNT_OPTIONS"
	    if [ "$CHROOT_TYPE" = "lvm-snapshot" ]; then
		echo "CHROOT_LVM_SNAPSHOT_NAME=$CHROOT_LVM_SNAPSHOT_NAME"
		echo "CHROOT_LVM_SNAPSHOT_DEVICE=$CHROOT_LVM_SNAPSHOT_DEVICE"
		echo "CHROOT_LVM_SNAPSHOT_OPTIONS=$CHROOT_LVM_SNAPSHOT_OPTIONS"
	    fi
	fi
	echo "CHROOT_SESSION_CREATE=$CHROOT_SESSION_CREATE"
	echo "CHROOT_SESSION_CLONE=$CHROOT_SESSION_CLONE"
	echo "CHROOT_SESSION_PURGE=$CHROOT_SESSION_PURGE"
        echo "FSTAB=$FSTAB"
        echo "SBUILD=$SBUILD"
    fi

    case "$CHROOT_TYPE" in
	plain | directory)
	    if [ ! -d "$CHROOT_LOCATION" ]; then
		echo "Directory '$CHROOT_LOCATION' does not exist"
		exit 1
	    fi
	    ;;
	file | loopback)
	    if [ ! -f "$CHROOT_FILE" ]; then
		echo "File '$CHROOT_FILE' does not exist"
		exit 1
	    fi
	    ;;
	block-device | lvm-snapshot)
	    if [ ! -b "$CHROOT_DEVICE" ]; then
		echo "Device '$CHROOT_DEVICE' does not exist"
		exit 1
	    fi
	    ;;
	*)
	    echo "Unknown chroot type $CHROOT_TYPE"
	    exit 1
	    ;;
    esac

    # A basic safety check, so that the root filesystem doesn't get
    # toasted by accident.
    if [ -z "$CHROOT_PATH" ] || [ "$CHROOT_PATH" = "/" ] || [ "$CHROOT_LOCATION" = "/" ]; then
	echo "Invalid chroot mount location: '$CHROOT_LOCATION'"
	exit 1
    fi

fi