Skip to content
Snippets Groups Projects
run.sh 994 B
Newer Older
#!/usr/bin/env bash

set -e

if [ "$UID" -ne 0 ]; then
    echo "Script must be run as root"
    exit 1
fi

export EXP_ROOT="$PWD"

source ./configs/base.sh

if [ -e "./configs/$(uname -r).sh" ]; then
    echo "Loading kernel-specific config for $(uname -r)"
    source ./configs/$(uname -r).sh
fi

source ./tunings/base.sh

while [[ $# -gt 0 ]]; do
    case $1 in
        -e)
            EXPERIMENT="$2"
            shift
            shift
            ;;
        *)
            break
            ;;
    esac
done

if [ -z "$EXPERIMENT" ]; then
    echo "Must specify an experiment to run"
    exit 1
fi

if [ ! -f "./experiments/$EXPERIMENT.sh" ]; then
     echo "$EXPERIMENT does not exist"
     exit 1
fi

source "./experiments/$EXPERIMENT.sh"

pre_start

EXPERIMENT_NAME="$EXPERIMENT"
if [ ! -z "$EXPERIMENT_NAME_EXT" ]; then
    EXPERIMENT_NAME="$EXPERIMENT.$EXPERIMENT_NAME_EXT"
fi

DATA_OUT="$EXP_ROOT/data/$EXPERIMENT_NAME"

rm -rf "$DATA_OUT"
mkdir -p "$DATA_OUT"

run_exp

post_start