Last active
August 31, 2023 20:02
-
-
Save jniltinho/7a59467a8a4e5e88a8166f9e7e679e4d to your computer and use it in GitHub Desktop.
Create Deb Samba4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## Create DEB package Samba4 4.12.3 (Ubuntu 18.04) | |
## http://sig9.hatenablog.com/entry/2017/12/04/000000 | |
## https://wiki.samba.org/index.php/Package_Dependencies_Required_to_Build_Samba | |
## https://github.com/jniltinho/go-samba4/releases | |
## https://www.tecmint.com/install-samba4-active-directory-ubuntu/ | |
## https://blog.ricosharp.com/posts/2019/Samba-4-Active-Directory-Domain-Controller-on-Ubuntu-18-04-Server | |
## http://www.bosontreinamentos.com.br/linux/samba-4-instalacao-e-provisionamento/ | |
## https://wiki.samba.org/index.php/Installing_RSAT | |
## https://www.tecmint.com/manage-samba4-ad-from-windows-via-rsat | |
## samba-tool user setexpiry Administrator --noexpiry | |
## samba-tool user create rebeca [email protected] | |
## chattr +i /etc/resolv.conf | |
## https://github.com/jniltinho/go-samba4/releases | |
## Debian 10 | |
## wget -O bootstrap.sh 'https://git.samba.org/?p=samba.git;a=blob_plain;f=bootstrap/generated-dists/debian10/bootstrap.sh;hb=v4-12-test' | |
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 | |
mkdir -p ~/build && cd ~/build | |
get_samba4=https://download.samba.org/pub/samba/stable/samba-4.12.3.tar.gz | |
PKG=$(basename ${get_samba4}|sed "s/.tar.gz//") | |
PKG_NAME=$(basename ${get_samba4}|sed "s/.tar.gz//"|cut -d- -f1) | |
PKG_VERSION=$(basename ${get_samba4}|sed "s/.tar.gz//"|cut -d- -f2) | |
wget -c ${get_samba4} | |
tar xvfz $(basename ${get_samba4}) | |
cd $(basename ${get_samba4}|sed "s/.tar.gz//") | |
./configure --with-ads --with-shared-modules=idmap_ad --with-systemd --prefix=/opt/samba4 | |
make -j$(nproc) | |
make install install DESTDIR=/tmp/installdir | |
mkdir -p /tmp/installdir/etc/systemd/system | |
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' > /tmp/installdir/etc/systemd/system/samba4.service | |
DIST=$(lsb_release -cs) | |
fpm -s dir -t deb -n ${PKG_NAME} -v ${PKG_VERSION} -C /tmp/installdir \ | |
-d "python3-minimal" \ | |
-d "libpython3.8" \ | |
-d "libbsd0" \ | |
-d "libpopt0" \ | |
-d "libgnutls30" \ | |
-d "libldap-2.4-2" \ | |
-d "libcups2" \ | |
-d "libjansson4" \ | |
-d "libtracker-sparql-2.0-0" \ | |
-d "libgpgme11" \ | |
-p ${PKG}+${DIST}-1.amd64.deb . | |
mv ${PKG}+${DIST}-1.amd64.deb /root/ | |
apt-get clean | |
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /var/cache/apt/archive/*.deb ~/build | |
## Install DEB | |
## apt-get update | |
## apt-get -yq install python3-minimal libpython3.8 libbsd0 libpopt0 libgnutls30 | |
## apt-get -yq install libldap-2.4-2 libcups2 libjansson4 libtracker-sparql-2.0-0 libgpgme11 | |
## dpkg -i /root/samba-4.12.3+bionic-1.amd64.deb | |
### Add PATH | |
echo 'export PATH=$PATH:/opt/samba4/bin:/opt/samba4/sbin' >> /etc/profile | |
source /etc/profile | |
### Create Domain Samba4 like AD | |
# hostnamectl set-hostname adc1.linuxpro.local | |
# samba-tool domain provision --server-role=dc --use-rfc2307 --dns-backend=SAMBA_INTERNAL --realm=LINUXPRO.LOCAL --domain=LINUXPRO --adminpass=@Linuxpro123456 | |
# samba-tool domain provision --server-role=dc --use-rfc2307 --function-level=2008_R2 --use-xattrs=yes --dns-backend=SAMBA_INTERNAL --realm=LINUXPRO.LOCAL --domain=LINUXPRO --adminpass=Linuxpro123456 | |
## mv /etc/krb5.conf /etc/krb5.conf.orig && cp /opt/samba4/private/krb5.conf /etc/krb5.conf | |
### Add start script on boot | |
# systemctl daemon-reload | |
# systemctl enable samba4.service | |
# systemctl start samba4.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment