417 # Northshore
);
+# Hard-code the districts eligible for automatic teacher account processing.
+TEACHER_DISTRICTS=(
+ 408 # Auburn
+ 415 # Kent
+)
+
function usage {
cat <<USAGE
$0 -d 415 -l
Options:
-
+
-s SFTP Server Hostname
-u SFTP User
-l List Pending Files
-p Process selected files
-
+
-f Fetch pending files
-b Database server
for FILE in $($SSH "$COMMAND -l"); do
LOCAL_FILE=$(basename $FILE)
+ TEACHER_FLAG=""
- announce "Retrieving file $FILE"
- $SCP:$FILE $LOCAL_FILE
+ announce "Inspecting file $FILE"
- TEACHER_FLAG=""
- if [[ $LOCAL_FILE =~ 'teacher' ]]; then
- announce "Processing a teacher file"
- TEACHER_FLAG="--teacher"
+ # File format examples:
+ # 415.2016-03-18.csv
+ # 415.teacher.2016-03-18.csv
+ if [[ $LOCAL_FILE =~ ^[0-9]{3}.[0-9]{4}-[0-9]{2}-[0-9]{2}.csv$ ]]; then
+ announce "Found a student file."
+ else
+ if [[ $LOCAL_FILE =~ ^[0-9]{3}.teacher.[0-9]{4}-[0-9]{2}-[0-9]{2}.csv$ ]]; then
+ announce "Found a teacher file."
+
+ if [[ " ${TEACHER_DISTRICTS[@]} " =~ " $code " ]]; then
+ announce "Processing a teacher file"
+ TEACHER_FLAG="--teacher"
+ else
+ announce "District $code not configured for teacher file processing. Skipping."
+ continue;
+ fi
+ else
+ announce "File has invalid name. Skipping"
+ continue;
+ fi
fi
+ announce "Retrieving file $FILE"
+ $SCP:$FILE $LOCAL_FILE
+
announce "Processing file $LOCAL_FILE"
INFO=$(perl ./generate-patrons-from-csv.pl \
--log-stdout $TEACHER_FLAG \