scripts/common.zsh

85 lines
1.7 KiB
Bash

#!/bin/zsh
##############################
# #
# NFS client configuration #
# #
##############################
CLIENT=(client)
MOUNTPOINT=(/mnt/test)
SCRATCHMNT=(/mnt/scratch)
##############################
# #
# NFS server configuration #
# #
##############################
SERVER=(server)
EXPORT=(/srv/xfs/test)
SCRATCH=(/srv/xfs/scratch)
###########################
# #
# General configuration #
# #
###########################
BIN=$HOME/bin
DMESG=()
PROTO=(tcp)
SRVDMESG=()
USER=$(whoami)
VERSION=(3 4.0 4.1 4.2)
######################
# #
# Shared functions #
# #
######################
function client_run()
{
zparseopts -D -K t=TERMINAL
[[ ! -z $TERMINAL ]] && SSH_OPT="-t"
ssh $SSH_OPT ${CLIENT[-1]} sudo run.zsh $*
}
function client_setup()
{
ssh ${CLIENT[-1]} sudo setup.zsh $*
}
function setup_client_func()
{
client_setup testdirs.zsh ${SERVER[-1]} ${EXPORT[-1]} \
${MOUNTPOINT[-1]} $USER
}
function prepare_to_test()
{
$BIN/vm.zsh boot ${CLIENT[-1]} ${SERVER[-1]}
$BIN/install-scripts.zsh ${CLIENT[-1]}
if [ ${#DMESG} -gt 0 ]; then
ssh ${CLIENT[-1]} "sudo dmesg --clear"
fi
if [ ${#SRVDMESG} -gt 0 ]; then
ssh ${SERVER[-1]} "sudo dmesg --clear"
fi
if [ ${#RDMA} -gt 0 ]; then
PROTO+=(rdma)
$BIN/rping.zsh ${RDMA[-1]} ${CLIENT[-1]} ${SERVER[-1]}
fi
setup_client_func
echo
}
TRAPEXIT()
{
if [ ${#DMESG} -gt 0 ]; then
ssh ${CLIENT[-1]} "sudo dmesg --color=always"
fi
if [ ${#SRVDMESG} -gt 0 ]; then
ssh ${SERVER[-1]} "sudo dmesg --color=always"
fi
}