add samba share for music on nas
This commit is contained in:
parent
e8983829ed
commit
82aeeb585d
5 changed files with 139 additions and 0 deletions
59
bundles/samba/items.py
Normal file
59
bundles/samba/items.py
Normal file
|
@ -0,0 +1,59 @@
|
|||
svc_systemd = {
|
||||
'nmbd': {
|
||||
'needs': {
|
||||
'pkg_apt:samba',
|
||||
},
|
||||
},
|
||||
'smbd': {
|
||||
'needs': {
|
||||
'pkg_apt:samba',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
files = {
|
||||
'/etc/samba/smb.conf': {
|
||||
'content_type': 'mako',
|
||||
'triggers': {
|
||||
'svc_systemd:nmbd:restart',
|
||||
'svc_systemd:smbd:restart',
|
||||
},
|
||||
},
|
||||
'/etc/systemd/system/nmbd.service.d/bundlewrap.conf': {
|
||||
'source': 'override.conf',
|
||||
'triggers': {
|
||||
'action:systemd-reload',
|
||||
'svc_systemd:nmbd:restart',
|
||||
},
|
||||
},
|
||||
'/etc/systemd/system/smbd.service.d/bundlewrap.conf': {
|
||||
'source': 'override.conf',
|
||||
'triggers': {
|
||||
'action:systemd-reload',
|
||||
'svc_systemd:smbd:restart',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
last_action = set()
|
||||
for user, uconfig in node.metadata.get('users', {}).items():
|
||||
if (
|
||||
'password' not in uconfig
|
||||
or uconfig.get('delete')
|
||||
or user in ('root',)
|
||||
):
|
||||
continue
|
||||
|
||||
actions[f'smbpasswd_for_user_{user}'] = {
|
||||
'command': f'smbpasswd -a -s {user}',
|
||||
'unless': f'pdbedit -L | grep -E "^{user}:"',
|
||||
'data_stdin': uconfig['password'] + '\n' + uconfig['password'],
|
||||
'needs': {
|
||||
'pkg_apt:samba',
|
||||
f'user:{user}',
|
||||
},
|
||||
'after': last_action,
|
||||
}
|
||||
last_action = {
|
||||
f'action:smbpasswd_for_user_{user}',
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue