mirror of
https://github.com/foxcpp/maddy.git
synced 2025-04-04 13:37:41 +03:00
Add get.sh script for semi-automated installation
Given amount of steps actually needed to install maddy, it makes sense to automate at least some of them. Also, since maddy repo is replicated on foxcpp.dev/maddy, it can be used like this: curl https://foxcpp.dev/maddy/get.sh | bash That's, of course, is a partial solution. In future, package repository least for Debian will be created with properly built packages. Response to possible complaints about curl|bash: There is not that much difference between that and cloning repo to run 'make install'. People who care can inspect the script either way and ones who don't care... well, don't care.
This commit is contained in:
parent
ccb9c9df4c
commit
9c8ef4a2ae
3 changed files with 99 additions and 11 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -34,3 +34,5 @@ cmd/maddy-*-helper/maddy-*-helper
|
|||
# in repo directory.
|
||||
cmd/maddy/*mtasts-cache
|
||||
cmd/maddy/*queue
|
||||
|
||||
maddy-setup/
|
||||
|
|
19
README.md
19
README.md
|
@ -53,15 +53,13 @@ Planned:
|
|||
- Server-side messages encryption (#75)
|
||||
- [JMAP](https://jmap.io) (#19)
|
||||
|
||||
## Installation
|
||||
## Installation & configuration
|
||||
|
||||
Pre-built binaries for releases are available
|
||||
[here](https://github.com/foxcpp/maddy/releases).
|
||||
Detailed explaination of what you need to do to get it running can be found
|
||||
here:
|
||||
https://github.com/foxcpp/maddy/wiki/Tutorial:-Setting-up-a-mail-server-with-maddy
|
||||
|
||||
## Building from source
|
||||
|
||||
Make sure you have $GOPATH/bin ($HOME/go/bin) in your $PATH before
|
||||
doing anything.
|
||||
### Manual installation
|
||||
|
||||
#### Dependencies
|
||||
|
||||
|
@ -80,7 +78,7 @@ doing anything.
|
|||
Required for SQLite3-based storage (default configuration) and PAM
|
||||
authentication.
|
||||
|
||||
### Building
|
||||
#### Building
|
||||
|
||||
First, make sure Go Modules support is enabled:
|
||||
```
|
||||
|
@ -96,11 +94,10 @@ go get github.com/foxcpp/maddy/cmd/{maddy,maddyctl}@master
|
|||
Executables will be placed in the $GOPATH/bin directory (defaults to
|
||||
$HOME/go/bin).
|
||||
|
||||
## Quick start
|
||||
#### Quick start
|
||||
|
||||
*Note*: explaination below is short and assumes that you already have
|
||||
basic ideas about how email works. If you are not sure, Project Wiki
|
||||
contains a [more detailed tutorial](https://github.com/foxcpp/maddy/wiki/Setting-up-a-mail-server-with-maddy).
|
||||
basic ideas about how email works.
|
||||
|
||||
1. Install maddy and maddyctl (see above)
|
||||
2. Copy maddy.conf from this repo to /etc/maddy/maddy.conf
|
||||
|
|
89
get.sh
Executable file
89
get.sh
Executable file
|
@ -0,0 +1,89 @@
|
|||
#!/bin/sh
|
||||
set -euo pipefail
|
||||
IFS=$'\n'
|
||||
|
||||
GOVERSION=1.13.1
|
||||
MADDYVERSION=master
|
||||
PREFIX=/usr/local
|
||||
SYSTEMDUNITS=/etc/systemd
|
||||
CONFPATH=/etc/maddy/maddy.conf
|
||||
|
||||
mkdir -p maddy-setup/
|
||||
cd maddy-setup/
|
||||
|
||||
if ! which go >/dev/null; then
|
||||
download=1
|
||||
else
|
||||
if [ "`go version | grep -o "go$GOVERSION"`" = "go$GOVERSION" ]; then
|
||||
echo "Using system Go toolchain." >&2
|
||||
download=0
|
||||
GO=`which go`
|
||||
else
|
||||
download=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $download -eq 1 ]; then
|
||||
echo "Downloading Go $GOVERSION toolchain..." >&2
|
||||
if ! [ -e go$GOVERSION ]; then
|
||||
if ! [ -e go$GOVERSION.linux-amd64.tar.gz ]; then
|
||||
wget -q 'https://dl.google.com/go/go1.13.3.linux-amd64.tar.gz'
|
||||
fi
|
||||
tar xf go$GOVERSION.linux-amd64.tar.gz
|
||||
mv go go$GOVERSION
|
||||
fi
|
||||
GO=go$GOVERSION/bin/go
|
||||
fi
|
||||
|
||||
export GOPATH="$PWD/gopath"
|
||||
export GOBIN="$GOPATH/bin"
|
||||
|
||||
echo 'Downloading and compiling maddy...' >&2
|
||||
|
||||
export GO111MODULE=on
|
||||
$GO get github.com/foxcpp/maddy/cmd/{maddy,maddyctl}@$MADDYVERSION
|
||||
|
||||
echo 'Installing maddy...' >&2
|
||||
|
||||
sudo mkdir -p "$PREFIX/bin"
|
||||
sudo cp "$GOPATH/bin/maddy" "$GOPATH/bin/maddyctl" "$PREFIX/bin/"
|
||||
|
||||
echo 'Downloading and installing systemd unit files...' >&2
|
||||
|
||||
wget -q "https://raw.githubusercontent.com/foxcpp/maddy/$MADDYVERSION/dist/systemd/maddy.service" -O maddy.service
|
||||
wget -q "https://raw.githubusercontent.com/foxcpp/maddy/$MADDYVERSION/dist/systemd/maddy@.service" -O maddy@.service
|
||||
|
||||
sed -Ei "s!/usr/bin!$PREFIX/bin!g" maddy.service maddy@.service
|
||||
|
||||
sudo cp maddy.service maddy@.service "$SYSTEMDUNITS/system/"
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
echo 'Creating maddy user and group...' >&2
|
||||
|
||||
sudo useradd -UMr -s /sbin/nologin maddy || true
|
||||
|
||||
if ! [ -e "$CONFPATH" ]; then
|
||||
echo 'Downloading and installing default configuration...' >&2
|
||||
|
||||
wget -q "https://raw.githubusercontent.com/foxcpp/maddy/$MADDYVERSION/maddy.conf" -O maddy.conf
|
||||
sudo mkdir -p /etc/maddy/
|
||||
|
||||
host=`hostname`
|
||||
read -p "What's your domain, btw? [$host] > " DOMAIN
|
||||
if [ "$DOMAIN" = "" ]; then
|
||||
DOMAIN=$host
|
||||
fi
|
||||
echo 'Good, I will put that into configuration for you.' >&2
|
||||
|
||||
sed -Ei "s/^\\$\\(primary_domain\) = .+$/$\(primary_domain\) = $DOMAIN/" maddy.conf
|
||||
sed -Ei "s/^\\$\\(hostname\) = .+$/$\(hostname\) = $DOMAIN/" maddy.conf
|
||||
|
||||
sudo cp maddy.conf /etc/maddy/
|
||||
else
|
||||
echo "Configuration already exists in /etc/maddy/maddy.conf, skipping defaults installation." >&2
|
||||
fi
|
||||
|
||||
echo "Okay, almost ready." >&2
|
||||
echo "It's up to you to figure out TLS certificates and DNS stuff, though." >&2
|
||||
echo "Here is the tutorial to help you:" >&2
|
||||
echo "https://github.com/foxcpp/maddy/wiki/Tutorial:-Setting-up-a-mail-server-with-maddy" >&2
|
Loading…
Add table
Add a link
Reference in a new issue