#!/bin/sh
source "$RUNES_INTERFACE_DIR/RUNES/functions.sh"
[ -f "$RUNES_CONFIG_PATH" ] && source "$RUNES_CONFIG_PATH"


eval $(runes_cmdline param_ VIVER)
# 

eval $(runes_interface ipv4_ LOCAL IPv4Network getNetworkInterfacesList)
# ipv4_Interfaces

# 最初の1つを使う
netdev=$(echo $ipv4_Interfaces | cut -d ' ' -f 1)

#eval $(runes_interface netdev_ LOCAL IPv4Network getInterfaceInfo $netdev)
# netdev_IPAddress=

#eval $(runes_interface viver_ LOCAL VIVER getSystemInfo)
# BootStrap=
# BootStrapIP=
# BootStrapPort=
# ToRAM=
# CompressedPath=
# Ark=

if [ -n "$CompressedPath" ];then
	nbdpath="$CompressedPath"
else
	nbdpath=
fi

if [ -n "$viver_BootStrapPort" ];then
	nbdport=$viver_BootStrapPort
else
	nbdport=19660
fi


#./bin/nbd-server $nbdport $nbdpath
./bin/vfield -port $nbdport -if $netdev -file /VIVER/disk/fixed.squash &
if [ $? -eq 0 ];then
	gprintf_success "VFIELD Primary Node for VIVER successfully started"
else
	gprintf_failure "Failed to start VFIELD Primary Node for VIVER"
fi
