SHARE
TWEET

Untitled

a guest Oct 22nd, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. EXAM_PATH=$1
  4. EXAM_FILE=$2
  5. NEW_EXAM_PATH=${EXAMS_PATH}_new
  6. DB_NAME=gsd_dev
  7. DB_USERNAME=gsd
  8. DB_HOST=localhost.localdomain
  9.  
  10. if [[ "$EXAM_FILE" == *"visible"* ]]; then
  11.  
  12.     export LD_LIBRARY_PATH="/opt/gsd/lib/"
  13.     # Extract the device serial number
  14.     DEVICE_SERIAL_NUM=imdm -g EXAM_FILE CV_cameraFingerPrint deviceSnl
  15.     #Convert the serial number in hex format
  16.     DEVICE_SERIAL_NUM_HEX=echo "obase=16; ${DEVICE_SERIAL_NUM}" | bc
  17.     #Extract the device type number
  18.     DEVICE_ACQUISITION_TYPE=echo ${"$DEVICE_SERIAL_NUM_HEX":0:1}
  19.     if [["$DEVICE_ACQUISITION_TYPE" -eq 2 ]]; then #It's a visible image acquired with a neuro device
  20.         cp -rnl ${EXAM_PATH} ${NEW_EXAM_PATH} # create hard links to the exam folders
  21.  
  22.         # Extract the image id
  23.         IMAGE_ID=echo ${"$EXAM_FILE":6:36}
  24.  
  25.         FILE_RENAMED=$(echo "${EXAM_FILE}" | sed s/visible/neu_t/g)
  26.  
  27.         # Rename the file changing visible with neu_t
  28.         mv "${EXAM_FILE}" "${FILE_RENAMED}"
  29.  
  30.         psql -v "ON_ERROR_STOP=1" -d ${DB_NAME} -U ${DB_USERNAME} -h ${DB_HOST} -tAc " BEGIN; UPDATE images SET image_type='neu_t' WHERE image_type='visible' AND id=${IMAGE_ID}; UPDATE images SET image_type='raw_neu_t' WHERE image_type='raw_visible' AND id=${IMAGE_ID}; COMMIT;"
  31.         RESULT="$?"
  32.  
  33.         if [ "$RESULT" -eq 0 ]; then
  34.             rm -rf ${EXAM_PATH}
  35.             mv ${NEW_EXAM_PATH} ${EXAM_PATH} # rename the exam folder
  36.         fi
  37.     fi
  38. fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top