summaryrefslogtreecommitdiff
path: root/cfengine/cf.services.file
blob: 3c15e8d9c266bb32b40dafe27f774c78934096cc (plain)
  1. control:
  2.     AddInstallable = ( samba samba_reload netatalk netatalk_reload lprng lprng_reload cups cups_reload )
  3. classes:
  4. #
  5. # Determine if this is a samba server, netatalk server or both, and define
  6. # classes based on that.
  7. #
  8. samba = ( `/usr/bin/test -x /usr/sbin/smbd` )
  9. netatalk = ( `/usr/bin/test -x /usr/sbin/afpd` )
  10. #
  11. # Determine which print system is in use, and define classes based on that.
  12. # We only support lprng and cups
  13. #
  14. lprng = ( `/usr/bin/test -x /usr/sbin/lpd` )
  15. cups = ( `/usr/bin/test -x /usr/sbin/cupsd` )
  16. import:
  17. samba::
  18. #
  19. # Import the shares definition for this site. This is a cfengine file!
  20. #
  21. /etc/local-COMMON/samba/smb-shares-$(site).conf
  22. lprng|cups::
  23. #
  24. # Set up a printershare only if there's some printersoftware installed
  25. #
  26. /etc/local-COMMON/samba/smb-printers.conf
  27. editfiles:
  28. samba.lprng::
  29. { /etc/samba/smb.conf
  30. AppendIfNoSuchLine "include = /etc/samba/smb-printers-lprng.conf"
  31. }
  32. samba.cups::
  33. { /etc/samba/smb.conf
  34. AppendIfNoSuchLine "include = /etc/samba/smb-printers-cups.conf"
  35. }
  36. samba::
  37. { /etc/samba/smb.conf
  38. #
  39. # Global stuff
  40. #
  41. # Remove share declarations from main smb.conf. It is split
  42. # up in the following files:
  43. # - smb.conf
  44. # - smb-shares-$(site).conf
  45. #
  46. # DeleteLinesAfterThisMatching "^\[homes\]$(n)*.*"
  47. # ResetSearch "1"
  48. # CatchAbort
  49. # ResetSearch "1"
  50. #
  51. # Append the include lines for the files decribed above
  52. #
  53. BeginGroupIfFileExists "/etc/local-COMMON/samba/smb-shares-$(site).conf"
  54. AppendIfNoSuchLine "include = /etc/samba/smb-shares-$(site).conf"
  55. EndGroup
  56. ResetSearch "1"
  57. #
  58. # workgroup = $(site)
  59. #
  60. LocateLineMatching "^[;[:blank:]]*workgroup[[:blank:]]*=.*"
  61. BeginGroupIfNoLineMatching '^[[:blank:]]*workgroup[[:blank:]]*=[[:blank:]]*$(site)[[:blank:]]*'
  62. ReplaceLineWith ' workgroup = $(site)'
  63. EndGroup
  64. CatchAbort
  65. BeginGroupIfNoMatch '^[[:blank:]]*workgroup[[:blank:]]*=[[:blank:]]*$(site)[[:blank:]]*'
  66. InsertLine ' workgroup = $(site)'
  67. EndGroup
  68. #
  69. # wins support = yes
  70. #
  71. LocateLineMatching "^[;[:blank:]]*wins support[[:blank:]]*=.*"
  72. BeginGroupIfNoLineMatching "^[[:blank:]]*wins support[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  73. ReplaceLineWith ' wins support = yes'
  74. EndGroup
  75. CatchAbort
  76. BeginGroupIfNoMatch "^[[:blank:]]*wins support[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  77. InsertLine ' wins support = yes'
  78. EndGroup
  79. #
  80. # os level = 65
  81. #
  82. LocateLineMatching "^[;[:blank:]]*os level[[:blank:]]*=.*"
  83. BeginGroupIfNoLineMatching "^[[:blank:]]*os level[[:blank:]]*=[[:blank:]]*65[[:blank:]]*"
  84. ReplaceLineWith ' os level = 65'
  85. EndGroup
  86. CatchAbort
  87. BeginGroupIfNoMatch "^[[:blank:]]*os level[[:blank:]]*=[[:blank:]]*65[[:blank:]]*"
  88. InsertLine ' os level = 65'
  89. EndGroup
  90. #
  91. # domain master = yes
  92. #
  93. LocateLineMatching "^[;[:blank:]]*domain master[[:blank:]]*=.*"
  94. BeginGroupIfNoLineMatching "^[[:blank:]]*domain master[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  95. ReplaceLineWith ' domain master = yes'
  96. EndGroup
  97. CatchAbort
  98. BeginGroupIfNoMatch "^[[:blank:]]*domain master[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  99. InsertLine ' domain master = yes'
  100. EndGroup
  101. #
  102. # local master = yes
  103. #
  104. LocateLineMatching "^[;[:blank:]]*local master[[:blank:]]*=.*"
  105. BeginGroupIfNoLineMatching "^[[:blank:]]*local master[[:blank:]]*=[[:blank:]]*yes"
  106. ReplaceLineWith ' local master = yes'
  107. EndGroup
  108. CatchAbort
  109. BeginGroupIfNoMatch "^[[:blank:]]*local master[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  110. InsertLine ' local master = yes'
  111. EndGroup
  112. #
  113. # logon drive = Z:
  114. #
  115. LocateLineMatching "^[;[:blank:]]*logon drive[[:blank:]]*=.*"
  116. BeginGroupIfNoLineMatching "^[[:blank:]]*logon drive[[:blank:]]*=[[:blank:]]*Z:[[:blank:]]*"
  117. ReplaceLineWith ' logon drive = Z:'
  118. EndGroup
  119. CatchAbort
  120. BeginGroupIfNoMatch "^[[:blank:]]*logon drive[[:blank:]]*=[[:blank:]]*Z:[[:blank:]]*"
  121. InsertLine ' logon drive = Z:'
  122. EndGroup
  123. #
  124. # logon script = logon-$(site).bat
  125. #
  126. LocateLineMatching "^[;[:blank:]]*logon script[[:blank:]]*=.*"
  127. BeginGroupIfNoLineMatching "^[[:blank:]]*logon script[[:blank:]]*=[[:blank:]]*logon-$(site).bat[[:blank:]]*"
  128. ReplaceLineWith ' logon script = logon-$(site).bat'
  129. EndGroup
  130. CatchAbort
  131. BeginGroupIfNoMatch "^[[:blank:]]*logon script[[:blank:]]*=[[:blank:]]*logon-$(site).bat[[:blank:]]*"
  132. InsertLine ' logon script = logon-$(site).bat'
  133. EndGroup
  134. #
  135. # domain logons = yes
  136. #
  137. LocateLineMatching "^[;[:blank:]]*domain logons[[:blank:]]*=.*"
  138. BeginGroupIfNoLineMatching "^[[:blank:]]*domain logons[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  139. ReplaceLineWith ' domain logons = yes'
  140. EndGroup
  141. CatchAbort
  142. BeginGroupIfNoMatch "^[[:blank:]]*domain logons[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  143. InsertLine ' domain logons = yes'
  144. EndGroup
  145. #
  146. # logon home = \\%N\USERPROFILES\%U
  147. #
  148. LocateLineMatching "^[;[:blank:]]*logon home[[:blank:]]*=.*"
  149. BeginGroupIfNoLineMatching "^[[:blank:]]*logon home[[:blank:]]*=[[:blank:]]*[\\][\\]%N[\\]USERPROFILES[\\]%U[[:blank:]]*"
  150. ReplaceLineWith ' logon home = \\%N\USERPROFILES\%U'
  151. EndGroup
  152. CatchAbort
  153. BeginGroupIfNoMatch "^[[:blank:]]*logon home[[:blank:]]*=[[:blank:]]*[\\][\\]%N[\\]USERPROFILES[\\]%U[[:blank:]]*"
  154. InsertLine ' logon home = \\%N\USERPROFILES\%U'
  155. EndGroup
  156. #
  157. # preferred master = yes
  158. #
  159. LocateLineMatching "^[;[:blank:]]*preferred master[[:blank:]]*=.*"
  160. BeginGroupIfNoLineMatching "^[[:blank:]]*preferred master[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  161. ReplaceLineWith ' preferred master = yes'
  162. EndGroup
  163. CatchAbort
  164. BeginGroupIfNoMatch "^[[:blank:]]*preferred master[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  165. InsertLine ' preferred master = yes'
  166. EndGroup
  167. #
  168. # character set = ISO8859-1
  169. #
  170. LocateLineMatching "^[;[:blank:]]*character set[[:blank:]]*=.*"
  171. BeginGroupIfNoLineMatching "^[[:blank:]]*character set[[:blank:]]*=[[:blank:]]*ISO8859-1[[:blank:]]*"
  172. ReplaceLineWith ' character set = ISO8859-1'
  173. EndGroup
  174. CatchAbort
  175. BeginGroupIfNoMatch "^[[:blank:]]*character set[[:blank:]]*=[[:blank:]]*ISO8859-1[[:blank:]]*"
  176. InsertLine ' character set = ISO8859-1'
  177. EndGroup
  178. DefineClasses "samba_reload"
  179. }
  180. #
  181. # Batch file for mounting shares automatically
  182. #
  183. { /etc/samba/netlogon/logon-$(site).bat
  184. #
  185. # We don't make this file dynamically, but instead we copy the contents
  186. # of a master file, but only if it's newer than the one installed.
  187. #
  188. BeginGroupIfFileIsNewer "/etc/local-COMMON/samba/netlogon/logon-$(site).bat"
  189. AutoCreate
  190. EmptyEntireFilePlease
  191. InsertFile "/etc/local-COMMON/samba/netlogon/logon-$(site).bat"
  192. Append "rem Edited by cfengine $(date)"
  193. EndGroup
  194. DefineClasses "samba_reload"
  195. }
  196. lprng::
  197. #
  198. # Printer configuration stuff
  199. #
  200. { /etc/printcap
  201. #
  202. # We don't make the printcap dynamically, but instead we copy the contents
  203. # of a master file, but only if it's newer than the one installed.
  204. #
  205. BeginGroupIfFileIsNewer "/etc/local-COMMON/printcap.$(site)"
  206. EmptyEntireFilePlease
  207. InsertFile "/etc/local-COMMON/printcap.$(site)"
  208. Append "# Edited by cfengine $(date)"
  209. EndGroup
  210. DefineClasses "lprng_reload"
  211. }
  212. samba_reload::
  213. { /etc/samba/smb.conf
  214. LocateLineMatching "^; EDITED BY CFENGINE .*"
  215. ReplaceAll '; EDITED BY CFENGINE .*$' With '; EDITED BY CFENGINE $(date)'
  216. CatchAbort
  217. BeginGroupIfNoMatch "^; EDITED BY CFENGINE .*"
  218. Append '; EDITED BY CFENGINE $(date)'
  219. EndGroup
  220. }
  221. processes:
  222. "smbd" restart "/etc/init.d/samba restart"
  223. "afpd" restart "/etc/init.d/netatalk restart"
  224. shellcommands:
  225. samba_reload::
  226. "/etc/init.d/samba force-reload"
  227. netatalk_reload::
  228. "/etc/init.d/netatalk force-reload"
  229. lprng_reload::
  230. "/etc/init.d/lprng force-reload"
  231. cups_reload::
  232. "/etc/init.d/cups force-reload"