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