# Configuration

Everything you can set on a CrushMFT 27 container, and how. Most settings are made in CrushMFT's own admin pages, like on any server, and kept in the volume. This page is about what you set from outside: arguments, environment variables, Java options, and settings as files.

## At a glance

| What | How |
|---|---|
| The first admin's name and password | `CRUSHFTP_ADMIN_USERNAME`, `CRUSHFTP_ADMIN_PASSWORD_FILE`, `CRUSHFTP_ADMIN_PASSWORD`, `PASSFILE` ([below](#the-first-admin)) |
| Java memory and options | `JDK_JAVA_OPTIONS` ([below](#java-memory-and-options)) |
| Time zone | `TZ` |
| Any server setting, from outside | files in `split_prefs/` in the volume ([below](#settings-as-files-split_prefs)) |
| The licence | three `split_prefs` files, or the admin pages |
| Ports | the admin pages (Preferences, IP / Servers), or `split_prefs/_server_list.xml` |
| CrushMFT's updater on or off | two `split_prefs` files ([Updates and versions](Updates-and-Versions.md#turning-the-updater-off)) |
| Logging to the container's output | on by default ([Health, logs and monitoring](Health-Logs-Monitoring.md#logs)) |
| Health check address | `CRUSHFTP_HEALTH_URL` |

## Environment variables

| Variable | Default | What it does |
|---|---|---|
| `CRUSHFTP_ADMIN_USERNAME` | `crushadmin` | the name of the first admin, when the container is started without arguments of its own |
| `CRUSHFTP_ADMIN_PASSWORD_FILE` | none | a file holding the first admin's password. Comes first. |
| `CRUSHFTP_ADMIN_PASSWORD` | none | the first admin's password itself |
| `PASSFILE` | `/app/CrushMFT27/passfile` | where a given password is looked for, and where a random one is written |
| `TZ` | UTC | the time zone of the log and of schedules, e.g. `Europe/Berlin`, `America/New_York` |
| `JDK_JAVA_OPTIONS` | none | extra Java options for every Java process in the container ([below](#java-memory-and-options)) |
| `CRUSHFTP_HEALTH_URL` | `http://127.0.0.1:8080/WebInterface/api/readyz` | what the `-health` command asks ([Health, logs and monitoring](Health-Logs-Monitoring.md#health-checks)) |
| `CRUSHFTP_FIPS_PREPARE` | on | `-fips` images only: `false` stops the image from preparing the volume for FIPS mode ([Images and tags](Images.md#fips-140-3-mode)) |
| `LANG`, `LC_ALL` | `C.UTF-8` | leave them: they make file names with accents and other scripts come out exactly |

The admin variables are read only when the admin user is created, on the very first start of a new volume. Later changes to them change nothing.

## The first admin

The image's default arguments are `-ad crushadmin`: create the admin user `crushadmin` if there is none yet. Its password comes from, in this order:

1. the file `CRUSHFTP_ADMIN_PASSWORD_FILE` names,
2. `CRUSHFTP_ADMIN_PASSWORD`,
3. the file `PASSFILE` names (default `/app/CrushMFT27/passfile`), if it is there and not empty,
4. otherwise 20 random characters, written to `PASSFILE` and printed once in the log.

The safest way is a secret file:

```
docker run -d --name crushmft27 -p 8080:8080 \
  -v crushmft27:/app/CrushMFT27 \
  -v /srv/crushmft27-secrets:/run/secrets:ro \
  -e CRUSHFTP_ADMIN_PASSWORD_FILE=/run/secrets/admin \
  crushftp/crushmft27:latest
```

with the password as the only content of `/srv/crushmft27-secrets/admin` (a trailing line break is ignored), readable by uid 65532 (`chmod 644`, or owned by 65532). A file that is missing, empty or not readable stops the start with exit code 1 and says why. In Compose, use `secrets:` ([Docker Compose](Docker-Compose.md)); in Kubernetes the chart does it with a Secret.

Another admin name: `-e CRUSHFTP_ADMIN_USERNAME=admin`, or give the arguments yourself: `... crushftp/crushmft27:latest -ad admin`. With a password as the third argument (`-ad admin MyPassword`) that password is used as you wrote it; avoid this, as it shows in `docker inspect` and the process list.

## Arguments

Whatever follows the image name replaces the default `-ad crushadmin` and goes to CrushMFT. The ones that make sense in a container:

| Arguments | What they do |
|---|---|
| `-ad <name>` | start the server; create the admin `<name>` on the first start (the default) |
| `-ad <name> <password>` | the same, with that password |
| `-d` | start the server, create no admin |
| `-A <name> <password>` | write the admin user `<name>` with that password, then exit. For resetting a lost password, with the server stopped ([Operations](Operations.md#reset-the-admin-password)). |
| `-FIPS_CHECK`, `-FIPS_PREPARE` | `-fips` images: the readiness report and the preparation for FIPS mode, run in a Java process without the launch parameter, as they have to be ([FIPS 140-3 mode](../CrushMFT27/FIPS-Mode.md)) |

## Java memory and options

The server's Java heap is **50 % of the container's memory limit** (`-XX:MaxRAMPercentage=50`). The other half is for Java itself and for CrushMFT's job engine and its runners, which are separate Java processes in the same container. Without a memory limit, the 50 % are of the machine's memory.

| Memory limit | Server heap | Good for |
|---|---|---|
| 1 GB | 512 MB | trying it, a few users |
| 2 GB | 1 GB | most servers, with jobs |
| 4 GB and more | half of it | many users, many or large jobs |

Set the limit with `--memory 2g` (Docker), `mem_limit: 2g` (Compose), or `resources.limits.memory` (Kubernetes).

For a fixed heap, or any other Java option, use `JDK_JAVA_OPTIONS`:

```
-e JDK_JAVA_OPTIONS="-Xmx3g"
-e JDK_JAVA_OPTIONS="-Xmx3g -Dcrushmft.container.console=false"
```

`-Xmx` wins over the percentage. Java prints `NOTE: Picked up JDK_JAVA_OPTIONS: ...` at each start when the variable is set; that is normal. The variable reaches every Java process in the container, the job engine's too. The system properties CrushMFT's documentation mentions (`-D...`) go the same way.

## Settings as files: split_prefs

Any server setting can be set from outside by a file in the folder `split_prefs/` of the working folder (`/app/CrushMFT27/split_prefs/`). CrushMFT reads these files at every start, from the very first one, and their values win over what is in `prefs.XML`. This is how you configure a container without the admin pages, and how the Kubernetes chart sets the licence and the updater.

| File | Sets |
|---|---|
| `_<setting>.txt` | a setting with a single value; the file's content (trimmed) is the value |
| `_<setting>.xml` | a setting that is a list or a group, in the XML form `prefs.XML` has it |
| `server_list_<setting>.txt` | that setting on **every** port of the server list |

`<setting>` is the name of the setting as it appears in `prefs.XML` (the element's name). Only settings that exist there are taken; a file with a misspelled name is ignored. Each file that is used shows in the log: `SPLIT_PREFS:Using log_debug_level value from .../split_prefs/_log_debug_level.txt with value 2`.

Examples:

| File | Content | Effect |
|---|---|---|
| `_log_debug_level.txt` | `2` | log level 2 (0 normal, 1 debug, 2 verbose) |
| `_registration_name.txt` | `Example%20Corp` | the licence name, URL-encoded (a space is `%20`) |
| `_registration_email.txt` | `it@example.com` | the licence e-mail |
| `_registration_code.txt` | the code | the licence code |
| `_daily_check_and_auto_update_on_idle.txt` and `_daily_check_and_auto_update_on_idle_all_builds.txt` | `false` | CrushMFT's updater off |
| `_server_list.xml` | the `<server_list>` element | the whole list of ports |

**The port list as a file.** Set the ports up once in the admin pages (Preferences, IP / Servers), then copy the `<server_list type="vector">...</server_list>` element out of `prefs.XML` into `split_prefs/_server_list.xml`. From then on every start uses that list.

**A setting that comes from a file belongs to the file.** When you change such a setting in the admin pages, CrushMFT writes the new value back into the file if it can. If the folder is read-only (a Kubernetes ConfigMap), the write is refused and the file's value comes back at the next start. Change it in the file.

To put files there in Docker, mount a folder over it, read-only if you like:

```
-v /srv/crushmft27-split_prefs:/app/CrushMFT27/split_prefs:ro
```

or copy them into the volume with the `-dev` image (`docker cp` works too). `-Dcrushmft.split_prefs=false` in `JDK_JAVA_OPTIONS` turns the whole mechanism off.

## What you configure in the admin pages

Everything else: users and groups, folders and storage, ports, HTTPS certificates, sign-in methods, jobs, alerts, reports. It is kept in the volume like on any CrushMFT server; see the [CrushMFT 27 documentation](../CrushMFT27/Main.md).
