<commit_before>#!/usr/bin/env bash
set -e

#Check usage
if [ $# -ne 2]; then
  echo "ERROR: This script requires a path and user:password file as parameters."
  echo "USAGE: ./$0 /home/faculty faculty.usrpasswd"
  exit
fi

#Check the input path is valid
path=$1
if [ -d "$path" ];
  echo "WARN: Path $path does not exist. Continuing will create it."
  read -p "Press [Enter] key to continue or Ctrl+C to cancel..."
  mkdir -p "$path"
fi

#Check the input file is valid
if [ -f $2 ];
then
  usrpasswdfile=$2
else
  echo "ERROR: $2 is not valid"
  exit
fi

while IFS=: read -r user pass;
do
  #Ensure users exist and passwords match file
  if id -u $user >/dev/null 2>&1; then
    echo "User $user already exists. Continuing will update password."
    read -p "Press [Enter] key to continue or Ctrl+C to cancel..."
    echo "$user:$pass" | chpasswd 
  else
    #Create users in $path
    useradd --base-dir $path --create-home \
            --shell /bin/bash --password $(openssl passwd $pass) $user  
  fi
done < "$usrpasswdfile"<commit_msg>Fixed add-users script to use usrpasswd format<commit_after>#!/usr/bin/env bash
set -e

#Check usage
if [ $# -ne 1]; then
  echo "ERROR: This script requires a user:password file."
  echo "USAGE: ./$0 student.usrpasswd"
  exit
fi
#Check the input file is valid
if [ -f $1 ];
then
  usrpasswdfile=$1
else
  echo "ERROR: $1 is not valid"
  exit
fi

while IFS=: read -r pw_name pw_passwd pw_uid pw_gid pw_gecos pw_dir pw_shell;
do
  #Ensure users exist and passwords match file
  if id -u $pw_name >/dev/null 2>&1; then
    echo "User $user already exists. Continuing will update password."
    read -p "Press [Enter] key to continue or Ctrl+C to cancel..."
    echo "$pw_name:$pw_passwd" | chpasswd 
  else
    #Create users in $path
    useradd --home $pw_dir --create-home --skel /etc/skel \
            --shell $pw_shell --password $(openssl passwd $pass) $user  
    fullname=$(echo "$pw_gecos" | sed s/,//g)
    chfn -f "$fullname" $pw_name
  fi
done < "$usrpasswdfile"
{'fraction_non_alphanumeric': 0.12276341948310139, 'fraction_numerical': 0.007455268389662028, 'mean_word_length': 2.994047619047619, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '1025354', 'n_tokens_mistral': 725, 'n_tokens_neox': 702, 'n_words': 275}