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