<commit_before>#!/bin/bash
SCRIPT_VERSION='0.1.0'
UPLOAD_URL='http://google.com'
REPO_URL='https://raw.github.com/benchmarky/benchmarky-linux/master/'
usage () {
	echo "Usage: bash $0 [ -h ] -e '<EMAIL>' -p 'SuperHosting.<EMAIL>' -l 'PlanName' -c '$24' -t all [ -a ] [ -q ]" 
	echo -e "\t-e - email"
	echo -e "\t-h - show this help"
	echo -e "\t-p - provider"
	echo -e "\t-l - plan"
	echo -e "\t-c - tariff (cost per month)"
	echo -e "\t-t - which tests to run (comma-separated list (disk,unixbench,bandwidth) or all"
	echo -e "\t-a - keep report private"
	echo -e "\t-q - show less messages"
}


# Some variables
LOGFILE=$PWD/script.log
WORKDIR=$PWD
TMPDIR=$PWD/tmpdir
SHOWLOG=$PWD/stdout.log
# default values
TESTS='all'
ANONYOMOUS='false'
QUIETLY='false'

EMAIL='null'
PROVIDER='null'
TARIFF='null'
PLAN='null'

while getopts "he:p:l:t:c:aq" opt; do
	case "$opt" in
	h)
		usage
		exit 0
		;;
	e)	EMAIL="$OPTARG"
		;;	
	p)	PROVIDER="$OPTARG"
		;;	
	l)	PLAN="$OPTARG"
		;;	
	c)	TARIFF="$OPTARG"
		;;	
	t)	TESTS="$OPTARG"
		;;	
	a)	ANONYOMOUS='yes'
		;;
	q)	QUIETLY='yes'
		;;
	esac
done

# Validate parameters
if [ "$EMAIL" = 'null' -o "$PROVIDER" = 'null' -o "$TARIFF" = 'null' -o "$PLAN" = 'null' ]; then
	usage
	exit 0
fi
if [ $QUIETLY = 'false' ]; then
	SHOWLOG=$LOGFILE
fi

# Here we would like to go to background
if test -t 1 ; then
	echo "Perfect! ¡Perfecto! Parfait! Perfekt!

Script has started running.

     ( (
      ) )        Script will now switch to the background.
     .--/.
    |'---'|-,    Feel free to disconnect from terminal and 
    |     | ))   go brew a nice cup coffee (or tea) while 
    |     |-'    it is running.
    '.___.'
          
You may also sit down and watch the log output in the 
terminal. Don't worry, we will also send it to your 
email and you can find it on your server as script.log

Caution: You can disconnect from log by pressing Ctrl+C 
anytime."
	rm -f $SHOWLOG $LOGFILE
	touch $SHOWLOG
	nohup bash "$0" "$@" >> $SHOWLOG 2>&1 &
	tail -F $SHOWLOG -n 25
	exit 0
fi
sleep 20
# Parse required tests
NEED_DISK='null'
NEED_BANDWIDTH='null'
NEED_UNIXBENCH='null'

if [ $TESTS = 'all' ]; then
	NEED_DISK='yes'
	NEED_BANDWIDTH='yes'
	NEED_UNIXBENCH='yes'
else 
	for TEST in `echo $TESTS | sed 's/,/ /g'`;do
		case $TEST in
			disk) 
				NEED_DISK='yes'
				;;
			unixbench) 
				NEED_UNIXBENCH='yes'
				;;
			bandwidth) 
				NEED_BANDWIDTH='yes'
				;;
		esac
	done
fi

# Prepare environment
echo "Creating directory $TMPDIR"
rm -rf $TMPDIR
mkdir -p $TMPDIR 
if [ ! -d $TMPDIR ];then
	echo "Can't create directory $TMPDIR" && exit 1
fi
cd $TMPDIR
# touch log file
#touch $LOGFILE
DATE=`date`
echo "==DATE==" >>$LOGFILE
echo $DATE  >> $LOGFILE
echo "==VERSION==" >>$LOGFILE
echo "VERSION: ${SCRIPT_VERSION}" >>$LOGFILE
echo "==PARAMETERS==" >>$LOGFILE
echo "EMAIL: ${EMAIL}" >>$LOGFILE
echo "PROVIDER: ${PROVIDER}" >>$LOGFILE
echo "PLAN: ${PLAN}" >>$LOGFILE
echo "TARIFF: ${TARIFF}" >>$LOGFILE
echo "TESTS: ${TESTS}" >>$LOGFILE
echo "ANONYOMOUS: ${ANONYOMOUS}" >>$LOGFILE

