diff --git a/CHANGELOG.md b/CHANGELOG.md index 300fffae..6071c8e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. This projec If you are upgrading from v0.16.x, replace the binary (or run `docker pull`). If you are upgrading from v0.15.x and below, please read the [upgrading documentation](https://github.com/stalwartlabs/stalwart/blob/main/UPGRADING/v0_16.md) for more information on how to upgrade from previous versions. ## Added +- FreeBSD support (x86_64 only for now): release binaries, installer support with rc.d service, and hier(7)-compliant default paths (`/usr/local/etc/stalwart`, `/var/db/stalwart`). ## Changed diff --git a/README.md b/README.md index b8491e93..1a21c613 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,7 @@ Key features: Install Stalwart on your server by following the instructions for your platform: -- [Linux / MacOS](https://stalw.art/docs/install/platform/linux) +- [Linux / MacOS / FreeBSD](https://stalw.art/docs/install/platform/linux) - [Windows](https://stalw.art/docs/install/platform/windows) - [Docker](https://stalw.art/docs/install/platform/docker) diff --git a/crates/jmap/src/registry/mapping/bootstrap.rs b/crates/jmap/src/registry/mapping/bootstrap.rs index 6264522e..283a7e2c 100644 --- a/crates/jmap/src/registry/mapping/bootstrap.rs +++ b/crates/jmap/src/registry/mapping/bootstrap.rs @@ -651,6 +651,14 @@ fn map_dns_server(dns_server: &DnsServerBootstrap) -> Option Bootstrap { let server_hostname = server.registry().local_hostname().to_string(); let default_domain = psl::domain_str(&server_hostname) @@ -659,7 +667,7 @@ fn build_default_bootstrap(server: &Server) -> Bootstrap { Bootstrap { data_store: DataStore::RocksDb(RocksDbStore { - path: "/var/lib/stalwart/".to_string(), + path: DEFAULT_DATA_PATH.to_string(), ..Default::default() }), blob_store: BlobStore::Default, diff --git a/install.sh b/install.sh index bb518080..a270b7b0 100644 --- a/install.sh +++ b/install.sh @@ -34,11 +34,11 @@ main() { # Detect OS local _os _uname _account _uname="$(uname)" - _account="stalwart" case "$_uname" in - Linux) _os="linux" ;; - Darwin) _os="macos"; _account="_stalwart" ;; - *) err "❌ Install failed: Unsupported OS: $_uname" ;; + Linux) _os="linux"; _account="stalwart" ;; + Darwin) _os="macos"; _account="_stalwart" ;; + FreeBSD) _os="freebsd"; _account="stalwart" ;; + *) err "❌ Install failed: Unsupported OS: $_uname" ;; esac # Parse arguments @@ -70,9 +70,16 @@ main() { local _bin_dir _bin_file _conf_dir _log_dir _data_dir _env_file _config_file if [ -z "$_prefix" ]; then _bin_dir="/usr/local/bin" - _conf_dir="/etc/stalwart" _log_dir="/var/log/stalwart" - _data_dir="/var/lib/stalwart" + if [ "$_os" = "freebsd" ]; then + # hier(7): third-party config lives under /usr/local/etc, + # variable data under /var/db + _conf_dir="/usr/local/etc/stalwart" + _data_dir="/var/db/stalwart" + else + _conf_dir="/etc/stalwart" + _data_dir="/var/lib/stalwart" + fi else _bin_dir="${_prefix}/bin" _conf_dir="${_prefix}/etc" @@ -139,6 +146,10 @@ main() { create_service_macos "$_bin_file" "$_config_file" "$_env_file" "$_account" _service_type="launchd" ;; + freebsd) + create_service_freebsd "$_bin_file" "$_config_file" "$_env_file" "$_account" "$_log_dir" + _service_type="rcd" + ;; esac # Completion message @@ -162,6 +173,9 @@ main() { launchd) say " sudo log show --predicate 'process == \"stalwart\"' --last 5m" ;; + rcd) + say " grep -A8 'bootstrap mode' ${_log_dir}/stalwart.log" + ;; esac say "" say " Or set STALWART_RECOVERY_ADMIN=admin: in" @@ -190,6 +204,11 @@ With no PREFIX, Stalwart is installed under standard FHS paths: logs /var/log/stalwart/ data /var/lib/stalwart/ +On FreeBSD, config and data follow hier(7) instead: + config /usr/local/etc/stalwart/config.json + env /usr/local/etc/stalwart/stalwart.env + data /var/db/stalwart/ + When PREFIX is provided, a self-contained layout is used instead: binary $PREFIX/bin/stalwart config $PREFIX/etc/config.json @@ -265,6 +284,8 @@ create_account() { ensure dscl /Local/Default -delete /Users/_stalwart AuthenticationAuthority ensure dscl /Local/Default -delete /Users/_stalwart PasswordPolicyOptions + elif [ "$_os" = "freebsd" ]; then + ensure pw useradd -n "$_account" -c "Stalwart service" -d /nonexistent -s /usr/sbin/nologin -w no else ensure useradd "$_account" -s /usr/sbin/nologin -M -r -U fi @@ -451,6 +472,60 @@ EOF launchctl enable system/stalwart } +create_service_freebsd() { + local _bin="$1" _config="$2" _env="$3" _user="$4" _log_dir="$5" + ensure mkdir -p /usr/local/etc/rc.d + cat > /usr/local/etc/rc.d/stalwart < /dev/null 2>&1 || true + service stalwart start +} + get_architecture() { local _ostype _cputype _bitness _arch _clibtype