JBAS-1998 Sftp client process selected district code
authorBill Erickson <berickxx@gmail.com>
Wed, 9 May 2018 15:18:43 +0000 (11:18 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Fixes a bug where selecting a specific district code using -d would
process the selected code plus all college codes.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/utility-scripts/import_students/sftp-client-agent.sh

index f5930d9..04d6497 100755 (executable)
@@ -49,6 +49,9 @@ COLLEGE_CODES=(
     "lwt" # Lake Washington Institute of Technology
 );
 
+# Which codes to process in this iteration of the script.
+CODES_TO_PROCESS=();
+
 # Hard-code the districts eligible for automatic teacher account processing.
 # College teacher accounts are processed the same as school teacher accounts.
 TEACHER_DISTRICTS=(
@@ -150,7 +153,9 @@ SERVER_AGENT="/home/$USER/sftp-server-agent.sh"
 
 # only process the requested district if specified
 if [ -n "$DISTRICT_CODE" ]; then 
-    DISTRICT_CODES=($DISTRICT_CODE);
+    CODES_TO_PROCESS=($DISTRICT_CODE);
+else
+    CODES_TO_PROCESS=("${DISTRICT_CODES[@]}" "${COLLEGE_CODES[@]}");
 fi;
 
 announce "Connecting to server $SERVER"
@@ -158,7 +163,7 @@ if [ -n "$PROCESS_FILES" ]; then
     announce "Processing files on DB $DB_HOST"
 fi
 
-for code in "${DISTRICT_CODES[@]}" "${COLLEGE_CODES[@]}"; do
+for code in "${CODES_TO_PROCESS[@]}"; do
     COMMAND="$SERVER_AGENT -d $code"; 
     COMPLETE_DIR="/home/sftp$code/complete"