Advertisement
Giftednarwhals

final stuff

May 6th, 2015
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. #!/bin/bash
  2. #Script for testing changes in system directory
  3. =============================================================================================
  4. crontab function : (performs the script every 30 mins) 00,30 * * * * Script path
  5. ---------------------------------------------------------------------------------------------
  6. #Part A : Create a script to detect and log changes to /etc/passwd
  7. # Part 1 - The number of users in the system may increase or decrease.
  8. # Part 2 - One or more characters in the file may change.
  9. ---------------------------------------------------------------------------------------------
  10. Part 1 ~ The number of users may change
  11. ---------------------------------------------------------------------------------------------
  12. 1. ) CREATED A copy , "compare" , of /etc/passwd to compare with
  13. ~ located at /home/kwblanchard/bin/logs/compare
  14.  
  15. 2. ) Compares the wc-l of the two files
  16. ~ diff <(wc-l < /etc/passwd) <(wc-l < /home/kwblanchard/bin/logs/compare)
  17.  
  18. - diff -y --suppress-common-lines /etc/passwd /home/kwblanchard/bin/logs/compare | grep '^' ??? | wc -l
  19.  
  20. 3. ) Create an if statement
  21. ~ How to create if statements?
  22. - If there is no difference, echo "There is no difference between the two files"
  23. - If there is a difference , echo " There is a difference between the two files"
  24. - show the results of the diff command
  25. - create a log file of the difference
  26.  
  27. 4. ) Put at end of script to rewrite the "compare" file with the up to date version of /etc/passwd
  28. ~ cp -r /etc/passwd /home/kwblanchard/bin/logs/compare
  29.  
  30. ---------------------------------------------------------------------------------------------
  31. Part 2 ~ One or more characters in the file may change
  32. ---------------------------------------------------------------------------------------------
  33. 1. ) CREATED A copy , "compare" , of /etc/passwd to compare with
  34. ~ located at /home/kwblanchard/bin/logs/compare
  35.  
  36. 2. ) Log the date and time then the word count of the file.
  37. ~ wc -w < etc/passwd
  38. - how to write this to a file?
  39. TIME: echo %time% > logfile.txt
  40. DATE: echo %date% > logfile.txt
  41.  
  42. 3. ) Log the date and time then the MD5 sum of the file.
  43. ~ Stated above for date and time
  44. ~ sha1sum /etc/passwd > logfile.txt
  45. 4. ) Save the date and time then the entire password file.
  46. ~ cp -r /etc/passwd /home/kwblanchard/bin/logs/compare
  47. ---------------------------------------------------------------------------------------------
  48. =============================================================================================
  49. ---------------------------------------------------------------------------------------------
  50. #Part B : Detect the changes to the volume size of /home2
  51. # - Minimum change in size will be 100MB. Smaller changes can be ignored.
  52. ---------------------------------------------------------------------------------------------
  53.  
  54. 1. ) Create a copy , "Comparable", of the /home2 directory to compare to
  55. 2. ) Compare each file in the current /home2 directory to the back up
  56. - use an if statement that uses each files size as its true / false parameter. ( over 100mb = true)
  57. - create another comparable file of the total size of the directory to see if there are any changes at all.
  58. use as first if statement and if true continue onto the individual changes.
  59.  
  60. ---------------------------------------------------------------------------------------------
  61. =============================================================================================
  62. ---------------------------------------------------------------------------------------------
  63. #Part C : Detect changes to the startup files
  64. # - A new file may be added to the directory
  65. # - Something may make a change in an existing file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement