summaryrefslogtreecommitdiff
path: root/cfengine/cf.services.file
blob: b2ccab28f6c721543b8b611a1dc643be61b7d9b2 (plain)
  1. control:
  2.     AddInstallable = ( samba samba_reload netatalk netatalk_reload lprng lprng_reload cups cups_reload )
  3. # #
  4. # # Variables for shares
  5. # You can change the paths here and it will be changed both in
  6. # the conf file and in the filesystem - But once it is implemented,
  7. # it is not wise to change it - the data in the shares doesn't get
  8. # moved!
  9. # You can change the rights on the shares in the "directories:"
  10. # section.
  11. #
  12. # netlogshare = ( /etc/samba/netlogon )
  13. # commonsharedir = ( /home/fsadmin/COMMON )
  14. # datashare = ( /home/fsadmin/COMMON/documents )
  15. # softshare = ( /home/fsadmin/COMMON/software )
  16. # profshare = ( /home/fsadmin/COMMON/samba/userprofiles )
  17. printdir = ( /var/spool/lpd/sharedprinter )
  18. # privpcshare = ( .pcshare )
  19. # privmacshare = ( .macshare )
  20. # privxchngshare = ( .xchangeshare )
  21. #
  22. # Administrative user and group
  23. #
  24. # adminuser = ( fsadmin )
  25. # admingrp = ( fsadmin )
  26. #
  27. # Determine if this is a samba server, netatalk server or both, and define
  28. # classes based on that.
  29. #
  30. classes:
  31. samba = ( `/usr/bin/test -x /usr/sbin/smbd` )
  32. netatalk = ( `/usr/bin/test -x /usr/sbin/afpd` )
  33. #
  34. # Determine which print system is in use, and define classes based on that.
  35. # We only support lprng and cups
  36. #
  37. lprng = ( `/usr/bin/test -x /usr/sbin/lpd` )
  38. cups = ( `/usr/bin/test -x /usr/sbin/cupsd` )
  39. import:
  40. samba::
  41. /etc/local-COMMON/samba/smb-shares-$(site).conf
  42. editfiles:
  43. samba::
  44. #
  45. # Samba configuration stuff.
  46. #
  47. { /etc/samba/smb.conf
  48. #
  49. # Global stuff
  50. #
  51. # Remove share declarations from main smb.conf. It is split
  52. # up in the following files:
  53. # - smb.conf
  54. # - smb-shares-COMMON.conf
  55. # - smb-shares-$(site).conf
  56. # - smb-printers.conf
  57. #
  58. # DeleteLinesAfterThisMatching "^\[homes\]$(n)*.*"
  59. # ResetSearch "1"
  60. # CatchAbort
  61. # ResetSearch "1"
  62. #
  63. # Append the include lines for the files decribed above
  64. #
  65. # AppendIfNoSuchLine "include = /etc/samba/smb-shares-COMMON.conf"
  66. AppendIfNoSuchLine "include = /etc/samba/smb-printers.conf"
  67. BeginGroupIfFileExists "/etc/local-COMMON/samba/smb-shares-$(site).conf"
  68. AppendIfNoSuchLine "include = /etc/samba/smb-shares-$(site).conf"
  69. EndGroup
  70. ResetSearch "1"
  71. #
  72. # workgroup = $(site)
  73. #
  74. LocateLineMatching "^[;[:blank:]]*workgroup[[:blank:]]*=.*"
  75. BeginGroupIfNoLineMatching '^[[:blank:]]*workgroup[[:blank:]]*=[[:blank:]]*$(site)[[:blank:]]*'
  76. ReplaceLineWith ' workgroup = $(site)'
  77. EndGroup
  78. CatchAbort
  79. BeginGroupIfNoMatch '^[[:blank:]]*workgroup[[:blank:]]*=[[:blank:]]*$(site)[[:blank:]]*'
  80. InsertLine ' workgroup = $(site)'
  81. EndGroup
  82. #
  83. # wins support = yes
  84. #
  85. LocateLineMatching "^[;[:blank:]]*wins support[[:blank:]]*=.*"
  86. BeginGroupIfNoLineMatching "^[[:blank:]]*wins support[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  87. ReplaceLineWith ' wins support = yes'
  88. EndGroup
  89. CatchAbort
  90. BeginGroupIfNoMatch "^[[:blank:]]*wins support[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  91. InsertLine ' wins support = yes'
  92. EndGroup
  93. #
  94. # os level = 65
  95. #
  96. LocateLineMatching "^[;[:blank:]]*os level[[:blank:]]*=.*"
  97. BeginGroupIfNoLineMatching "^[[:blank:]]*os level[[:blank:]]*=[[:blank:]]*65[[:blank:]]*"
  98. ReplaceLineWith ' os level = 65'
  99. EndGroup
  100. CatchAbort
  101. BeginGroupIfNoMatch "^[[:blank:]]*os level[[:blank:]]*=[[:blank:]]*65[[:blank:]]*"
  102. InsertLine ' os level = 65'
  103. EndGroup
  104. #
  105. # domain master = yes
  106. #
  107. LocateLineMatching "^[;[:blank:]]*domain master[[:blank:]]*=.*"
  108. BeginGroupIfNoLineMatching "^[[:blank:]]*domain master[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  109. ReplaceLineWith ' domain master = yes'
  110. EndGroup
  111. CatchAbort
  112. BeginGroupIfNoMatch "^[[:blank:]]*domain master[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  113. InsertLine ' domain master = yes'
  114. EndGroup
  115. #
  116. # local master = yes
  117. #
  118. LocateLineMatching "^[;[:blank:]]*local master[[:blank:]]*=.*"
  119. BeginGroupIfNoLineMatching "^[[:blank:]]*local master[[:blank:]]*=[[:blank:]]*yes"
  120. ReplaceLineWith ' local master = yes'
  121. EndGroup
  122. CatchAbort
  123. BeginGroupIfNoMatch "^[[:blank:]]*local master[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  124. InsertLine ' local master = yes'
  125. EndGroup
  126. #
  127. # logon drive = U:
  128. #
  129. LocateLineMatching "^[;[:blank:]]*logon drive[[:blank:]]*=.*"
  130. BeginGroupIfNoLineMatching "^[[:blank:]]*logon drive[[:blank:]]*=[[:blank:]]*U:[[:blank:]]*"
  131. ReplaceLineWith ' logon drive = U:'
  132. EndGroup
  133. CatchAbort
  134. BeginGroupIfNoMatch "^[[:blank:]]*logon drive[[:blank:]]*=[[:blank:]]*U:[[:blank:]]*"
  135. InsertLine ' logon drive = U:'
  136. EndGroup
  137. #
  138. # logon script = common.bat
  139. #
  140. LocateLineMatching "^[;[:blank:]]*logon script[[:blank:]]*=.*"
  141. BeginGroupIfNoLineMatching "^[[:blank:]]*logon script[[:blank:]]*=[[:blank:]]*logon-$(site).bat[[:blank:]]*"
  142. ReplaceLineWith ' logon script = logon-$(site).bat'
  143. EndGroup
  144. CatchAbort
  145. BeginGroupIfNoMatch "^[[:blank:]]*logon script[[:blank:]]*=[[:blank:]]*logon-$(site).bat[[:blank:]]*"
  146. InsertLine ' logon script = logon-$(site).bat'
  147. EndGroup
  148. #
  149. # domain logons = yes
  150. #
  151. LocateLineMatching "^[;[:blank:]]*domain logons[[:blank:]]*=.*"
  152. BeginGroupIfNoLineMatching "^[[:blank:]]*domain logons[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  153. ReplaceLineWith ' domain logons = yes'
  154. EndGroup
  155. CatchAbort
  156. BeginGroupIfNoMatch "^[[:blank:]]*domain logons[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  157. InsertLine ' domain logons = yes'
  158. EndGroup
  159. #
  160. # logon path = \\%N\USERPROFILES\%U
  161. #
  162. LocateLineMatching "^[;[:blank:]]*logon path[[:blank:]]*=.*"
  163. BeginGroupIfNoLineMatching "^[[:blank:]]*logon path[[:blank:]]*=[[:blank:]]*[\\][\\]%N[\\]USERPROFILES[\\]%U[[:blank:]]*"
  164. ReplaceLineWith ' logon path = \\%N\USERPROFILES\%U'
  165. EndGroup
  166. CatchAbort
  167. BeginGroupIfNoMatch "^[[:blank:]]*logon path[[:blank:]]*=[[:blank:]]*[\\][\\]%N[\\]USERPROFILES[\\]%U[[:blank:]]*"
  168. InsertLine ' logon path = \\%N\USERPROFILES\%U'
  169. EndGroup
  170. #
  171. # preferred master = yes
  172. #
  173. LocateLineMatching "^[;[:blank:]]*preferred master[[:blank:]]*=.*"
  174. BeginGroupIfNoLineMatching "^[[:blank:]]*preferred master[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  175. ReplaceLineWith ' preferred master = yes'
  176. EndGroup
  177. CatchAbort
  178. BeginGroupIfNoMatch "^[[:blank:]]*preferred master[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  179. InsertLine ' preferred master = yes'
  180. EndGroup
  181. DefineClasses "samba_reload"
  182. }
  183. { /etc/samba/smb-printers.conf
  184. #
  185. # This file contains all the printers defined in the Linux printing
  186. # system. There shouldn't be any need for setting up additional
  187. # printer entries. Manage the printers through the Linux print
  188. # system you have installed - cups or lprng.
  189. # We check if the proper sections are there and add them if they
  190. # isn't. We don't check the file line for line.
  191. #
  192. AutoCreate
  193. #
  194. # [printers]
  195. #
  196. BeginGroupIfNoLineMatching "^\[printers\]"
  197. Append '[printers]'
  198. Append ' comment = %S printer'
  199. Append ' path = $(printdir)'
  200. Append ' print command = /usr/bin/lpr -h %s'
  201. Append ' lprm command = /usr/bin/lprm -P%S %j'
  202. Append ' public = yes'
  203. Append ' printable = yes'
  204. EndGroup
  205. }
  206. #
  207. # Batch file for mounting shares automatically
  208. #
  209. { /etc/samba/netlogon/logon-$(site).bat
  210. #
  211. # We don't make this file dynamically, but instead we copy the contents
  212. # of a master file, but only if it's newer than the one installed.
  213. #
  214. BeginGroupIfFileIsNewer "/etc/local-COMMON/samba/netlogon/logon-$(site).bat"
  215. AutoCreate
  216. EmptyEntireFilePlease
  217. InsertFile "/etc/local-COMMON/samba/netlogon/logon-$(site).bat"
  218. Append "rem Edited by cfengine $(date)"
  219. EndGroup
  220. DefineClasses "samba_reload"
  221. }
  222. lprng::
  223. { /etc/samba/smb.conf
  224. #
  225. # printing = lprng
  226. #
  227. ResetSearch "1"
  228. LocateLineMatching "^[;[:blank:]]*printing[[:blank:]]*=.*"
  229. BeginGroupIfNoLineMatching '^[[:blank:]]*printing[[:blank:]]*=[[:blank:]]*lprng[[:blank:]]*'
  230. ReplaceLineWith ' printing = lprng'
  231. EndGroup
  232. CatchAbort
  233. BeginGroupIfNoMatch '^[[:blank:]]*printing[[:blank:]]*=[[:blank:]]*lprng[[:blank:]]*'
  234. InsertLine ' printing = lprng'
  235. EndGroup
  236. DefineClasses "samba_reload"
  237. }
  238. #
  239. # Printer configuration stuff
  240. #
  241. { /etc/printcap
  242. #
  243. # We don't make the printcap dynamically, but instead we copy the contents
  244. # of a master file, but only if it's newer than the one installed.
  245. #
  246. BeginGroupIfFileIsNewer "/etc/local-COMMON/printcap.$(site)"
  247. EmptyEntireFilePlease
  248. InsertFile "/etc/local-COMMON/printcap.$(site)"
  249. Append "# Edited by cfengine $(date)"
  250. EndGroup
  251. DefineClasses "lprng_reload"
  252. }
  253. samba_reload::
  254. { /etc/samba/smb.conf
  255. LocateLineMatching "^; EDITED BY CFENGINE .*"
  256. ReplaceAll '; EDITED BY CFENGINE .*$' With '; EDITED BY CFENGINE $(date)'
  257. CatchAbort
  258. BeginGroupIfNoMatch "^; EDITED BY CFENGINE .*"
  259. Append '; EDITED BY CFENGINE $(date)'
  260. EndGroup
  261. }
  262. { /etc/samba/smb-shares-COMMON.conf
  263. LocateLineMatching "^; EDITED BY CFENGINE .*"
  264. ReplaceAll '; EDITED BY CFENGINE .*$' With '; EDITED BY CFENGINE $(date)'
  265. CatchAbort
  266. BeginGroupIfNoMatch "^; EDITED BY CFENGINE .*"
  267. Append '; EDITED BY CFENGINE $(date)'
  268. EndGroup
  269. }
  270. { /etc/samba/smb-shares-$(site).conf
  271. LocateLineMatching "^; EDITED BY CFENGINE .*"
  272. ReplaceAll '; EDITED BY CFENGINE .*$' With '; EDITED BY CFENGINE $(date)'
  273. CatchAbort
  274. BeginGroupIfNoMatch "^; EDITED BY CFENGINE .*"
  275. Append '; EDITED BY CFENGINE $(date)'
  276. EndGroup
  277. }
  278. { /etc/samba/smb-printers.conf
  279. LocateLineMatching "^; EDITED BY CFENGINE .*"
  280. ReplaceAll '; EDITED BY CFENGINE .*$' With '; EDITED BY CFENGINE $(date)'
  281. CatchAbort
  282. BeginGroupIfNoMatch "^; EDITED BY CFENGINE .*"
  283. Append '; EDITED BY CFENGINE $(date)'
  284. EndGroup
  285. }
  286. processes:
  287. "smbd" restart "/etc/init.d/samba restart"
  288. "afpd" restart "/etc/init.d/netatalk restart"
  289. shellcommands:
  290. samba_reload::
  291. "/etc/init.d/samba force-reload"
  292. netatalk_reload::
  293. "/etc/init.d/netatalk force-reload"
  294. lprng_reload::
  295. "/etc/init.d/lprng force-reload"
  296. cups_reload::
  297. "/etc/init.d/cups force-reload"