# We can test bandwidth without additional packages
# For test unixbench and disk we need them
function requires() {
  if [ `$1 >/dev/null; echo $?` -ne 0 ]; then
    TO_INSTALL="$TO_INSTALL $2"
  fi 
}
function apt_requires() {
	installed=`dpkg -s $1 2>/dev/null| grep -c 'install ok installed'`
	if [ $installed = 0 ]; then<commit_msg>Added ID parameter<commit_after>#!/bin/bash
SCRIPT_VERSION='0.1.0'
UPLOAD_URL='http://google.com'
REPO_URL='https://raw.github.com/benchmarky/benchmarky-linux/master/'
usage () {
	echo "Usage: bash $0 [ -h ] -e '<EMAIL>' -p 'SuperHosting.com' -l 'PlanName' -c '\$24' -t all [ -a ] [ -q ]" 
	echo -e "\t-e - email"
	echo -e "\t-h - show this help"
	echo -e "\t-p - provider"
	echo -e "\t-l - plan"
	echo -e "\t-c - tariff (cost per month)"
	echo -e "\t-t - which tests to run (comma-separated list (disk,unixbench,bandwidth) or all"
	echo -e "\t-a - keep report private"
	echo -e "\t-q - show less messages"
}


# Some variables
LOGFILE=$PWD/script.log
WORKDIR=$PWD
TMPDIR=$PWD/tmpdir
SHOWLOG=$PWD/stdout.log
# default values
TESTS='all'
ANONYOMOUS='false'
QUIETLY='false'

EMAIL='null'
PROVIDER='null'
TARIFF='null'
PLAN='null'
ID='null'

while getopts "he:p:l:t:c:i:aq" opt; do
	case "$opt" in
	h)
		usage
		exit 0
		;;
	e)	EMAIL="$OPTARG"
		;;	
	p)	PROVIDER="$OPTARG"
		;;	
	l)	PLAN="$OPTARG"
		;;	
	c)	TARIFF="$OPTARG"
		;;	
	t)	TESTS="$OPTARG"
		;;	
	i)	ID="$OPTARG"
		;;	
	a)	ANONYOMOUS='yes'
		;;
	q)	QUIETLY='yes'
		;;
	esac
done

# Validate parameters
if [ "$EMAIL" = 'null' -o "$PROVIDER" = 'null' -o "$TARIFF" = 'null' -o "$PLAN" = 'null' ]; then
	usage
	exit 0
fi
if [ $QUIETLY = 'false' ]; then
	SHOWLOG=$LOGFILE
fi

# Here we would like to go to background
if test -t 1 ; then
	echo "Perfect! ¡Perfecto! Parfait! Perfekt!

Script has started running.

     ( (
      ) )        Script will now switch to the background.
     .--/.
    |'---'|-,    Feel free to disconnect from terminal and 
    |     | ))   go brew a nice cup coffee (or tea) while 
    |     |-'    it is running.
    '.___.'
          
You may also sit down and watch the log output in the 
terminal. Don't worry, we will also send it to your 
email and you can find it on your server as script.log

Caution: You can disconnect from log by pressing Ctrl+C 
anytime."
	rm -f $SHOWLOG $LOGFILE
	touch $SHOWLOG
	nohup bash "$0" "$@" >> $SHOWLOG 2>&1 &
	tail -F $SHOWLOG -n 25
	exit 0
fi
sleep 20
# Parse required tests
NEED_DISK='null'
NEED_BANDWIDTH='null'
NEED_UNIXBENCH='null'

if [ $TESTS = 'all' ]; then
	NEED_DISK='yes'
	NEED_BANDWIDTH='yes'
	NEED_UNIXBENCH='yes'
else 
	for TEST in `echo $TESTS | sed 's/,/ /g'`;do
		case $TEST in
			disk) 
				NEED_DISK='yes'
				;;
			unixbench) 
				NEED_UNIXBENCH='yes'
				;;
			bandwidth) 
				NEED_BANDWIDTH='yes'
				;;
		esac
	done
fi

# Prepare environment
echo "Creating directory $TMPDIR"
rm -rf $TMPDIR
mkdir -p $TMPDIR 
if [ ! -d $TMPDIR ];then
	echo "Can't create directory $TMPDIR" && exit 1
fi
cd $TMPDIR
# touch log file
#touch $LOGFILE
DATE=`date`
echo "==DATE==" >>$LOGFILE
echo $DATE  >> $LOGFILE
echo "==VERSION==" >>$LOGFILE
echo "VERSION: ${SCRIPT_VERSION}" >>$LOGFILE
echo "==PARAMETERS==" >>$LOGFILE
echo "EMAIL: ${EMAIL}" >>$LOGFILE
echo "PROVIDER: ${PROVIDER}" >>$LOGFILE
echo "PLAN: ${PLAN}" >>$LOGFILE
echo "TARIFF: ${TARIFF}" >>$LOGFILE
echo "TESTS: ${TESTS}" >>$LOGFILE
echo "ANONYOMOUS: ${ANONYOMOUS}" >>$LOGFILE
echo "ID: ${ID}" >>$LOGFILE
# We can test bandwidth without additional packages
# For test unixbench and disk we need them
function requires() {
  if [ `$1 >/dev/null; echo $?` -ne 0 ]; then
    TO_INSTALL="$TO_INSTALL $2"
  fi 
}
function apt_requires() {
	installed=`dpkg -s $1 2>/dev/null| grep -c 'install ok installed'`
	if [ $installed = 0 ]; then
{'fraction_non_alphanumeric': 0.1663714201358134, 'fraction_numerical': 0.0070859167404783, 'mean_word_length': 3.329073482428115, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 62, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2031805', 'n_tokens_mistral': 2922, 'n_tokens_neox': 2777, 'n_words': 806}