Skip to content

Instantly share code, notes, and snippets.

@jniltinho
Last active November 23, 2020 11:10
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save jniltinho/3eae533a95887817a1c30314051524db to your computer and use it in GitHub Desktop.
Save jniltinho/3eae533a95887817a1c30314051524db to your computer and use it in GitHub Desktop.
Compile Samba4 for Debian/Ubuntu
#!/bin/bash
## Install Samba4 4.12.3
## On Ubuntu 18.04 64Bits
## Author: Nilton OS -- www.linuxpro.com.br
## Link: https://github.com/jniltinho/go-samba4
## https://wiki.samba.org/index.php/Package_Dependencies_Required_to_Build_Samba
## Version: 0.6
### Tested on Ubuntu 18.04 64Bits
apt-get update
apt-get -yq install ruby-dev wget curl
wget -O bootstrap.sh 'https://git.samba.org/?p=samba.git;a=blob_plain;f=bootstrap/generated-dists/ubuntu1804/bootstrap.sh;hb=v4-12-test'
bash bootstrap.sh
gem install fpm
cd /usr/src
get_samba4=https://download.samba.org/pub/samba/stable/samba-4.12.3.tar.gz
wget -c ${get_samba4}
tar xvfz $(basename ${get_samba4})
cd $(basename ${get_samba4}|sed "s/.tar.gz//")
./configure --with-ads --systemd-install-services --with-shared-modules=idmap_ad --enable-debug --enable-selftest --with-systemd --enable-spotlight --prefix=/opt/samba4
make
make install
echo '[Unit]
Description=Samba4 AD Daemon
After=syslog.target network.target
[Service]
Type=forking
PIDFile=/opt/samba4/var/run/samba.pid
LimitNOFILE=16384
EnvironmentFile=-/etc/sysconfig/samba4
ExecStart=/opt/samba4/sbin/samba $SAMBAOPTIONS
ExecReload=/usr/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target' > /etc/systemd/system/samba4.service
### Add PATH
echo 'export PATH=$PATH:/opt/samba4/bin:/opt/samba4/sbin' >> /etc/profile
source /etc/profile
### Add start script on boot
# systemctl daemon-reload
# systemctl enable samba4.service
# systemctl start samba4.service
### To use Samba4 acls, add the following mount options to your data filesystems user_xattr,acl.
### If you use xfs you can also add barrier=1 which ensures that tdb transactions are safe against unexpected power loss.
## errors=remount-ro
### Change fstab
# cp /etc/fstab /etc/fstab_$$.bkp
# sed -i 's|errors=remount-ro|errors=remount-ro,acl,user_xattr,barrier=1|' /etc/fstab
# mount -o remount /
### Create User
# samba-tool user create nilton --random-password --use-username-as-cn --surname="OS" --given-name="Nilton" --mail-address=nilton@linuxpro.com.br --job-title="Goes there and back again"
@help-me-project
Copy link

Hi! Please add to compile script this line:
apt-get install -y libpam-dev libjansson4 libjansson-dev

@warwickchapman
Copy link

warwickchapman commented Apr 6, 2018

Updated with libpam0g-dev and 4.8.0 : https://gist.github.com/warwickchapman/07718d401c3f400157d4fe3f2f44d3eb

Also, tested on Ubuntu 16.04 LTS.

@jniltinho
Copy link
Author

Updated with libpam0g-dev and 4.8.0 : https://gist.github.com/warwickchapman/07718d401c3f400157d4fe3f2f44d3eb

Also, tested on Ubuntu 16.04 LTS.

:-) Thanks, Update for Samba 4.9.0

@dxgldotorg
Copy link

dxgldotorg commented Oct 13, 2018

What is your luck on Ubuntu 18.04? Currently trying to make an AD DC on that OS on an ODROID-C2. So far I needed to install, in addition to the already mentioned APT packages, libtracker-sparql-2.0-dev
EDIT: libtracker-sparql-1.0-dev needs to be replaced with libtracker-sparql-2.0-dev on line 16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment