
# Samba Installation and Configuration Guide for Ubuntu 24.04

## 1. Introduction

This guide provides step-by-step instructions for installing and configuring Samba on Ubuntu 24.04. The configuration file will be moved to a custom directory: `/etc/calypso/conf/smb`.

## 2. Installation

First, update the package lists and install the `samba` package.

```bash
sudo apt-get update
sudo apt-get install -y samba
```

## 3. Configuration File Migration

Create the new configuration directory and copy the default configuration file.

```bash
sudo mkdir -p /etc/calypso/conf/smb
sudo cp /etc/samba/smb.conf /etc/calypso/conf/smb/smb.conf
```

## 4. Systemd Service Configuration

Create override files for the `smbd` and `nmbd` services to point to the new configuration file location.

### 4.1. smbd Service

```bash
sudo mkdir -p /etc/systemd/system/smbd.service.d
sudo bash -c 'cat > /etc/systemd/system/smbd.service.d/override.conf <<EOF
[Service]
ExecStart=
ExecStart=/usr/sbin/smbd --foreground --no-process-group -s /etc/calypso/conf/smb/smb.conf $SMBDOPTIONS
EOF'
```

### 4.2. nmbd Service

```bash
sudo mkdir -p /etc/systemd/system/nmbd.service.d
sudo bash -c 'cat > /etc/systemd/system/nmbd.service.d/override.conf <<EOF
[Service]
ExecStart=
ExecStart=/usr/sbin/nmbd --foreground --no-process-group -s /etc/calypso/conf/smb/smb.conf $NMBDOPTIONS
EOF'
```

Reload the systemd daemon to apply the changes.

```bash
sudo systemctl daemon-reload
```

## 5. Starting and Verifying Services

Restart the Samba services and check their status to ensure they are using the new configuration file.

```bash
sudo systemctl restart smbd nmbd
sudo systemctl status smbd nmbd
```

You should see in the status output that the services are being started with the `-s /etc/calypso/conf/smb/smb.conf` option.
