# samba-grid CHANGELOG
+0.2.0
+-----
+- adds autopilot features.
+
0.1.3
-----
- fix service control.
|:--|:--|:--|:--|
|`['samba-grid']['group']['sambashare']['gid']`|String|`sambashare` group gid.|`nil`|
|`['samba-grid']['group']['sambashare']['members']`|Array|`sambashare` group members|`[]`|
+|`['samba-grid']['autopilot']`|Hash|Samba services's autopilot configurations.|See `attributes/default.rb`|
|`['samba-grid']['smb.conf']`|Hash|Samba configurations.|See `attributes/default.rb`|
|`['samba-grid']['smb.conf']['global']`|Hash|`[global]` section configurations in the `smb.conf`.|`{}`|
|`['samba-grid']['smb.conf']['homes']`|Hash|`[homes]` section configurations in the `smb.conf`.|`{}`|
- Author:: whitestar at osdn.jp
```text
-Copyright 2016-2017, whitestar
+Copyright 2016-2018, whitestar
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
# Cookbook Name:: samba-grid
# Attributes:: default
#
-# Copyright 2016, whitestar
+# Copyright 2016-2018, whitestar
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
'gid' => nil,
'members' => [],
}
+default['samba-grid']['autopilot'] = {
+ 'enabled' => false,
+ 'log_dir' => '/var/log',
+ 'wait_time' => '180s',
+}
default['samba-grid']['smb.conf'] = {
'global' => {
#'workgroup' => 'WORKGROUP',
notifies :restart, 'service[samba-ad-dc]' if platform == 'debian' && platform_version < '9.0'
#notifies :reload, 'service[samba]'
end
+
+# autopilot
+srv = 'samba'
+template "/etc/cron.d/#{srv}-local" do
+ source "etc/cron.d/#{srv}-local"
+ owner 'root'
+ group 'root'
+ mode '0644'
+ action :delete unless node['samba-grid']['autopilot']['enabled']
+end
--- /dev/null
+<%
+name = 'samba'
+
+conf = node['samba-grid']['autopilot']
+log = "#{conf['log_dir']}/#{name}-local.log"
+wait_time = conf['wait_time']
+
+cmd = nil
+st_cmd = nil
+if File.exist?('/etc/init.d/samba')
+ cmd = '/etc/init.d/samba restart'
+ st_cmd = '/etc/init.d/samba status'
+else
+ cmd = 'systemctl restart nmbd smbd'
+ st_cmd = 'systemctl status nmbd smbd'
+end
+-%>
+PATH=/usr/bin:/bin:/usr/local/bin
+DATE_F='+%Y-%m-%d %H:%M:%S %z'
+LOG=<%= log %>
+
+@reboot root sleep <%= wait_time %> && date "$DATE_F" > $LOG && <%= cmd %> >> $LOG 2>&1 && <%= st_cmd %> >> $LOG 2>&1