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