Advertisement
Guest User

Untitled

a guest
Jul 20th, 2015
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. #! /bin/sh
  2.  
  3. # ---------------------------------------
  4. # INSTALL AND CONFIGURE SMTP / GMAIL
  5. # ---------------------------------------
  6. # WARNING: YOU WILL BE REQUIRED TO CHANGE
  7. # YOUR GOOGLE ACCOUNT SETTINGS AND
  8. # ENABLE ACCESS FOR LESS SECURE APPS
  9. # ---------------------------------------
  10.  
  11. # Install the necessary packages
  12.  
  13. # sudo apt-get update
  14.  
  15. # sudo apt-get install mailutils ssmtp
  16.  
  17. # Edit the ssmtp configuration file
  18.  
  19. # sudo nano /etc/ssmtp/ssmtp.conf
  20.  
  21. # Change the mailhub to
  22.  
  23. # mailhub=smtp.gmail.com:587
  24.  
  25. # Add the following lines to the end of the file
  26.  
  27. # AuthUser=yourgmailaddress@gmail.com
  28.  
  29. # AuthPass=yourgmailpassword
  30.  
  31. # UseSTARTTLS=YES
  32.  
  33. # Edit the revaliases file
  34.  
  35. # sudo nano /etc/ssmtp/revaliases
  36.  
  37. # Add the following line to the end of the file
  38.  
  39. # root:yourgmailaddress@gmail.com:smtp.gmail.com:587
  40.  
  41. # Test the above configuration with the following command
  42.  
  43. # sudo echo testtext | mail -s testsubject yourgmailaddress@gmail.com
  44.  
  45. # Create an empty text file in your home directory and call it ip.txt
  46.  
  47. # Put this script in your home directory
  48.  
  49. # And make this script executable
  50.  
  51. # chmod u+x ipmailer.sh
  52.  
  53. # Edit the cron table
  54.  
  55. # sudo crontab -e
  56.  
  57. # Add the following line to the end of the file
  58.  
  59. # @reboot /home/pi/ipmailer.sh &>/dev/null
  60.  
  61. # Reboot your Raspberry Pi
  62.  
  63. # sudo shutdown now -r
  64.  
  65. SUBJ="Raspberry Pi IP Address"
  66.  
  67. EMAIL="yourgmailaddress@gmail.com"
  68.  
  69. IP=$(wget -qO- ifconfig.me/ip)
  70.  
  71. WLAN0=$(/sbin/ifconfig wlan0 | grep "inet " | awk -F'[: ]+' '{ print $4 }')
  72.  
  73. # Uncomment the following line to store your internal ethernet address in a variable
  74.  
  75. # ETH0=$(/sbin/ifconfig eth0 | grep "inet " | awk -F'[: ]+' '{ print $4 }')
  76.  
  77. echo "PUBLIC: $IP" > /home/pi/ip.txt
  78.  
  79. echo "WLAN0: $WLAN0" >> /home/pi/ip.txt
  80.  
  81. # Uncomment the following line to append your internal ethernet address to the text file
  82.  
  83. # echo "ETH0: $ETH0" >> /home/pi/ip.txt
  84.  
  85. cat home/pi/ip.txt | mail -s "$SUBJ" $EMAIL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement