setup_sambauser() { echo -n "# Setting up samba user $1..." echo -ne "$2\n$2\n" | smbpasswd -a -s -U "$1" 2>/dev/null # $1: User, $2: Password ERR=$? if [ "$ERR" -ne 0 ]; then echo echo "# WARNING: Could not enter password for samba user $1." echo "# Please remember to set a password for user $1 by hand." else echo " ok." fi } setup_sambaconfig() { echo -n "# Writing samba config..." if [ $(grep -c "\[imageshare\]" /etc/samba/smb.conf) -gt 0 ]; then echo " config already written; doing nothing." else cat >>/etc/samba/smb.conf<<-EOF [imageshare] path = /srv/openslx/nfs comment = VM image share writable = yes valid users = vmware EOF echo "ok." fi } setup_samba() { setup_sambauser vmware openslx-ng setup_sambaconfig }