summaryrefslogtreecommitdiff
path: root/cfengine/cf.services.file
blob: ee3bdac9812db74f8d8a02b6a1b2ca65ad440f06 (plain)
  1. control:
  2.     AddInstallable = ( samba_reload netatalk_reload lprng_reload cups_reload lprng cups )
  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 = ( /var/local/filesharing/COMMON )
  14. locsharedir = ( /var/local/filesharing/local )
  15. datashare = ( /var/local/filesharing/COMMON/data )
  16. pgrshare = ( /var/local/filesharing/COMMON/programs )
  17. profshare = ( /var/local/filesharing/COMMON/samba/userprofiles )
  18. printdir = ( /var/spool/samba )
  19. #
  20. # Variables for lprng
  21. #
  22. editfiles:
  23. any::
  24. #
  25. # Samba configuration stuff.
  26. #
  27. { /etc/samba/smb.conf
  28. #
  29. # Global stuff
  30. #
  31. # Remove share declarations from main smb.conf. It is split
  32. # up in the following files:
  33. # - smb.conf
  34. # - smb-shares-COMMON.conf
  35. # - smb-shares-$(site).conf
  36. # - smb-printers.conf
  37. #
  38. # DeleteLinesAfterThisMatching "^\[homes\]$(n)*.*"
  39. # ResetSearch "1"
  40. # CatchAbort
  41. # ResetSearch "1"
  42. #
  43. # Append the include lines for the files decribed above
  44. #
  45. AppendIfNoSuchLine "include = smb-shares-COMMON.conf"
  46. AppendIfNoSuchLine "include = smb-shares-local.conf"
  47. AppendIfNoSuchLine "include = smb-printers.conf"
  48. ResetSearch "1"
  49. #
  50. # workgroup = $(site)
  51. #
  52. LocateLineMatching "^[;[:blank:]]*workgroup[[:blank:]]*=.*"
  53. BeginGroupIfNoLineMatching '^[[:blank:]]*workgroup[[:blank:]]*=[[:blank:]]*$(site)[[:blank:]]*'
  54. ReplaceLineWith ' workgroup = $(site)'
  55. EndGroup
  56. CatchAbort
  57. BeginGroupIfNoMatch '^[[:blank:]]*workgroup[[:blank:]]*=[[:blank:]]*$(site)[[:blank:]]*'
  58. InsertLine ' workgroup = $(site)'
  59. EndGroup
  60. #
  61. # wins support = yes
  62. #
  63. LocateLineMatching "^[;[:blank:]]*wins support[[:blank:]]*=.*"
  64. BeginGroupIfNoLineMatching "^[[:blank:]]*wins support[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  65. ReplaceLineWith ' wins support = yes'
  66. EndGroup
  67. CatchAbort
  68. BeginGroupIfNoMatch "^[[:blank:]]*wins support[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  69. InsertLine ' wins support = yes'
  70. EndGroup
  71. #
  72. # os level = 65
  73. #
  74. LocateLineMatching "^[;[:blank:]]*os level[[:blank:]]*=.*"
  75. BeginGroupIfNoLineMatching "^[[:blank:]]*os level[[:blank:]]*=[[:blank:]]*65[[:blank:]]*"
  76. ReplaceLineWith ' os level = 65'
  77. EndGroup
  78. CatchAbort
  79. BeginGroupIfNoMatch "^[[:blank:]]*os level[[:blank:]]*=[[:blank:]]*65[[:blank:]]*"
  80. InsertLine ' os level = 65'
  81. EndGroup
  82. #
  83. # domain master = yes
  84. #
  85. LocateLineMatching "^[;[:blank:]]*domain master[[:blank:]]*=.*"
  86. BeginGroupIfNoLineMatching "^[[:blank:]]*domain master[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  87. ReplaceLineWith ' domain master = yes'
  88. EndGroup
  89. CatchAbort
  90. BeginGroupIfNoMatch "^[[:blank:]]*domain master[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  91. InsertLine ' domain master = yes'
  92. EndGroup
  93. #
  94. # local master = yes
  95. #
  96. LocateLineMatching "^[;[:blank:]]*local master[[:blank:]]*=.*"
  97. BeginGroupIfNoLineMatching "^[[:blank:]]*local master[[:blank:]]*=[[:blank:]]*yes"
  98. ReplaceLineWith ' local master = yes'
  99. EndGroup
  100. CatchAbort
  101. BeginGroupIfNoMatch "^[[:blank:]]*local master[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  102. InsertLine ' local master = yes'
  103. EndGroup
  104. #
  105. # logon drive = U:
  106. #
  107. LocateLineMatching "^[;[:blank:]]*logon drive[[:blank:]]*=.*"
  108. BeginGroupIfNoLineMatching "^[[:blank:]]*logon drive[[:blank:]]*=[[:blank:]]*U:[[:blank:]]*"
  109. ReplaceLineWith ' logon drive = U:'
  110. EndGroup
  111. CatchAbort
  112. BeginGroupIfNoMatch "^[[:blank:]]*logon drive[[:blank:]]*=[[:blank:]]*U:[[:blank:]]*"
  113. InsertLine ' logon drive = U:'
  114. EndGroup
  115. #
  116. # logon script = common.bat
  117. #
  118. LocateLineMatching "^[;[:blank:]]*logon script[[:blank:]]*=.*"
  119. BeginGroupIfNoLineMatching "^[[:blank:]]*logon script[[:blank:]]*=[[:blank:]]*common.bat[[:blank:]]*"
  120. ReplaceLineWith ' logon script = common.bat'
  121. EndGroup
  122. CatchAbort
  123. BeginGroupIfNoMatch "^[[:blank:]]*logon script[[:blank:]]*=[[:blank:]]*common.bat[[:blank:]]*"
  124. InsertLine ' logon script = common.bat'
  125. EndGroup
  126. #
  127. # domain logons = yes
  128. #
  129. LocateLineMatching "^[;[:blank:]]*domain logons[[:blank:]]*=.*"
  130. BeginGroupIfNoLineMatching "^[[:blank:]]*domain logons[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  131. ReplaceLineWith ' domain logons = yes'
  132. EndGroup
  133. CatchAbort
  134. BeginGroupIfNoMatch "^[[:blank:]]*domain logons[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  135. InsertLine ' domain logons = yes'
  136. EndGroup
  137. #
  138. # logon path = \\%N\USERPROFILES\%U
  139. #
  140. LocateLineMatching "^[;[:blank:]]*logon path[[:blank:]]*=.*"
  141. BeginGroupIfNoLineMatching "^[[:blank:]]*logon path[[:blank:]]*=[[:blank:]]*[\\][\\]%N[\\]USERPROFILES[\\]%U[[:blank:]]*"
  142. ReplaceLineWith ' logon path = \\%N\USERPROFILES\%U'
  143. EndGroup
  144. CatchAbort
  145. BeginGroupIfNoMatch "^[[:blank:]]*logon path[[:blank:]]*=[[:blank:]]*[\\][\\]%N[\\]USERPROFILES[\\]%U[[:blank:]]*"
  146. InsertLine ' logon path = \\%N\USERPROFILES\%U'
  147. EndGroup
  148. #
  149. # preferred master = yes
  150. #
  151. LocateLineMatching "^[;[:blank:]]*preferred master[[:blank:]]*=.*"
  152. BeginGroupIfNoLineMatching "^[[:blank:]]*preferred master[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  153. ReplaceLineWith ' preferred master = yes'
  154. EndGroup
  155. CatchAbort
  156. BeginGroupIfNoMatch "^[[:blank:]]*preferred master[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  157. InsertLine ' preferred master = yes'
  158. EndGroup
  159. DefineClasses "samba_reload"
  160. }
  161. samba_reload::
  162. { /etc/samba/smb.conf
  163. LocateLineMatching "^; EDITED BY CFENGINE .*"
  164. ReplaceAll '; EDITED BY CFENGINE .*$' With '; EDITED BY CFENGINE $(date)'
  165. CatchAbort
  166. BeginGroupIfNoMatch "^; EDITED BY CFENGINE .*"
  167. Append '; EDITED BY CFENGINE $(date)'
  168. EndGroup
  169. }
  170. any::
  171. { /etc/samba/smb-shares-COMMON.conf
  172. #
  173. # This file contains all the shares common to all installations.
  174. # We check if the proper sections are there and add them if they
  175. # isn't. We don't check the file line for line.
  176. #
  177. AutoCreate
  178. #
  179. # [netlogon]
  180. #
  181. BeginGroupIfNoLineMatching "^\[netlogon\]"
  182. Append '[netlogon]'
  183. Append ' comment = Network logon'
  184. Append ' path = $(netlogshare)'
  185. Append ' browsable = no'
  186. Append ' writeable = no'
  187. Append ' share modes = no'
  188. EndGroup
  189. #
  190. # [userprofiles]
  191. #
  192. BeginGroupIfNoLineMatching "^\[userprofiles\]"
  193. Append '[userprofiles]'
  194. Append ' path = $(profshare)'
  195. Append ' force user = %u'
  196. Append ' writable = yes'
  197. Append ' browsable = no'
  198. Append ' root preexec = /bin/mkdir $(profshare)/%U \'
  199. Append ' /bin/chown %U $(profshare)/%U \'
  200. Append ' /bin/chmod 700 $(profshare)/%U'
  201. EndGroup
  202. #
  203. # [homes]
  204. #
  205. BeginGroupIfNoLineMatching "^\[homes\]"
  206. Append '[homes]'
  207. Append ' path = /home/%u/shared'
  208. Append ' browsable = no'
  209. Append ' root preexec = /bin/mkdir /home/%u/shared \'
  210. Append ' /bin/chown %U /home/%u/shared \'
  211. Append ' /bin/chmod 644 /home/%u/shared'
  212. EndGroup
  213. #
  214. # [programmer]
  215. #
  216. BeginGroupIfNoLineMatching "^\[programmer\]"
  217. Append '[programmer]'
  218. Append ' path = $(pgrshare)'
  219. Append ' comment = Programmer'
  220. Append ' browsable = yes'
  221. Append ' guest ok = yes'
  222. Append ' writeable = yes'
  223. EndGroup
  224. #
  225. # [dokumenter]
  226. #
  227. BeginGroupIfNoLineMatching "^\[dokumenter\]"
  228. Append '[dokumenter]'
  229. Append ' path = $(datashare)'
  230. Append ' comment = Fælles dokumenter'
  231. Append ' browsable = yes'
  232. Append ' guest ok = no'
  233. Append ' writeable = yes'
  234. EndGroup
  235. DefineClasses "samba_reload"
  236. }
  237. samba_reload::
  238. { /etc/samba/smb-shares-COMMON.conf
  239. LocateLineMatching "^; EDITED BY CFENGINE .*"
  240. ReplaceAll '; EDITED BY CFENGINE .*$' With '; EDITED BY CFENGINE $(date)'
  241. CatchAbort
  242. BeginGroupIfNoMatch "^; EDITED BY CFENGINE .*"
  243. Append '; EDITED BY CFENGINE $(date)'
  244. EndGroup
  245. }
  246. any::
  247. #
  248. # Local shares special for the site
  249. #
  250. { /etc/samba/smb-shares-$(site).conf
  251. #
  252. # We don't make this file dynamically, but instead we copy the contents
  253. # of a master file, but only if it's newer than the one installed.
  254. #
  255. BeginGroupIfFileIsNewer "/etc/local-$(host).$(domain)/samba/smb-shares-$(site).conf"
  256. EmptyEntireFilePlease
  257. InsertFile "/etc/local-$(host).$(domain)/samba/smb-shares-$(site).conf"
  258. Append "# Edited by cfengine $(date)"
  259. EndGroup
  260. DefineClasses "lprng_reload"
  261. }
  262. any::
  263. #
  264. # Printer configuration stuff
  265. #
  266. { /etc/printcap
  267. #
  268. # We don't make the printcap dynamically, but instead we copy the contents
  269. # of a master file, but only if it's newer than the one installed.
  270. #
  271. BeginGroupIfFileIsNewer "/etc/local-$(host).$(domain)/printcap"
  272. EmptyEntireFilePlease
  273. InsertFile "/etc/local-$(host).$(domain)/printcap"
  274. Append "# Edited by cfengine $(date)"
  275. EndGroup
  276. DefineClasses "lprng_reload"
  277. }
  278. any::
  279. { /etc/samba/smb-printers.conf
  280. #
  281. # This file contains all the printers defined in the Linux printing
  282. # system. There shouldn't be any need for setting up additional
  283. # printer entries. Manage the printers through the Linux print
  284. # system.
  285. # We check if the proper sections are there and add them if they
  286. # isn't. We don't check the file line for line.
  287. #
  288. AutoCreate
  289. #
  290. # [printers]
  291. #
  292. BeginGroupIfNoLineMatching "^\[printers\]"
  293. Append '[printers]'
  294. Append ' comment = %S printer'
  295. Append ' path = $(printdir)'
  296. Append ' print command = /usr/bin/lpr -h %s'
  297. Append ' lprm command = /usr/bin/lprm -P%S %j'
  298. Append ' public = yes'
  299. Append ' printable = yes'
  300. EndGroup
  301. }
  302. samba_reload::
  303. { /etc/samba/smb-printers.conf
  304. LocateLineMatching "^; EDITED BY CFENGINE .*"
  305. ReplaceAll '; EDITED BY CFENGINE .*$' With '; EDITED BY CFENGINE $(date)'
  306. CatchAbort
  307. BeginGroupIfNoMatch "^; EDITED BY CFENGINE .*"
  308. Append '; EDITED BY CFENGINE $(date)'
  309. EndGroup
  310. }
  311. directories:
  312. $(netlogshare)
  313. mode=755
  314. owner=root
  315. group=root
  316. $(commonsharedir)
  317. mode=755
  318. owner=root
  319. group=root
  320. $(pgrshare)
  321. mode=775
  322. owner=root
  323. group=users
  324. $(datashare)
  325. mode=775
  326. owner=root
  327. group=users
  328. $(profshare)
  329. mode=775
  330. owner=root
  331. group=users
  332. processes:
  333. "smb" restart "/etc/init.d/samba restart"
  334. shellcommands:
  335. samba_reload::
  336. "/etc/init.d/samba force-reload"
  337. netatalk_reload::
  338. "/etc/init.d/netatalk force-reload"
  339. lprng_reload::
  340. "/etc/init.d/lprng force-reload"
  341. cups_reload::
  342. "/etc/init.d/cups force-reload"