stspringer

script to copy working samba conf files

Jul 4th, 2016
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. #!/bin/bash
  2. # check if lock_file directory exists if it doesn't create it
  3. ./create_directory.sh
  4. # create name for lock file
  5. #
  6. lockDir="/root/lock_files"
  7. # this is the actual lock file
  8. lockFilePath="$lockDir/file.lock"
  9. #
  10. #
  11. #
  12. # Loop through servers until file is no longer exists
  13. #
  14. while [ -e "$lockFilePath" ]
  15. do
  16. exit
  17. done
  18. #----begin sample template for future jobs
  19. # create a new lock file for next job
  20. # touch $lockFilePath
  21. # ./new_job
  22. # echo "copying new job file"
  23. # dont forget to remove the lock
  24. # sleep 5
  25. # rm -f $lockFilePath
  26. #----end sample template for future jobs
  27. #
  28. # create new lock file for a new job
  29. #
  30. touch $lockFilePath
  31. #
  32. # loop through servers and sync docroots and code
  33. #
  34. #-----.conf and .conf.orig files
  35. # do the first rsync job
  36. ./copy_samba_etc_folder_files.sh
  37. echo "copying all .conf and conf.orig files"
  38. # sleep in X seconds
  39. sleep 5
  40. # Remove lock file........
  41. #
  42. rm -f $lockFilePath
  43. #-----sysconfig files
  44. # create a new lock file for next job
  45. touch $lockFilePath
  46. ./copy_samba_etc_sysconfig_folder_files.sh
  47. echo "copying all sysconfig files"
  48. #dont forget to remove the lock
  49. sleep 5
  50. rm -f $lockFilePath
  51. #------samba4 file to start samba4 on reboot
  52. # create a new lock file for next job
  53. touch $lockFilePath
  54. ./copy_samba_etc_rc.d_init.d_samba4_file.sh
  55. echo "copying samba4 file"
  56. #dont forget to remove the lock
  57. sleep 5
  58. rm -f $lockFilePath
  59. #------ifcfg-eth0 file
  60. # create a new lock file for next job
  61. touch $lockFilePath
  62. ./copy_ifcfg_eth0_file.sh
  63. echo "copying ifcfg-eth0 file"
  64. #dont forget to remove the lock
  65. sleep 5
  66. rm -f $lockFilePath
  67. #-----path.sh file
  68. # create a new lock file for next job
  69. touch $lockFilePath
  70. ./copy_profile.d.sh
  71. echo "copying path.sh file"
  72. # dont forget to remove the lock
  73. sleep 5
  74. rm -f $lockFilePath
  75. #-----smb.conf file
  76. # create a new lock file for next job
  77. touch $lockFilePath
  78. ./copy_usr_local_samba_etc_samba_conf.sh
  79. echo "copying smb.conf file"
  80. # dont forget to remove the lock
  81. sleep 5
  82. rm -f $lockFilePath
  83. #----
  84. echo "Done"
  85.  
  86.  
  87. ====================================
  88. create_directory.sh
  89. ====================================
  90. #!/bin/bash
  91. DIRECTORY="/root/lock_files"
  92. if [ -d "$DIRECTORY" ]; then
  93. # Control will enter here if $DIRECTORY exists.
  94. #echo "directory exists do something"
  95. fi
  96. #Or to check if a directory doesn't exist:
  97. if [ ! -d "$DIRECTORY" ]; then
  98. # Control will enter here if $DIRECTORY doesn't exist.
  99. #echo "directory does not exist do something"
  100. mkdir /root/lock_files
  101. fi
Advertisement
Add Comment
Please, Sign In to add comment