#!/bin/sh


if [ -z "$1" ]
  then
    echo "Type your ExportVHosts share password, followed by [ENTER]:"
    read -s EXPORTVHOSTS_PASSWORD 
else
    export EXPORTVHOSTS_PASSWORD=$1
fi


export VM_IP_ADDRESS=192.168.137.2
export HOST_IP_ADDRESS=192.168.137.3


echo "" >> /etc/hosts
echo $VM_IP_ADDRESS vm >> /etc/hosts
echo $VM_IP_ADDRESS mysql.vm >> /etc/hosts
echo $VM_IP_ADDRESS ordering.vmware.local >> /etc/hosts
echo $VM_IP_ADDRESS billing.vmware.local >> /etc/hosts
echo $VM_IP_ADDRESS bsi.vmware.local >> /etc/hosts
echo $VM_IP_ADDRESS bsiadmin.vmware.local >> /etc/hosts
echo $VM_IP_ADDRESS rapid.vmware.local >> /etc/hosts
echo $VM_IP_ADDRESS rapid.vmware.local >> /etc/hosts
echo $VM_IP_ADDRESS bsa.bigstep.local >> /etc/hosts
echo $VM_IP_ADDRESS bsa.vmware.local >> /etc/hosts
echo $VM_IP_ADDRESS repo.vmware.local >> /etc/hosts
echo $VM_IP_ADDRESS begisreports.vm >> /etc/hosts
echo $HOST_IP_ADDRESS physicalhost >> /etc/hosts
echo "" >> /etc/hosts



useradd bigstepdevel

mkdir /ExportVHosts
chmod -R 0777 /ExportVHosts
chown -R bigstepdevel /ExportVHosts

# echo -e "new"'!'"$EXPORTVHOSTS_PASSWORD\nnew"'!'"$EXPORTVHOSTS_PASSWORD" | passwd bigstepdevel



apt-get -y install samba
apt-get -y install samba-client samba-common cifs-utils
apt-get -y install smbclient

# This fixes a Samba warning for Windows compatibility when running Samba's testparm
# rlimit_max: rlimit_max (8192) below minimum Windows limit (16384)
echo "* - nofile 16384" >> /etc/security/limits.conf

read -r -d '' SMBCONF << EOM
[global]
workgroup = WORKGROUP
server string = %h server (Samba, Ubuntu)
dns proxy = no
log file = /var/log/samba/log.%m
max log size = 1000
syslog = 0
panic action = /usr/share/samba/panic-action %d
server role = standalone server
passdb backend = tdbsam
obey pam restrictions = yes
unix password sync = yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
pam password change = yes
map to guest = bad user
usershare allow guests = yes
security = user
guest account = nobody
map to guest = Bad Password
hosts allow = 192.168.137.2
hosts deny = all
guest account = bigstepdevel
follow symlinks = yes
wide links = yes
hide dot files = no
unix extensions = no
allow insecure wide links = yes
# Share
[ExportVHosts]
path = /ExportVHosts
guest only = yes
guest account = nobody
writable = yes
read only = No
browseable= yes
create mask = 0777
guest ok = yes
directory mask = 0777
public = yes
available = yes
EOM
echo "$SMBCONF" > /etc/samba/smb.conf

systemctl enable smbd
systemctl restart smbd

