Skip to content

Instantly share code, notes, and snippets.

@warwickchapman
Forked from jniltinho/install_samba4.sh
Last active June 1, 2021 03:00
Show Gist options
  • Save warwickchapman/07718d401c3f400157d4fe3f2f44d3eb to your computer and use it in GitHub Desktop.
Save warwickchapman/07718d401c3f400157d4fe3f2f44d3eb to your computer and use it in GitHub Desktop.
Compile Samba4 for Debian/Ubuntu
#!/bin/bash
## Install Samba4 4.8.0
## On Debian 64Bits
## Author: Nilton OS -- www.linuxpro.com.br
## Version: 0.4.2
## History
## 0.4.1 - Added libpam0g-dev and updated to 4.8.0
## 0.4.2 - Added bison flex libavahi-client-dev libavahi-common-dev tracker libtracker-sparql-1.0-dev --systemd-install-services --enable-spotlight
### Tested on Debian 8.9/9.1 & Ubuntu 16.04 64Bits
apt-get install -y libreadline-dev git build-essential libattr1-dev libblkid-dev
apt-get install -y autoconf python-dev python-dnspython libacl1-dev gdb pkg-config libpopt-dev libldap2-dev
apt-get install -y dnsutils acl attr libbsd-dev docbook-xsl libcups2-dev libgnutls28-dev
apt-get install -y tracker libtracker-sparql-1.0-dev libpam0g-dev libavahi-client-dev libavahi-common-dev bison flex
cd /usr/src
wget https://download.samba.org/pub/samba/stable/samba-4.8.0.tar.gz
tar -xzvf samba-4.8.0.tar.gz
cd samba-4.8.0
./configure --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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment