@@ -19,6 +19,7 @@ if [ ! -f "${basepath}/config.json" ]; then
1919 exit 1
2020fi
2121
22+
2223# delete any previous run results
2324# TODO: determine if any caching should occur
2425rm -rf " ${basepath} /logs"
@@ -36,16 +37,55 @@ mkdir -p "${basepath}/provided_code/files"
3637mkdir -p " ${basepath} /other_gradeables"
3738mkdir -p " ${basepath} /users"
3839
39- # the default is r-x and we need PHP to be able to write if edits are made to the provided code
40- chmod g=rwxs " ${basepath} /provided_code/files"
40+ # Run Lichen and exit if an error occurs
41+ {
42+ # ###########################################################################
43+ # Finish setting up Lichen run
44+
45+ # The default is r-x and we need PHP to be able to write if edits are made to the provided code
46+ chmod g=rwxs " ${basepath} /provided_code/files" || exit 1
47+
48+ cd " $( dirname " ${0} " ) " || exit 1
49+
50+ # ###########################################################################
51+ # Do some preprocessing
52+ echo " Beginning Lichen run: $( date +" %Y-%m-%d %H:%M:%S" ) "
53+ ./concatenate_all.py " $basepath " " $datapath " || exit 1
54+
55+ # ###########################################################################
56+ # Move the file somewhere to be processed (eventually this will be a worker machine)
57+
58+ # Tar+zip the file structure and save it to /tmp
59+ cd $basepath || exit 1
60+ archive_name=$( sha1sum " ${basepath} /config.json" | awk ' { print $1 }' ) || exit 1
61+ tar -czf " /tmp/LICHEN_JOB_${archive_name} .tar.gz" " config.json" " other_gradeables" " users" " provided_code" || exit 1
62+ cd " $( dirname " ${0} " ) " || exit 1
63+
64+ # TODO: move the archive to worker machine for processing
65+
66+ # Extract archive
67+ tmp_location=" /tmp/LICHEN_JOB_${archive_name} "
68+ mkdir $tmp_location || exit 1
69+ tar -xzf " /tmp/LICHEN_JOB_${archive_name} .tar.gz" -C " $tmp_location "
70+ rm " /tmp/LICHEN_JOB_${archive_name} .tar.gz" || exit 1
71+
72+ # ###########################################################################
73+ # Run Lichen
74+ ./tokenize_all.py " $tmp_location " || exit 1
75+ ./hash_all.py " $tmp_location " || exit 1
76+ ./compare_hashes.out " $tmp_location " || exit 1
77+
78+ # ###########################################################################
79+ # Zip the results back up and send them back to the course's lichen directory
80+ cd $tmp_location || exit 1
81+ tar -czf " /tmp/LICHEN_JOB_${archive_name} .tar.gz" " ."
82+ rm -rf $tmp_location || exit 1
4183
42- log_file= " ${basepath} /logs/lichen_job_output.txt "
84+ # TODO: Move the archive back from worker machine
4385
44- cd $( dirname " ${0} " )
86+ # Extract archive and restore Lichen file structure
87+ cd $basepath || exit 1
88+ tar --skip-old-files -xzf " /tmp/LICHEN_JOB_${archive_name} .tar.gz" -C " $basepath "
89+ rm " /tmp/LICHEN_JOB_${archive_name} .tar.gz" || exit 1
4590
46- # run all of the modules and exit if an error occurs
47- echo " Beginning Lichen run: $( date +" %Y-%m-%d %H:%M:%S" ) " >> $log_file 2>&1
48- ./concatenate_all.py $basepath $datapath >> $log_file 2>&1 || exit 1
49- ./tokenize_all.py $basepath >> $log_file 2>&1 || exit 1
50- ./hash_all.py $basepath >> $log_file 2>&1 || exit 1
51- ./compare_hashes.out $basepath >> $log_file 2>&1 || exit 1
91+ } >> " ${basepath} /logs/lichen_job_output.txt" 2>&1
0 commit comments