<commit_before>CUR_DIR_TMP="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

source "$CUR_DIR_TMP/on-premise.sh"

#overrides and custom minerva100 functions


#minerva needs *real* user first
get_ssh_user() {

  #check if we can change from root user
  if [ "$requireRootFirst" ] ; then
    #"WARNINIG: connecting as root"
    echo "npoggi"
  else
    echo "$userAloja"
  fi
}

vm_initial_bootstrap() {

  local bootstrap_file="Initial_Bootstrap"

  if check_bootstraped "$bootstrap_file" ""; then
    logger "Bootstraping $vm_name "

    local home_prefix="/users/scratch"
    vm_execute "
sudo useradd --create-home --home $home_prefix/$userAloja -s /bin/bash $userAloja;
sudo echo -n '$userAloja:$passwordAloja' |sudo chpasswd;
sudo adduser $userAloja sudo;
sudo adduser $userAloja adm;

sudo bash -c \"echo '%sudo ALL=NOPASSWD:ALL' >> /etc/sudoers\";

sudo mkdir -p $home_prefix/$userAloja/.ssh;
sudo bash -c \"echo '${insecureKey}' >> sudo $home_prefix/$userAloja/.ssh/authorized_keys\";
sudo chown -R $userAloja: $home_prefix/$userAloja/.ssh;
sudo cp $home_prefix/$userAloja/.profile $home_prefix/$userAloja/.bashrc /root/;
"

    #allow sudo from our new user
    #vm_update_template "/etc/sudoers" "%sudo ALL=NOPASSWD:ALL" "secured_file"

    test_action="$(vm_execute " [ -f $home_prefix/$userAloja/.ssh/authorized_keys ] && echo '$testKey'")"

    if [ "$test_action" == "$testKey" ] ; then
      #set the lock
      check_bootstraped "$bootstrap_file" "set"
    else
      logger "ERROR at $bootstrap_file for $vm_name. Test output: $test_action"
    fi

  else
    logger "$bootstrap_file already configured"
  fi
}<commit_msg>Create RAID-0 function<commit_after>CUR_DIR_TMP="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

source "$CUR_DIR_TMP/on-premise.sh"

#overrides and custom minerva100 functions


#minerva needs *real* user first
get_ssh_user() {

  #check if we can change from root user
  if [ "$requireRootFirst" ] ; then
    #"WARNINIG: connecting as root"
    echo "npoggi"
  else
    echo "$userAloja"
  fi
}

vm_initial_bootstrap() {

  local bootstrap_file="Initial_Bootstrap"

  if check_bootstraped "$bootstrap_file" ""; then
    logger "Bootstraping $vm_name "

    local home_prefix="/users/scratch"
    vm_execute "
sudo useradd --create-home --home $home_prefix/$userAloja -s /bin/bash $userAloja;
sudo echo -n '$userAloja:$passwordAloja' |sudo chpasswd;
sudo adduser $userAloja sudo;
sudo adduser $userAloja adm;

sudo bash -c \"echo '%sudo ALL=NOPASSWD:ALL' >> /etc/sudoers\";

sudo mkdir -p $home_prefix/$userAloja/.ssh;
sudo bash -c \"echo '${insecureKey}' >> sudo $home_prefix/$userAloja/.ssh/authorized_keys\";
sudo chown -R $userAloja: $home_prefix/$userAloja/.ssh;
sudo cp $home_prefix/$userAloja/.profile $home_prefix/$userAloja/.bashrc /root/;
"

    test_action="$(vm_execute " [ -f $home_prefix/$userAloja/.ssh/authorized_keys ] && echo '$testKey'")"

    if [ "$test_action" == "$testKey" ] ; then
      #set the lock
      check_bootstraped "$bootstrap_file" "set"
    else
      logger "ERROR at $bootstrap_file for $vm_name. Test output: $test_action"
    fi

  else
    logger "$bootstrap_file already configured"
  fi
}

vm_create_RAID0() {

  local bootstrap_file="vm_create_RAID0"

  if check_bootstraped "$bootstrap_file" ""; then
    logger "Executing $bootstrap_file"

    local num_drives="6"
    vm_execute "
sudo umount /dev/sdb{b..g}1;
yes | sudo mdadm -C /dev/md0 -l raid0 -n $num_drives /dev/sd{b..g}1;
sudo mkfs.ext4 /dev/md0;
"
#mount done by fstab
#sudo mount /dev/md0 /scratch/attached/1;
#not necessary to mark partition as raid auto apparently
#parted -s /dev/sdf -- mklabel gpt mkpart primary 0% 100% set 1 raid on

    logger "INFO: Updating /etc/fstab template"
    vm_update_template "/etc/fstab" "/dev/md0                /scratch/attached/1              ext4    deaults         0 0" "secured_file"

    logger "INFO: remounting disks according to fstab"
    vm_execute "
sudo mount -a;
sudo chown -R pristine: /scratch/attached/1;
"

    test_action="$(vm_execute " [ \"\$(sudo mdadm --examine /dev/sdb1 |grep 'Raid Devices : $num_drives')\" ] && echo '$testKey'")"

    if [ "$test_action" == "$testKey" ] ; then
      #set the lock
      check_bootstraped "$bootstrap_file" "set"
    else
      logger "ERROR at $bootstrap_file for $vm_name. Test output: $test_action"
    fi

  else
    logger "$bootstrap_file already configured"
  fi

}

vm_final_bootstrap() {
  logger "INFO: Creating RAID0 on 6 disks"
  vm_create_RAID0
}
{'fraction_non_alphanumeric': 0.13303769401330376, 'fraction_numerical': 0.007760532150776054, 'mean_word_length': 3.7186192468619246, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, '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': '6942570', 'n_tokens_mistral': 1722, 'n_tokens_neox': 1593, 'n_words': 417}