summaryrefslogtreecommitdiff
path: root/cfengine/cf.services.file
blob: d5e1a129b4c5a306b450cd6d8c9b1ec1ac92f103 (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/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. editfiles:
  40. samba::
  41. #
  42. # Samba configuration stuff.
  43. #
  44. { /etc/samba/smb.conf
  45. #
  46. # Global stuff
  47. #
  48. # Remove share declarations from main smb.conf. It is split
  49. # up in the following files:
  50. # - smb.conf
  51. # - smb-shares-COMMON.conf
  52. # - smb-shares-$(site).conf
  53. # - smb-printers.conf
  54. #
  55. # DeleteLinesAfterThisMatching "^\[homes\]$(n)*.*"
  56. # ResetSearch "1"
  57. # CatchAbort
  58. # ResetSearch "1"
  59. #
  60. # Append the include lines for the files decribed above
  61. #
  62. AppendIfNoSuchLine "include = /etc/samba/smb-shares-COMMON.conf"
  63. AppendIfNoSuchLine "include = /etc/samba/smb-printers.conf"
  64. BeginGroupIfFileExists "/etc/local-COMMON/samba/smb-shares-$(site).conf"
  65. AppendIfNoSuchLine "include = /etc/samba/smb-shares-$(site).conf"
  66. EndGroup
  67. ResetSearch "1"
  68. #
  69. # workgroup = $(site)
  70. #
  71. LocateLineMatching "^[;[:blank:]]*workgroup[[:blank:]]*=.*"
  72. BeginGroupIfNoLineMatching '^[[:blank:]]*workgroup[[:blank:]]*=[[:blank:]]*$(site)[[:blank:]]*'
  73. ReplaceLineWith ' workgroup = $(site)'
  74. EndGroup
  75. CatchAbort
  76. BeginGroupIfNoMatch '^[[:blank:]]*workgroup[[:blank:]]*=[[:blank:]]*$(site)[[:blank:]]*'
  77. InsertLine ' workgroup = $(site)'
  78. EndGroup
  79. #
  80. # wins support = yes
  81. #
  82. LocateLineMatching "^[;[:blank:]]*wins support[[:blank:]]*=.*"
  83. BeginGroupIfNoLineMatching "^[[:blank:]]*wins support[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  84. ReplaceLineWith ' wins support = yes'
  85. EndGroup
  86. CatchAbort
  87. BeginGroupIfNoMatch "^[[:blank:]]*wins support[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  88. InsertLine ' wins support = yes'
  89. EndGroup
  90. #
  91. # os level = 65
  92. #
  93. LocateLineMatching "^[;[:blank:]]*os level[[:blank:]]*=.*"
  94. BeginGroupIfNoLineMatching "^[[:blank:]]*os level[[:blank:]]*=[[:blank:]]*65[[:blank:]]*"
  95. ReplaceLineWith ' os level = 65'
  96. EndGroup
  97. CatchAbort
  98. BeginGroupIfNoMatch "^[[:blank:]]*os level[[:blank:]]*=[[:blank:]]*65[[:blank:]]*"
  99. InsertLine ' os level = 65'
  100. EndGroup
  101. #
  102. # domain master = yes
  103. #
  104. LocateLineMatching "^[;[:blank:]]*domain master[[:blank:]]*=.*"
  105. BeginGroupIfNoLineMatching "^[[:blank:]]*domain master[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  106. ReplaceLineWith ' domain master = yes'
  107. EndGroup
  108. CatchAbort
  109. BeginGroupIfNoMatch "^[[:blank:]]*domain master[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  110. InsertLine ' domain master = yes'
  111. EndGroup
  112. #
  113. # local master = yes
  114. #
  115. LocateLineMatching "^[;[:blank:]]*local master[[:blank:]]*=.*"
  116. BeginGroupIfNoLineMatching "^[[:blank:]]*local master[[:blank:]]*=[[:blank:]]*yes"
  117. ReplaceLineWith ' local master = yes'
  118. EndGroup
  119. CatchAbort
  120. BeginGroupIfNoMatch "^[[:blank:]]*local master[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  121. InsertLine ' local master = yes'
  122. EndGroup
  123. #
  124. # logon drive = U:
  125. #
  126. LocateLineMatching "^[;[:blank:]]*logon drive[[:blank:]]*=.*"
  127. BeginGroupIfNoLineMatching "^[[:blank:]]*logon drive[[:blank:]]*=[[:blank:]]*U:[[:blank:]]*"
  128. ReplaceLineWith ' logon drive = U:'
  129. EndGroup
  130. CatchAbort
  131. BeginGroupIfNoMatch "^[[:blank:]]*logon drive[[:blank:]]*=[[:blank:]]*U:[[:blank:]]*"
  132. InsertLine ' logon drive = U:'
  133. EndGroup
  134. #
  135. # logon script = common.bat
  136. #
  137. LocateLineMatching "^[;[:blank:]]*logon script[[:blank:]]*=.*"
  138. BeginGroupIfNoLineMatching "^[[:blank:]]*logon script[[:blank:]]*=[[:blank:]]*common.bat[[:blank:]]*"
  139. ReplaceLineWith ' logon script = common.bat'
  140. EndGroup
  141. CatchAbort
  142. BeginGroupIfNoMatch "^[[:blank:]]*logon script[[:blank:]]*=[[:blank:]]*common.bat[[:blank:]]*"
  143. InsertLine ' logon script = common.bat'
  144. EndGroup
  145. #
  146. # domain logons = yes
  147. #
  148. LocateLineMatching "^[;[:blank:]]*domain logons[[:blank:]]*=.*"
  149. BeginGroupIfNoLineMatching "^[[:blank:]]*domain logons[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  150. ReplaceLineWith ' domain logons = yes'
  151. EndGroup
  152. CatchAbort
  153. BeginGroupIfNoMatch "^[[:blank:]]*domain logons[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  154. InsertLine ' domain logons = yes'
  155. EndGroup
  156. #
  157. # logon path = \\%N\USERPROFILES\%U
  158. #
  159. LocateLineMatching "^[;[:blank:]]*logon path[[:blank:]]*=.*"
  160. BeginGroupIfNoLineMatching "^[[:blank:]]*logon path[[:blank:]]*=[[:blank:]]*[\\][\\]%N[\\]USERPROFILES[\\]%U[[:blank:]]*"
  161. ReplaceLineWith ' logon path = \\%N\USERPROFILES\%U'
  162. EndGroup
  163. CatchAbort
  164. BeginGroupIfNoMatch "^[[:blank:]]*logon path[[:blank:]]*=[[:blank:]]*[\\][\\]%N[\\]USERPROFILES[\\]%U[[:blank:]]*"
  165. InsertLine ' logon path = \\%N\USERPROFILES\%U'
  166. EndGroup
  167. #
  168. # preferred master = yes
  169. #
  170. LocateLineMatching "^[;[:blank:]]*preferred master[[:blank:]]*=.*"
  171. BeginGroupIfNoLineMatching "^[[:blank:]]*preferred master[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  172. ReplaceLineWith ' preferred master = yes'
  173. EndGroup
  174. CatchAbort
  175. BeginGroupIfNoMatch "^[[:blank:]]*preferred master[[:blank:]]*=[[:blank:]]*yes[[:blank:]]*"
  176. InsertLine ' preferred master = yes'
  177. EndGroup
  178. DefineClasses "samba_reload"
  179. }
  180. { /etc/samba/smb-shares-COMMON.conf
  181. #
  182. # This file contains all the shares common to all installations.
  183. # We check if the proper sections are there and add them if they
  184. # isn't. We don't check the file line for line.
  185. #
  186. AutoCreate
  187. #
  188. # [netlogon]
  189. #
  190. BeginGroupIfNoLineMatching "^\[netlogon\]"
  191. Append '[netlogon]'
  192. Append ' comment = Network logon'
  193. Append ' path = $(netlogshare)'
  194. Append ' browsable = no'
  195. Append ' writeable = no'
  196. Append ' share modes = no'
  197. EndGroup
  198. #
  199. # [userprofiles]
  200. #
  201. BeginGroupIfNoLineMatching "^\[userprofiles\]"
  202. Append '[userprofiles]'
  203. Append ' path = $(profshare)'
  204. Append ' force user = %u'
  205. Append ' writable = yes'
  206. Append ' browsable = no'
  207. Append ' root preexec = /bin/mkdir $(profshare)/%U \'
  208. Append ' /bin/chown %U $(profshare)/%U \'
  209. Append ' /bin/chmod 700 $(profshare)/%U'
  210. EndGroup
  211. #
  212. # [homes]
  213. #
  214. BeginGroupIfNoLineMatching "^\[homes\]"
  215. Append '[homes]'
  216. Append ' path = /home/%u/$(privpcshare)'
  217. Append ' browsable = no'
  218. Append ' root preexec = /bin/mkdir /home/%u/$(privpcshare) \'
  219. Append ' /bin/chown %U /home/%u/$(privpcshare) \'
  220. Append ' /bin/chmod 644 /home/%u/$(privpcshare)'
  221. EndGroup
  222. #
  223. # [programmer]
  224. #
  225. BeginGroupIfNoLineMatching "^\[software\]"
  226. Append '[software]'
  227. Append ' path = $(softshare)'
  228. Append ' comment = Fælles software'
  229. Append ' browsable = yes'
  230. Append ' guest ok = no'
  231. Append ' writeable = yes'
  232. Append ' valid users = @$(admingrp)'
  233. Append ' force group = +$(admingrp)'
  234. EndGroup
  235. #
  236. # [dokumenter]
  237. #
  238. BeginGroupIfNoLineMatching "^\[dokumenter\]"
  239. Append '[dokumenter]'
  240. Append ' path = $(datashare)'
  241. Append ' comment = Fælles dokumenter'
  242. Append ' browsable = yes'
  243. Append ' guest ok = no'
  244. Append ' writeable = yes'
  245. Append ' valid users = @$(admingrp)'
  246. Append ' force group = +$(admingrp)'
  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. #
  290. # Batch file for mounting shares automatically
  291. #
  292. { /etc/samba/netlogon/common.bat
  293. #
  294. # We don't make this file dynamically, but instead we copy the contents
  295. # of a master file, but only if it's newer than the one installed.
  296. #
  297. BeginGroupIfFileIsNewer "/etc/local-COMMON/samba/netlogon/common.bat"
  298. AutoCreate
  299. EmptyEntireFilePlease
  300. InsertFile "/etc/local-COMMON/samba/netlogon/common.bat"
  301. Append "rem Edited by cfengine $(date)"
  302. EndGroup
  303. DefineClasses "samba_reload"
  304. }
  305. lprng::
  306. { /etc/samba/smb.conf
  307. #
  308. # printing = lprng
  309. #
  310. ResetSearch "1"
  311. LocateLineMatching "^[;[:blank:]]*printing[[:blank:]]*=.*"
  312. BeginGroupIfNoLineMatching '^[[:blank:]]*printing[[:blank:]]*=[[:blank:]]*lprng[[:blank:]]*'
  313. ReplaceLineWith ' printing = lprng'
  314. EndGroup
  315. CatchAbort
  316. BeginGroupIfNoMatch '^[[:blank:]]*printing[[:blank:]]*=[[:blank:]]*lprng[[:blank:]]*'
  317. InsertLine ' printing = lprng'
  318. EndGroup
  319. DefineClasses "samba_reload"
  320. }
  321. #
  322. # Printer configuration stuff
  323. #
  324. { /etc/printcap
  325. #
  326. # We don't make the printcap dynamically, but instead we copy the contents
  327. # of a master file, but only if it's newer than the one installed.
  328. #
  329. BeginGroupIfFileIsNewer "/etc/local-COMMON/printcap.$(site)"
  330. EmptyEntireFilePlease
  331. InsertFile "/etc/local-COMMON/printcap.$(site)"
  332. Append "# Edited by cfengine $(date)"
  333. EndGroup
  334. DefineClasses "lprng_reload"
  335. }
  336. samba_reload::
  337. { /etc/samba/smb.conf
  338. LocateLineMatching "^; EDITED BY CFENGINE .*"
  339. ReplaceAll '; EDITED BY CFENGINE .*$' With '; EDITED BY CFENGINE $(date)'
  340. CatchAbort
  341. BeginGroupIfNoMatch "^; EDITED BY CFENGINE .*"
  342. Append '; EDITED BY CFENGINE $(date)'
  343. EndGroup
  344. }
  345. { /etc/samba/smb-shares-COMMON.conf
  346. LocateLineMatching "^; EDITED BY CFENGINE .*"
  347. ReplaceAll '; EDITED BY CFENGINE .*$' With '; EDITED BY CFENGINE $(date)'
  348. CatchAbort
  349. BeginGroupIfNoMatch "^; EDITED BY CFENGINE .*"
  350. Append '; EDITED BY CFENGINE $(date)'
  351. EndGroup
  352. }
  353. { /etc/samba/smb-shares-$(site).conf
  354. LocateLineMatching "^; EDITED BY CFENGINE .*"
  355. ReplaceAll '; EDITED BY CFENGINE .*$' With '; EDITED BY CFENGINE $(date)'
  356. CatchAbort
  357. BeginGroupIfNoMatch "^; EDITED BY CFENGINE .*"
  358. Append '; EDITED BY CFENGINE $(date)'
  359. EndGroup
  360. }
  361. { /etc/samba/smb-printers.conf
  362. LocateLineMatching "^; EDITED BY CFENGINE .*"
  363. ReplaceAll '; EDITED BY CFENGINE .*$' With '; EDITED BY CFENGINE $(date)'
  364. CatchAbort
  365. BeginGroupIfNoMatch "^; EDITED BY CFENGINE .*"
  366. Append '; EDITED BY CFENGINE $(date)'
  367. EndGroup
  368. }
  369. directories:
  370. any::
  371. $(commonsharedir)
  372. mode=755
  373. owner=$(adminuser)
  374. group=$(admingrp)
  375. $(softshare)
  376. mode=775
  377. owner=$(adminuser)
  378. group=$(admingrp)
  379. $(datashare)
  380. mode=775
  381. owner=$(adminuser)
  382. group=$(admingrp)
  383. samba::
  384. $(netlogshare)
  385. mode=755
  386. owner=root
  387. group=root
  388. $(profshare)
  389. mode=775
  390. owner=$(adminuser)
  391. group=$(admingrp)
  392. $(printdir)
  393. mode=775
  394. owner=root
  395. group=root
  396. processes:
  397. "smbd" restart "/etc/init.d/samba restart"
  398. "afpd" restart "/etc/init.d/netatalk restart"
  399. shellcommands:
  400. samba_reload::
  401. "/etc/init.d/samba force-reload"
  402. netatalk_reload::
  403. "/etc/init.d/netatalk force-reload"
  404. lprng_reload::
  405. "/etc/init.d/lprng force-reload"
  406. cups_reload::
  407. "/etc/init.d/cups force-reload"