#!/bin/sh
exec 2>&1
[ -r ./conf ] && . ./conf
MIN_MEMORY=${MIN_MEMORY:-256}
free -m | awk '/Mem:/ {exit ($2 >= ('"$MIN_MEMORY"'))?0:1}' || exit 0

if [ -n "$IONICE_OPTS" ]; then
	if [ -x "$IONICE" ]; then
		RUNNER="$IONICE $IONICE_OPTS"
	else
		echo "ionice not found, running with normal io priority" 1>&2
	fi
fi

exec $RUNNER preload $OPTS -f 2>&1
