#!/bin/bash

# Copyright (C) 2016 NIWA Hideyuki

FULCONDRIVER=`fulcon driver-name`
PATH=/usr/lib/slot-os/lib:/usr/lib/fulcon/driver/$FULCONDRIVER:/usr/lib/fulcon/lib:$PATH

SLOTOSDIR=/var/lib/slot-os

usage()
{
	echo "usage: list [ NAME ]"
}

lsdir() {
  ls -f --ind=none $1 | sed '/^\.\{1,2\}$/d'
}


if [ $# -ne 1 ]; then
	usage
	exit -1
fi

SNUM=$1
SNUM=`echo $SNUM | sed -e 's/slot//'` 
SNUM=`expr $SNUM + 0`
if [ ! -x $SLOTOSDIR/slot/$i ]; then
	printf "error: slot%2d is not exist" $SNUM
	exit -1
fi

NAME=`cat $SLOTOSDIR/slot/$SNUM/fulcon`
if [ x"$NAME" == "-" ]; then
	printf "error: slot%2d has not a container" $SNUM
	exit -1
fi

fulcon console $NAME

exit 0

