With the following script we can automatically add shares to the smb.conf (/etc/samba/smb.conf) based on the actual unix users:

#!/bin/bash

writesmb()
{

echo "[$f]" >> /etc/samba/smb.conf
echo " read only = no" >> /etc/samba/smb.conf
echo " valid users = $f" >> /etc/samba/smb.conf
echo " path = /home/$f" >> /etc/samba/smb.conf
echo " create mask = 0777" >> /etc/samba/smb.conf
echo " directory mask = 0777" >> /etc/samba/smb.conf
echo "" >> smb.conf
}

for f in $( ls /home ); do writesmb; done

Advertisements