Your workflow for SI204

Generally in this class, you will work on our lab machines during lab periods and programming practica, and on your laptop otherwise. In either case you'll be working under the Linux operating system. There are two consequences to this:
  1. we have to embed a Linux operating system in your Windows laptop and configure it with all the programming ammenities that you'll have with our lab machines, and
  2. we have to provide a mechanism for keeping your work on the lab machines synced with your work on your laptop.
The stuff you did for Class 1 homework and the setup we are doing today in class are all about making this happen. So sorry for all the instructions and and work, but it will pay off starting tomorrow and for the rest of the semester and beyond!

1. Open a terminal and run the SI204 setup script

This step just grabs a script (set of instructions) and runs it in order to setup your Linux environment so it has all the tools you need and works in a consistent and friendly way.
  1. Open Windows Terminal (make sure your tab has the penguin icon!)
  2. Copy/paste the following command into the terminal and hit enter to install DoD Certificates:
    		  sudo apt -y install curl 
    		  curl apt.cs.usna.edu/ssl/install-ssl-system.sh | bash
  3. Copy/paste the following command into the terminal and hit enter:
     cmd=$(curl -Lsf https://www.usna.edu/Users/cs/wcbrown/courses/S22SI204/setup/204begin) && eval $cmd
    Note1: in Windows Terminal, right-click to paste!
    Note2: in the middle of all the work resulting from this command, you will be asked
    	  [GitHub] Please confirm your email address: ← enter the e-mail you used when you setup your github account
    	  [GitHub] Please enter your username:  ← enter the username you used when you setup your github account 
    	  [GitHub] Follow the instructions on the si204 website and upload your public key to the github.
    	  Press enter once you have uploaded the key.
    	  ... at this point, open a separate Windows Terminal and do Step 2 below, (i.e. Setup github and Windows WSL ...).
    Note3: Follow all the instructions in the terminal window. There is a bunch of software to install inside Ubuntu, so it will take a while.

Step 2. Setup github and Windows WSL to communicate with one another (using ssh keys)

We want it to be as effortless as possible for you to move back and forth between working on your laptop and working on the CS Department lab machines. To do that, we will use a tool called "git" (a hugely important and ubiquitious tool in the programming world) to synch your work between the two accounts. You should already have an account on github, follow the instructions below to connect your github account and your laptop (or lab) development environment.
[Show instructions]

Step 3. Setting up the submit script

The CS department submit server (https://submit.cs.usna.edu) is a website created by CDR (ret) Jeff Kenney at USNA. We will use it to handle submissions of your programming projects, labs and homeworks, and to run auto-tests so that you can see how well your code is working. However, although you'll check the status of submissions and get feedback on them via the website, you will actually submit them from the command line. We need to set that up!
  1. Login to https://submit.cs.usna.edu using your Naval Academy credentials.
  2. Follow the instructions below to download the submit file:
    1. In the submit server page, in the drop-down menu under your name, choose the "Retrieve Personalized Scripts" option.
    2. On that page, close to the top, there is a big button saying "DOWNLOAD PERSONALIZED SUBMISSION SCRIPT". Click it.
      Note: This will download the file submit. If it's not put in the Downloads directory automatically, move it there.
  3. Open a terminal and execute the following commands:
    mv ~/Downloads/submit ~/bin/submit
    chmod 700 ~/bin/submit
    The commands will move the submit file in ~/bin directory and then change the permission of the file to become executable.

Step 4. Setting up your lab account

Finally, we will set up your CS Department Unix account to work seamlessly with your Windows Laptop WSL environment.
  1. Open Windows Terminal (make sure your tab has the penguin icon!)
  2. Give the following command to "ssh" into your CS Department account:
    ssh lnx1065183govt.academy.usna.edu
    Note: Your instructor will explain what this is about. Listen closely!
  3. Copy/paste the following command into the terminal and hit enter to install DoD Certificates:
    curl apt.cs.usna.edu/ssl/install-ssl-browsers.sh | bash
  4. Copy/paste the following command into the terminal and hit enter:
    cmd=$(curl -Lsf https://www.usna.edu/Users/cs/wcbrown/courses/S22SI204/setup/204begin) && eval $cmd
    Note: in the middle of all the work resulting from this command, you will be asked
    	  [GitHub] Please confirm your email address: ← enter the e-mail you used when you setup your github account
    	  [GitHub] Please enter your username:  ← enter the username you used when you setup your github account 
    	  [GitHub] Follow the instructions on the si204 website and upload your public key to the github.
    	  Press enter once you have uploaded the key.
    	  At this point, open a separate Windows Terminal and give the command:
                  scp /home/$USER/.ssh/id_ed25519* $USER@midn.cs.usna.edu:.ssh/
              ... after which you return to the terminal running "ssh" and hit <enter>
    	  
  5. In a separate Windows Terminal (i.e. not the terminal running "ssh") give the command:
    scp /home/$USER/bin/submit $USER@midn.cs.usna.edu:bin/

A peek at Unix and your working environment

On linux (and the same is true for Windows), you have a username (mXXXXXX), which is your identity, and a location on the filesystem called your home directory, which is the folder in which all of the files and folders you own are stored. Note: in Unix we use the work directory instead of folder. To understand how to organize and use your home directory effectively you need to understand a little bit about the filesystem and how the shell (the generic name for things like the Ubuntu Windows Terminal you've been using) interactis with the filesystem.

In class, your instructor will introduce you to the unix filesystem, the concept of a path (a precise description of a location within the filesystem) and linux commands like:

Your home directory on WSL on your laptop is /home/m<alpha>. The setup process created a directory si204 within your home directory, and all the work for this class should be inside the si204 directory. The setup process also created a directory called si204 in your CS department unix account. And in both accounts, the command 204sync synchronizes the si204 directory with your SI204 github account. This does two things. First of all, it means that if your laptop dies all your work is backed up in your github account. Second, it makes it really easy to keep your SI204 work synched up between your laptop and your CS Department Unix account.