summaryrefslogtreecommitdiff
path: root/cfengine/cf.services.file
blob: c6e79b52ad68b4c783007cefbec4f29575b3eca2 (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. AutoCreate
  260. BeginGroupIfFileIsNewer "/etc/local-COMMON/samba/smb-shares-$(site).conf"
  261. EmptyEntireFilePlease
  262. InsertFile "/etc/local-COMMON/samba/smb-shares-$(site).conf"
  263. Append "; Edited by cfengine $(date)"
  264. EndGroup
  265. DefineClasses "samba_reload"
  266. }
  267. { /etc/samba/smb-printers.conf
  268. #
  269. # This file contains all the printers defined in the Linux printing
  270. # system. There shouldn't be any need for setting up additional
  271. # printer entries. Manage the printers through the Linux print
  272. # system you have installed - cups or lprng.
  273. # We check if the proper sections are there and add them if they
  274. # isn't. We don't check the file line for line.
  275. #
  276. AutoCreate
  277. #
  278. # [printers]
  279. #
  280. BeginGroupIfNoLineMatching "^\[printers\]"
  281. Append '[printers]'
  282. Append ' comment = %S printer'
  283. Append ' path = $(printdir)'
  284. Append ' print command = /usr/bin/lpr -h %s'
  285. Append ' lprm command = /usr/bin/lprm -P%S %j'
  286. Append ' public = yes'
  287. Append ' printable = yes'
  288. EndGroup
  289. }
  290. #
  291. # Batch file for mounting shares automatically
  292. #
  293. { /etc/samba/netlogon/common.bat
  294. #
  295. # We don't make this file dynamically, but instead we copy the contents
  296. # of a master file, but only if it's newer than the one installed.
  297. #
  298. BeginGroupIfFileIsNewer "/etc/local-COMMON/samba/netlogon/common.bat"
  299. AutoCreate
  300. EmptyEntireFilePlease
  301. InsertFile "/etc/local-COMMON/samba/netlogon/common.bat"
  302. Append "rem Edited by cfengine $(date)"
  303. EndGroup
  304. DefineClasses "samba_reload"
  305. }
  306. lprng::
  307. { /etc/samba/smb.conf
  308. #
  309. # printing = lprng
  310. #
  311. ResetSearch "1"
  312. LocateLineMatching "^[;[:blank:]]*printing[[:blank:]]*=.*"
  313. BeginGroupIfNoLineMatching '^[[:blank:]]*printing[[:blank:]]*=[[:blank:]]*lprng[[:blank:]]*'
  314. ReplaceLineWith ' printing = lprng'
  315. EndGroup
  316. CatchAbort
  317. BeginGroupIfNoMatch '^[[:blank:]]*printing[[:blank:]]*=[[:blank:]]*lprng[[:blank:]]*'
  318. InsertLine ' printing = lprng'
  319. EndGroup
  320. DefineClasses "samba_reload"
  321. }
  322. #
  323. # Printer configuration stuff
  324. #
  325. { /etc/printcap
  326. #
  327. # We don't make the printcap dynamically, but instead we copy the contents
  328. # of a master file, but only if it's newer than the one installed.
  329. #
  330. BeginGroupIfFileIsNewer "/etc/local-COMMON/printcap.$(site)"
  331. EmptyEntireFilePlease
  332. InsertFile "/etc/local-COMMON/printcap.$(site)"
  333. Append "# Edited by cfengine $(date)"
  334. EndGroup
  335. DefineClasses "lprng_reload"
  336. }
  337. samba_reload::
  338. { /etc/samba/smb.conf
  339. LocateLineMatching "^; EDITED BY CFENGINE .*"
  340. ReplaceAll '; EDITED BY CFENGINE .*$' With '; EDITED BY CFENGINE $(date)'
  341. CatchAbort
  342. BeginGroupIfNoMatch "^; EDITED BY CFENGINE .*"
  343. Append '; EDITED BY CFENGINE $(date)'
  344. EndGroup
  345. }
  346. { /etc/samba/smb-shares-COMMON.conf
  347. LocateLineMatching "^; EDITED BY CFENGINE .*"
  348. ReplaceAll '; EDITED BY CFENGINE .*$' With '; EDITED BY CFENGINE $(date)'
  349. CatchAbort
  350. BeginGroupIfNoMatch "^; EDITED BY CFENGINE .*"
  351. Append '; EDITED BY CFENGINE $(date)'
  352. EndGroup
  353. }
  354. { /etc/samba/smb-shares-$(site).conf
  355. LocateLineMatching "^; EDITED BY CFENGINE .*"
  356. ReplaceAll '; EDITED BY CFENGINE .*$' With '; EDITED BY CFENGINE $(date)'
  357. CatchAbort
  358. BeginGroupIfNoMatch "^; EDITED BY CFENGINE .*"
  359. Append '; EDITED BY CFENGINE $(date)'
  360. EndGroup
  361. }
  362. { /etc/samba/smb-printers.conf
  363. LocateLineMatching "^; EDITED BY CFENGINE .*"
  364. ReplaceAll '; EDITED BY CFENGINE .*$' With '; EDITED BY CFENGINE $(date)'
  365. CatchAbort
  366. BeginGroupIfNoMatch "^; EDITED BY CFENGINE .*"
  367. Append '; EDITED BY CFENGINE $(date)'
  368. EndGroup
  369. }
  370. directories:
  371. any::
  372. $(commonsharedir)
  373. mode=755
  374. owner=$(adminuser)
  375. group=$(admingrp)
  376. $(softshare)
  377. mode=775
  378. owner=$(adminuser)
  379. group=$(admingrp)
  380. $(datashare)
  381. mode=775
  382. owner=$(adminuser)
  383. group=$(admingrp)
  384. samba::
  385. $(netlogshare)
  386. mode=755
  387. owner=root
  388. group=root
  389. $(profshare)
  390. mode=775
  391. owner=$(adminuser)
  392. group=$(admingrp)
  393. $(printdir)
  394. mode=775
  395. owner=root
  396. group=root
  397. processes:
  398. "smbd" restart "/etc/init.d/samba restart"
  399. "afpd" restart "/etc/init.d/netatalk restart"
  400. shellcommands:
  401. samba_reload::
  402. "/etc/init.d/samba force-reload"
  403. netatalk_reload::
  404. "/etc/init.d/netatalk force-reload"
  405. lprng_reload::
  406. "/etc/init.d/lprng force-reload"
  407. cups_reload::
  408. "/etc/init.d/cups force-reload"