2010-10-21 22:50:12 +00:00
|
|
|
#! @shell@ -e
|
|
|
|
|
|
|
|
# Shows the usage of this command to the user
|
|
|
|
|
|
|
|
showUsage()
|
|
|
|
{
|
2010-12-06 22:02:37 +00:00
|
|
|
echo "Usage: $0 network_expr"
|
2010-10-21 22:50:12 +00:00
|
|
|
echo "Options:"
|
|
|
|
echo
|
2010-12-06 22:02:37 +00:00
|
|
|
echo "--use-backdoor Indicates that the backdoor must be enabled so that the VMs can be accessed through a UNIX domain socket"
|
|
|
|
echo "--no-out-link Do not create a 'result' symlink"
|
|
|
|
echo "--show-trace Shows the output trace"
|
|
|
|
echo "-h,--help Shows the usage of this command"
|
2010-10-21 22:50:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Parse valid argument options
|
|
|
|
|
2010-12-08 14:30:55 +00:00
|
|
|
PARAMS=`getopt -n $0 -o h -l use-backdoor,no-out-link,show-trace,help -- "$@"`
|
2010-10-21 22:50:12 +00:00
|
|
|
|
|
|
|
if [ $? != 0 ]
|
|
|
|
then
|
|
|
|
showUsage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
eval set -- "$PARAMS"
|
|
|
|
|
|
|
|
# Evaluate valid options
|
|
|
|
|
|
|
|
while [ "$1" != "--" ]
|
|
|
|
do
|
|
|
|
case "$1" in
|
|
|
|
--use-backdoor)
|
|
|
|
useBackdoorArg="--arg useBackdoor true"
|
|
|
|
;;
|
2010-12-06 22:02:37 +00:00
|
|
|
--no-out-link)
|
|
|
|
noOutLinkArg="--no-out-link"
|
|
|
|
;;
|
2010-10-21 22:50:12 +00:00
|
|
|
--show-trace)
|
|
|
|
showTraceArg="--show-trace"
|
|
|
|
;;
|
|
|
|
-h|--help)
|
|
|
|
showUsage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2010-12-06 22:02:37 +00:00
|
|
|
shift
|
|
|
|
|
2010-10-21 22:50:12 +00:00
|
|
|
# Validate the given options
|
|
|
|
|
2010-12-06 22:02:37 +00:00
|
|
|
if [ -z "$NIXOS" ]
|
2010-10-21 22:50:12 +00:00
|
|
|
then
|
2010-12-06 22:02:37 +00:00
|
|
|
NIXOS=/etc/nixos/nixos
|
2010-10-21 22:50:12 +00:00
|
|
|
fi
|
|
|
|
|
2010-12-06 22:02:37 +00:00
|
|
|
if [ "$@" = "" ]
|
2010-10-21 22:50:12 +00:00
|
|
|
then
|
2010-12-06 22:02:37 +00:00
|
|
|
echo "ERROR: A network expression must be specified!" >&2
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
networkExpr=$(readlink -f $@)
|
2010-10-21 22:50:12 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Build a network of VMs
|
|
|
|
|
2010-12-06 22:02:37 +00:00
|
|
|
nix-build $NIXOS/modules/installer/tools/nixos-build-vms/build-vms.nix --argstr networkExpr $networkExpr --argstr nixos $NIXOS --argstr nixpkgs $NIXPKGS_ALL $useBackdoorArg $noOutLinkArg $showTraceArg
|