Tuesday, 5 November 2013

SAMBA: Samba4 install on Ubuntu Server 12.04

Samba4 install on Ubuntu Server 12.04


When I was trying to set-up Samba4 a lot of HOWTO's and sites were out of date or incomplete (see sources at end of post). This is the configuration that I used to get my server working and is currently in a production environment (35+ users).

Server details

  • Servername: SAMBA
  • DNS Domain name: mysamba.local (Realm MYSAMBA.LOCAL)
  • NETBIOS Domain name: MYSAMBA
  • IP address: 192.168.1.249
  • netmask 255.255.255.0
  • gateway: 192.168.1.254

Basics


sudo apt-get update && sudo apt-get upgrade

sudo apt-get install openssh-server

sudo passwd root

sudo nano /etc/network/interfaces

    auto lo
    iface lo inet loopback

    auto eth0
    iface eth0 inet static
    address 192.168.1.249
    netmask 255.255.255.0
    gateway 192.168.1.254
    dns-nameservers 192.168.1.249 8.8.8.8
    dns-search mysamba.local

sudo reboot now

ifconfig

Webmin (optional)


wget http://prdownloads.sourceforge.net/webadmin/webmin_1.660_all.deb
dpkg --install webmin_1.660_all.deb
sudo apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python

Install Samba


sudo apt-get install build-essential libacl1-dev python-dev libldap2-dev pkg-config gdb libgnutls-dev libblkid-dev libreadline-dev libattr1-dev python-dnspython libpopt-dev libbsd-dev attr docbook-xsl libcups2-dev git samba-common-bin -y

git clone git://git.samba.org/samba.git samba-master

cd samba-master
sudo ./configure
sudo make
sudo make install

Provision


/usr/local/samba/bin/samba-tool domain provision --use-rfc2307 --interactive


Starting Your Samba AD DC


/usr/local/samba/sbin/samba


Testing Connectivity to Your Samba AD DC


/usr/local/samba/bin/smbclient --version

/usr/local/samba/bin/smbclient -L localhost -U%

Add users


/usr/local/samba/bin/samba-tool user add USERNAME

Init scrit for auto start


sudo nano /etc/init.d/samba4

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

#! /bin/sh
### BEGIN INIT INFO
# Provides: samba
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start Samba daemons
### END INIT INFO
#
# Start/stops the Samba daemon (samba).
# Adapted from the Samba 3 packages.
#

SAMBAPID=/var/run/samba/samba.pid

# clear conflicting settings from the environment
unset TMPDIR
# See if the daemon and the config file are there
test -x /usr/local/samba/sbin -a -r /usr/local/samba/etc/ || exit 0

. /lib/lsb/init-functions

case "$1" in
start)
log_daemon_msg "Starting Samba 4 daemon" "samba"
if ! start-stop-daemon --start --quiet --oknodo --exec /usr/local/samba/sbin/samba -- -D; then
log_end_msg 1
exit 1
fi

log_end_msg 0
;;
stop)
log_daemon_msg "Stopping Samba 4 daemon" "samba"

start-stop-daemon --stop --quiet --name samba $SAMBAPID
# Wait a little and remove stale PID file
sleep 1
if [ -f $SAMBAPID ] && ! ps h `cat $SAMBAPID` > /dev/null
then
# Stale PID file (samba was succesfully stopped),
# remove it (should be removed by samba itself IMHO.)
rm -f $SAMBAPID
fi

log_end_msg 0
;;
restart|force-reload)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: /etc/init.d/samba {start|stop|restart|force-reload}"
exit 1
;;
esac

exit 0

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

sudo chmod 755 /etc/init.d/samba4

sudo update-rc.d samba4 defaults

Complete


Appreciation and thanks to the following sources;
https://wiki.samba.org/index.php/Samba4/HOWTO
http://ubuntuforums.org/showthread.php?t=2146198
http://paulcolfer.ie/tag/samba/
http://edoceo.com/howto/samba4
http://www.openchange.org/cookbook/configuring.html

No comments:

Post a Comment