#!/bin/bash

# Set environment and declare global variables
. /usr/local/lib/labtool.shlib
trap on_exit EXIT

# Check to make sure we are running on the correct host
check_host "server"

# Check to see if we can log in to desktopX w/ a key pair
function ssh_key_one_way {
    su -c "ssh -o PreferredAuthentications=publickey student@desktop${GLS_ENROLLMENT} sleep 1" student
}

# Check the contents of the /tmp/student.tar.bz2 file
function verify_tarball {
    local TARBALL=/tmp/student.tar.bz2
    local TESTDIR=${0}.$$
    local RESTORED=
    if [ -r "${TARBALL}" ] ; then
	mkdir /tmp/${TESTDIR}/tarball
	su -c "ssh desktop${GLS_ENROLLMENT} find . \! -type d -exec sha256sum {} \:" > /tmp/${TESTDIR}/SHA256SUM
	pushd /tmp/${TESTDIR}/tarball &>/dev/null
	
	su -c student "tar xf ${TARBALL}"
	popd

    else
	echo "${TARBALL} does not exist."
    fi
}

# Check the copy of /tmp/student.tar.bz2 on desktopX
function verify_copy {
	:    
}

cat <<EOF

This grading script is not implemented at this time.

The criterion test has been successfully completed when
  1. /tmp/student.tar.bz2 exists on serverX as is the same as the
     original on desktopX,
  2. student's original SSH keys are deployed on serverX, and
  3. student can ssh from serverX to desktopX without using a password.

EOF
