Skip to content

Instantly share code, notes, and snippets.

@Peleke
Last active June 17, 2020 18:31
Show Gist options
  • Save Peleke/479929a3d2e3a21ebdca56c228f18ddd to your computer and use it in GitHub Desktop.
Save Peleke/479929a3d2e3a21ebdca56c228f18ddd to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Variables
LAB_ENV_DIR="$HOME/Documents/LabEnvironments"
SCAVENGER_DIR="$LAB_ENV_DIR/linux-scavenger"
VAGRANTFILE_URL="http://tinyurl.com/ycyul3wt"
# Create Environment & Download Vagrantfile
echo "Creating $SCAVENGIR_DIR and downloading Vagrantfile..."
mkdir -p "$SCAVENGER_DIR" && cd "$_"
curl -s -L -o Vagrantfile "$VAGRANTFILE_URL"
# Lift Machine and Install Reprovisioner
vagrant up
# Tell Students how to Connect
SSH_USERNAME="student"
SSH_HOST="192.168.0.105" # $(vagrant ssh-config | grep -i 'hostname' | awk '{print $2}' | sed 's/\s*//g')
PORT="22" # "$(vagrant ssh-config | grep -i 'port' | awk '{print $2}' | sed 's/\s*//g')"
echo "Your Scavenger Hunt environment has been installed to $(pwd)!"
echo -e "\nConnect via SSH by running: ssh $SSH_USERNAME@$SSH_HOST -p $PORT\n"
@farmetha
Copy link

farmetha commented May 9, 2020

On line 10
mkdir -p $SCAVENGER_DIR && cd $_

If they have a space in their username it will fail when it expands the variables and think you are passing another argument. Fix this by quoting the arguments, i.e.:

mkdir -p "$SCAVENGER_DIR" && cd "$_"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment