Advertisement
mikeisfly

astcron.sh

Jun 12th, 2014
532
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 1 0
  1. #!/bin/bash
  2.  
  3. # This file should go in /var/lib/asterisk/agi-bin
  4. # make sure you change your permissions of astcron.sh to 775
  5. #Change to hold directory
  6. #
  7. cd /var/spool/asterisk/hold
  8.  
  9. #
  10. # Check through all queued files in sort order (so we always get the oldest first)
  11. #
  12. for filename in `ls -v *.call`; do
  13.  
  14.  
  15. destexten=`echo $filename | cut -d - -f1 `
  16.  
  17. echo "Checking extension" $destexten "for file" $filename "for existing messages"
  18.  
  19. ifexist=`ls /var/spool/asterisk/outgoing/*.call | grep -c $destexten`
  20.  
  21. #
  22. # if extension doesnt exist then queued message has been delivered
  23. # so we can move the waiting message now
  24. #
  25.  
  26. if [[ "$ifexist" == "0" ]]; then
  27. echo "No existing message for " $destexten
  28.  
  29. #
  30. # move file to outgoing folder
  31. #
  32. echo "Moving filename" $filename "to outgoing"
  33.  
  34. mv /var/spool/asterisk/hold/$filename /var/spool/asterisk/outgoing/
  35.  
  36. #
  37. # If we actually do a move then delay just in case
  38. # there is more than one waiting message for that extension
  39. #
  40. sleep 3
  41. fi
  42. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement