# Install on Linux

On Linux, CrushMFT is a folder and a start script. There is no window: you make the first administrator on the command line, install the service with the script, and do everything else in the browser.

The same applies to BSD and other Unix systems where a current Java runs.

## 1. Java

Nothing to install, as long as the machine has `curl` or `wget` and can reach the internet: with no Java 21 or later on the machine, the start script downloads Eclipse Temurin into a folder `Java` in the CrushMFT folder, and CrushMFT keeps it up to date by itself ([CrushMFT's own Java](Java-Updates.md)).

A Java from your distribution or from a Java vendor works as well, and is then yours to keep current: 25 or later is recommended, 21 is the oldest the server starts on. Check:

```bash
java -version
```

Or unpack a Java into the CrushMFT folder as a folder named `Java`: the start script uses that one before the system's, and CrushMFT does not change a Java you put there.

## 2. Unpack

The start script expects the server in `/var/opt/CrushMFT27/`. Any other place works; then one line of the script names it.

```bash
unzip CrushMFT27.zip -d /var/opt/
```

## 3. Look at the start script

Open `crushmft_init.sh` in the folder. Its settings are at the top, each with a comment:

| Setting | Is | In the download |
|---|---|---|
| `CRUSH_DIR` | the CrushMFT folder | `/var/opt/CrushMFT27/` |
| `CRUSH_USER` | the account the server runs as | `root` |
| `JAVA` | `java` means: the `Java` folder inside the CrushMFT folder if there is one, else the system's; with neither, one is downloaded. Or a full path. | `java` |
| `JAVA_OPTS` | Java's options. The first is the most memory the server may use. | `-Xmx512m` and two more |
| `MAX_OPEN_FILES` | the most files and connections the server may have open | 16000 |
| `START_ARGS` | what to run: `-d` is the server; `-dmz 9000` a DMZ server | `-d` |
| `INIT_SYSTEM` | the kind of service: `auto`, `systemd`, `sysv` or `bsd` | `auto` |
| `STOP_WAIT` | seconds `stop` waits for the server to finish | 60 |

For a first look, change nothing. For a real server: raise the memory, and think about `CRUSH_USER`: see [The Linux service](Linux-Service.md).

## 4. Make the administrator

In the CrushMFT folder:

```bash
java -jar CrushMFT.jar -a "name" "password"
```

It answers with where the user was written. Choose a name of your own, not `admin` or `root`.

The password is now in your shell's history. Change it in the admin pages after the first login, or clear the line from the history.

## 5. Install and start

As root:

```bash
./crushmft_init.sh install
```

That makes the service, sets it to start with the machine, and starts the server. The script works out whether the system uses systemd or an older init system.

| Command | Does |
|---|---|
| `./crushmft_init.sh start` | starts the server. One that is running is stopped first. |
| `./crushmft_init.sh stop` | stops it |
| `./crushmft_init.sh restart` | both |
| `./crushmft_init.sh status` | says whether the server runs and whether the service is installed |
| `./crushmft_init.sh info` | shows the system, the Java it would use, and the settings |
| `./crushmft_init.sh uninstall` | stops the service and removes it |

Under systemd the service is named `crushmft`: `systemctl status crushmft` and `journalctl -u crushmft` work as for any service.

## 6. Log in

From a browser on another machine: `http://` the server's address `:8080/`, as the administrator. Go on with [First-run setup](First-Run-Setup.md).

If the page does not open, the machine's firewall is the usual reason: open the ports you offer with the tool of your distribution.

## Ports below 1024

Only root may open ports such as 21, 22 and 443. Two ways:

- run as root, as the download is set. Simple, and the server then has every right on the machine.
- run as another account, let the server listen on high ports, and redirect the low ones to them:

  ```bash
  iptables -t nat -A PREROUTING -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 8443
  ```

  with the tool your distribution uses to keep such rules.

## File names with accents

If names with accents or non-English letters come out as `?`, the script has a line for it: take the `#` off `export LC_ALL=en_US.UTF-8`.

## If it does not start

| What you see | Do |
|---|---|
| "No Java found" | the download of Java did not work (the lines above the message say why): install Java, or set `JAVA` in the script |
| "CrushMFT needs Java 21 or later" | the Java it found is too old |
| "This script needs the pgrep command" | install the package `procps` |
| "must be run as root" | `install`, and starting a server that runs as another account, need root |
| "could not allow … open files" | the system's own limit is lower than `MAX_OPEN_FILES`: raise the system's, or lower the setting |
| the script says FIPS mode could not start, exit code 78 | see [FIPS mode](FIPS-Mode.md) |
| it starts and no port answers | read the server's output: the journal under systemd, or `nohup.out` in the CrushMFT folder; and `CrushMFT.log` there |

## In a container

For Docker and Kubernetes there are ready images, with a wiki of their own: [Docker](../Docker/Main.md).

## Not tried for this page

The start script was not run for this page; what it does is read from the script. The test servers of this wiki were started on a Mac with a small script of their own.
