daily pastebin goal
62%
SHARE
TWEET

Untitled

a guest Jan 28th, 2016 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. TEMP_FILE=/tmp/available-updates.log
  4.  
  5. apt-get update
  6.  
  7. sleep 5
  8.  
  9. dpkg --get-selections | xargs apt-cache policy {} | grep -1 Installed | sed -r 's/(:|Installed: |Candidate: )//' | uniq -u | tac | sed '/--/I,+1 d' | tac | sed '$d' | sed -n 1~2p > $TEMP_FILE
  10.  
  11. sleep 5
  12.  
  13. FILE_SIZE=`ls -lha /tmp/available-updates.log | cut -d' ' -f5`
  14.  
  15. if [ $FILE_SIZE -eq 0 ]
  16. then
  17.     rm $TEMP_FILE
  18. else
  19.     cat $TEMP_FILE | /usr/bin/mailx -v \
  20.     -r "FROM_ADDRESS" \
  21.     -s "[ SERVER_NAME ] Server Updates available" \
  22.     -S smtp="SMTP_SERVER:SMTP_PORT" \
  23.     -S smtp-use-starttls \
  24.     -S smtp-auth=login \
  25.     -S smtp-auth-user="SMTP_USER" \
  26.     -S smtp-auth-password="SMTP_PASSWORD" \
  27.     -S ssl-verify=ignore \
  28.     RECIPIENT_ADDRESS
  29.  
  30.     sleep 5
  31.  
  32.     rm $TEMP_FILE
  33. 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
 
Top