<commit_before>#!/bin/bash -x

identity=${1}
[ "${identity}" = "" ] && echo "** PLEASE PROVIDE A PATH TO AWS IDENTITY CREDENTIALS (PEM FILE)**" && exit 255

mkdir -p logs

hosts=()

while read line
do
  OLDIFS=$IFS;
  IFS=, vals=($line)
  IFS=$OLDIFS

  name=${vals[0]}
  ip=${vals[1]}
  dns=$(echo ${vals[2]} | cut -d '"' -f2)
  pwd=$(echo ${vals[3]} | cut -d '"' -f2)

  hosts+=("${dns}")

  bin/issh cloud-user@${dns} -i ${identity} -tt "echo ${pwd} | sudo passwd demo --stdin" </dev/null &>logs/$dns-1-passwd
  [ $? -ne 0 ] && echo "*** ERROR $? RETURNED FOR ${dns} WHILST SETTING DEMO PASSWORD, bailing ***" && exit 1

  scp -i ${identity} -S bin/issh target/* cloud-user@$dns: &>logs/$dns-2-scp
  [ $? -ne 0 ] && echo "*** ERROR $? RETURNED FOR ${dns} WHILST COPYING SCRIPTS, bailing ***" && exit 1

  bin/issh -i ${identity} -tt cloud-user@$dns sudo 'bash -c "cd /home/cloud-user; ./openshift-aws-reip.sh"' </dev/null &>logs/$dns-3-reip &
done < creds.csv

echo "*** WAITING FOR REIP PROCESSES ***"
wait

for dns in "${hosts[@]}"
do
  bin/issh -i ${identity} -tt cloud-user@$dns sudo 'sed -i -e "/^PermitEmptyPasswords yes/ d" /etc/ssh/sshd_config' &>logs/$dns-4-sshd
  bin/issh -i ${identity} -tt cloud-user@$dns sudo 'sed -i -e "/^PasswordAuthentication no/ d" /etc/ssh/sshd_config' &>>logs/$dns-4-sshd
  bin/issh -i ${identity} -tt cloud-user@$dns sudo 'systemctl restart sshd.service' &>>logs/$dns-4-sshd
  bin/issh -i ${identity} -tt cloud-user@$dns sudo 'bash -c "cd /home/cloud-user; ./create-novnc.sh"' &>logs/$dns-5-novnc &
done

echo "*** WAITING FOR NOVNC PROCESSES ***"
wait

for dns in "${hosts[@]}"
do
  bin/issh -i ${identity} -tt cloud-user@$dns sudo ./warm-openshift.sh &>logs/$dns-6-warmup &
done

echo "*** WAITING FOR WARMUP PROCESSES ***"
wait

for dns in "${hosts[@]}"
do
  bin/issh -i ${identity} -tt cloud-user@$dns nohup sudo ./warm-ebs.sh &>logs/$dns-7-ebs
done<commit_msg>note that &>> doesn't work on a mac, thanks mperciva<commit_after>#!/bin/bash -x

identity=${1}
[ "${identity}" = "" ] && echo "** PLEASE PROVIDE A PATH TO AWS IDENTITY CREDENTIALS (PEM FILE)**" && exit 255

mkdir -p logs

hosts=()

while read line
do
  OLDIFS=$IFS;
  IFS=, vals=($line)
  IFS=$OLDIFS

  name=${vals[0]}
  ip=${vals[1]}
  dns=$(echo ${vals[2]} | cut -d '"' -f2)
  pwd=$(echo ${vals[3]} | cut -d '"' -f2)

  hosts+=("${dns}")

  bin/issh cloud-user@${dns} -i ${identity} -tt "echo ${pwd} | sudo passwd demo --stdin" </dev/null &>logs/$dns-1-passwd
  [ $? -ne 0 ] && echo "*** ERROR $? RETURNED FOR ${dns} WHILST SETTING DEMO PASSWORD, bailing ***" && exit 1

  scp -i ${identity} -S bin/issh target/* cloud-user@$dns: &>logs/$dns-2-scp
  [ $? -ne 0 ] && echo "*** ERROR $? RETURNED FOR ${dns} WHILST COPYING SCRIPTS, bailing ***" && exit 1

  bin/issh -i ${identity} -tt cloud-user@$dns sudo 'bash -c "cd /home/cloud-user; ./openshift-aws-reip.sh"' </dev/null &>logs/$dns-3-reip &
done < creds.csv

echo "*** WAITING FOR REIP PROCESSES ***"
wait

for dns in "${hosts[@]}"
do
  bin/issh -i ${identity} -tt cloud-user@$dns sudo 'sed -i -e "/^PermitEmptyPasswords yes/ d" /etc/ssh/sshd_config' &>logs/$dns-4-sshd
  bin/issh -i ${identity} -tt cloud-user@$dns sudo 'sed -i -e "/^PasswordAuthentication no/ d" /etc/ssh/sshd_config' >>logs/$dns-4-sshd 2>&1
  bin/issh -i ${identity} -tt cloud-user@$dns sudo 'systemctl restart sshd.service' >>logs/$dns-4-sshd 2>&1
  bin/issh -i ${identity} -tt cloud-user@$dns sudo 'bash -c "cd /home/cloud-user; ./create-novnc.sh"' &>logs/$dns-5-novnc &
done

echo "*** WAITING FOR NOVNC PROCESSES ***"
wait

for dns in "${hosts[@]}"
do
  bin/issh -i ${identity} -tt cloud-user@$dns sudo ./warm-openshift.sh &>logs/$dns-6-warmup &
done

echo "*** WAITING FOR WARMUP PROCESSES ***"
wait

for dns in "${hosts[@]}"
do
  bin/issh -i ${identity} -tt cloud-user@$dns nohup sudo ./warm-ebs.sh &>logs/$dns-7-ebs
done
{'fraction_non_alphanumeric': 0.2179321067634102, 'fraction_numerical': 0.012956724540036279, 'mean_word_length': 3.541176470588235, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 29, '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': '5853393', 'n_tokens_mistral': 1731, 'n_tokens_neox': 1625, 'n_words': 425}