Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # call our PHP script to update photo file locations
- date >> /var/www/scripts-logs/student-photo-import.log 2>&1
- echo "Calling user-picture-locations.php script now!" >> /var/www/scripts-logs/student-photo-import.log 2>&1
- echo "-----------------------------------------------" >> /var/www/scripts-logs/student-photo-import.log 2>&1
- php user-picture-locations.php >> /var/www/scripts-logs/student-photo-import.log 2>&1
- # remove all jpg files from import directory and cd into it
- rm ./photoimports/*.jpg;
- cd ./photoimports;
- # Save our old delimter and set it to a comma
- OIFS=$IFS;
- IFS=",";
- # define our input file
- csvfile="../user-picture-locations.csv";
- date >> /var/www/scripts-logs/student-photo-import.log 2>&1
- echo "Connecting via smbclient" >> /var/www/scripts-logs/student-photo-import.log 2>&1
- # load our input file a run through a line at a time
- cat $csvfile | while read line; do
- # load each line into an array
- locationsArray=($line);
- # fetech our files with smbclient
- smbclient //iSAMS-IIS-Server/e$ -U AD-User-With-Read-Access-to-Share%ReallyLongComplexPasswordWithoutAnySpecialCharactersInIt -W YourDomainName -c "${locationsArray[0]}" >> /var/www/scripts-logs/student-photo-import.log 2>&1
- # rename our files to match Moodle usernames
- echo "Renaming ${locationsArray[1]} to ${locationsArray[2]}" >> /var/www/scripts-logs/student-photo-import.log 2>&1
- mv ${locationsArray[1]} ${locationsArray[2]} >> /var/www/scripts-logs/student-photo-import.log 2>&1
- done
- echo "Done copying and renaming files" >> /var/www/scripts-logs/student-photo-import.log 2>&1
- echo "-----------------------------------------------" >> /var/www/scripts-logs/student-photo-import.log 2>&1
- cd ../;
- # call our PHP script to update photos in Moodle
- date >> /var/www/scripts-logs/student-photo-import.log 2>&1
- echo "Calling updatepics.php script now!" >> /var/www/scripts-logs/student-photo-import.log 2>&1
- echo "-----------------------------------------------" >> /var/www/scripts-logs/student-photo-import.log 2>&1
- php updatepics.php --dir=./photoimports >> /var/www/scripts-logs/student-photo-import.log 2>&1
- # set IFS back...
- IFS=$OIFS;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement