Guest User

Untitled

a guest
Jun 28th, 2018
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3.  
  4. echo "This script will check the following websites for changes"
  5. echo "1. APAC"
  6. echo "2. AMERICAS"
  7. echo "3. EMEA"
  8. #read -p "Press enter to continue"
  9.  
  10. echo -ne '##### (33%)r'
  11. sleep 1
  12.  
  13.  
  14. URL1="https://support.symantec.com/en_US/article.TECH244698.html" #APAC
  15. URL2="https://support.symantec.com/en_US/article.TECH243000.html" #AMERICAS
  16. URL3="https://support.symantec.com/en_US/article.TECH244697.html" #EMEA
  17.  
  18. DATE=$(date +"%Y%m%d") #defines the date which is used in the logfile name
  19. YESTERDAY=$(date --date="yesterday" +"%Y%m%d")
  20.  
  21.  
  22. SAI1=$(diff -U4 logfiles/APAC_$YESTERDAY.log logfiles/APAC_$DATE.log) #DIFF COMMANDS
  23. SAI2=$(diff -U4 logfiles/AMERICAS_$YESTERDAY.log logfiles/AMERICAS_$DATE.log)
  24. SAI3=$(diff -U4 logfiles/EMEA_$YESTERDAY.log logfiles/EMEA_$DATE.log)
  25.  
  26. #This processes the 3 URLs from above, awk extracts the tables and creates a simplified html file with only the ip tables.
  27. #XSLT processor produces the output and sed will remove lines that are not required
  28.  
  29. export https_proxy=https://XXXXXXX:XXXXXX@111.111.111.111:0000 #All connections hereafter use this proxy until line 'unset HTTPS_PROXY' is reached
  30. #Proxy is set as: https://LDAP:PW@IPorHOSTNAME:PORT
  31.  
  32. #GET IP LIST AND HTML FILES
  33. curl --silent "$URL1" |
  34. awk 'BEGIN{print "<html><body>"}/<table/{a=1;}/</table>/{print;a=0}{if(a)print;}END{print "</body></html>"}' |
  35. xsltproc -html generate_ips.xslt - | sed '/^Egress/{d};s/^ *//' > logfiles/APAC_$DATE.log
  36.  
  37. curl --silent "$URL1" > logfiles/HTML_APAC_$DATE.log #Gets URL1 (APAC) as HTML file and saves it to specified filename
  38.  
  39. curl --silent "$URL2" |
  40. awk 'BEGIN{print "<html><body>"}/<table/{a=1;}/</table>/{print;a=0}{if(a)print;}END{print "</body></html>"}' |
  41. xsltproc -html generate_ips.xslt - | sed '/^Egress/{d};s/^ *//' > logfiles/AMERICAS_$DATE.log
  42.  
  43. curl --silent "$URL2" > logfiles/HTML_AMERICAS_$DATE.log #Gets URL2 (AMERICAS) as HTML file and saves it to specified filename
  44.  
  45. echo -ne '############# (66%)r'
  46. sleep 1
  47.  
  48. curl --silent "$URL3" |
  49. awk 'BEGIN{print "<html><body>"}/<table/{a=1;}/</table>/{print;a=0}{if(a)print;}END{print "</body></html>"}' |
  50. xsltproc -html generate_ips.xslt - | sed '/^Egress/{d};s/^ *//' > logfiles/EMEA_$DATE.log
  51.  
  52. curl --silent "$URL3" > logfiles/HTML_EMEA_$DATE.log #Gets URL3 (EMEA) as HTML file and saves it to specified filename
  53.  
  54.  
  55. sleep 1 #Wait for 1sec
  56.  
  57. #DIFF and WRITE OUT TO FILE
  58. if [[ $SAI1 -eq 0 ]]
  59. then
  60. echo $"APAC IP List: No Change detected" | tee logfiles/APAC_diffresult_$DATE
  61. else
  62. echo -n "$SAI1" | tee logfiles/APAC_diffresult_$DATE
  63. fi
  64.  
  65. if [[ $SAI2 -eq 0 ]]
  66. then
  67. echo $"AMERICAS IP LIST: No Change detected" | tee logfiles/AMERICAS_diffresult_$DATE
  68. else
  69. echo -n "$SAI2" | tee logfiles/AMERICAS_diffresult_$DATE
  70. fi
  71.  
  72. if [[ $SAI3 -eq 0 ]]
  73. then
  74. echo $"EMEA IP LIST: No Change detected" | tee logfiles/EMEA_diffresult_$DATE
  75. else
  76. echo -n "$SAI3" | tee logfiles/EMEA_diffresult_$DATE
  77. fi
  78.  
  79. sleep 1 #Wait for 1 sec
  80.  
  81. #Mail Notification
  82. cat logfiles/APAC_diffresult_$DATE | mail -s "APAC IP LIST UPDATE" user@mail.com
  83. cat logfiles/AMERICAS_diffresult_$DATE | mail -s "AMERICAS IP LIST UPDATE" user@mail.com
  84. cat logfiles/EMEA_diffresult_$DATE | mail -s "EMEA IP LIST UPDATE" user@mail.com
  85.  
  86. sleep 1
  87.  
  88. unset HTTPS_PROXY #Disables proxy
  89.  
  90. sleep 1
  91.  
  92. echo -ne '####################### (100%)r'
  93. echo -ne 'n'
  94.  
  95. sleep 1
  96.  
  97. exit 0; #Finish
Add Comment
Please, Sign In to add comment