#!/bin/bash 

# Fulcon - Full Container system
# Copyright (C) 2015-2016 NIWA Hideyuki

# check root
if [ ${EUID:-$UID} -ne 0 ] ; then
  echo "error: not executing without superuser privileges."
  exit 1
fi

export PATH=/usr/lib/fulcon/sbin:$PATH
export FULCONDIR=/var/lib/fulcon

mkdir -p /var/lib/fulcon

FLG_H=0

while getopts h OPT
do
  case $OPT in
    "h" ) FLG_H=1 ;;
  esac
done
shift `expr $OPTIND - 1`

if [ $# -eq 0 ] ; then
	less /usr/lib/fulcon/doc/help.txt
else
  if [ -f /usr/lib/fulcon/sbin/$1 ]; then
    EXLINE=`echo /usr/lib/fulcon/sbin/$* | sed -e 's/\$//g' -e 's/\`//g' -e "s/'//g" -e 's/\"//g' -e 's/;//g' -e 's/&//g' -e 's/|//g'`
    . $EXLINE
  else
    echo "error: unknown command:" $1
  fi
fi

exit 0
