initial commit

This commit is contained in:
2025-10-26 14:41:49 +00:00
commit e548aec9f8
4 changed files with 200 additions and 0 deletions

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2025 Allan Christensen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

67
README.md Normal file
View File

@@ -0,0 +1,67 @@
# Postfix for Ubuntu 24.04 Server
[![OS](https://img.shields.io/badge/ubuntu-24.04-E95420)](#)
[![Shell](https://img.shields.io/badge/shell-bash-121011)](#)
[![MailServer](https://img.shields.io/badge/server-postfix-8B1E3F)](#)
[![License](https://img.shields.io/badge/License-MIT-green)](./LICENSE)
Automated Bash installer for deploying **Postfix** non-interactively on Ubuntu 24.04 Server — ideal when you just need a working mail server and dont want a screen full of configuration prompts. The script comes with an optional Mailutils installation flag.
This is a **production-focused installer**, not a demo.
---
### Preparing
Update your package index before running the installer:
```
sudo apt update -y
```
---
### Download the Script
Clone the repository from your Git server:
```
git clone https://git.x-files.dk/mail/postfix-ubuntu.git
```
```
cd postfix-ubuntu
```
### Usage
Run the script using the `-m` flag to control whether Mailutils will be installed as well (`yes` or `no`).
```
sudo ./postfixinstall -m <yes|no>
```
### Example
Install Postfix **with** Mailutils:
```
sudo ./postfixinstall -m yes
```
Install Postfix **only**:
```
sudo ./postfixinstall -m no
```
---
### More Information
More guides and documentation can be found on [wiki.x-files.dk](https://wiki.x-files.dk)
---
### License
Licensed under the [MIT License](./LICENSE).

4
last-tested Normal file
View File

@@ -0,0 +1,4 @@
------------------------------------
Last tested: 26-10-2025 (DD-MM-YYYY)
Environment: Ubuntu Server 24.04 LTS
------------------------------------

108
postfixinstall Executable file
View File

@@ -0,0 +1,108 @@
#!/usr/bin/env bash
# Author : Allan Christensen
# First Created : 17102020 (DD-MM-YYYY)
# Description : Installs Postfix and optionally Mailutils on Ubuntu 24.04
# License : MIT License (see LICENSE file for details)
#
# Are we root
#
if [[ $(id -u) -ne 0 ]]; then echo "" && echo "Must be root or use sudo" && echo "" ; exit ; fi
#
# Define variables and functions
#
install_utils="no"
#
# Function to check if a service is already running or not
#
serviceyes () { printf "\n%s" $service ; printf " is already running cannot continue...\n\n"; }
servicealive () { status=$(systemctl is-active $service); if [[ "$status" == "active" ]]; then serviceyes ; exit 1; fi; }
#
# Usage function
#
usage() {
printf "\nUsage:\n"
printf " sudo ./postfixinstall [-m yes|no]\n\n"
printf "Options:\n"
printf " -m <yes|no> Install Mailutils (defaults to no)\n"
printf " -h Show this help message\n\n"
printf "Examples:\n"
printf " sudo ./postfixinstall # install Postfix only\n"
printf " sudo ./postfixinstall -m yes # install Postfix + Mailutils\n\n"
exit 1
}
#
# If Postfix is already running then die
#
service="postfix" ; servicealive
#
# Let's go
#
clear
#
# Parse options
#
while getopts ":m:h" opt; do
case "${opt}" in
m)
arg="${OPTARG}"
if [[ -z "$arg" ]]; then
printf "\nOption -m requires an argument (yes/no).\n"
usage
fi
case "${arg,,}" in
y|yes) install_utils="yes" ;;
n|no) install_utils="no" ;;
*) usage ;;
esac
;;
h)
usage
;;
:)
printf "\nOption -%s requires an argument (yes/no).\n" "$OPTARG"
usage
;;
\?)
printf "\nInvalid option: -%s\n" "$OPTARG"
usage
;;
esac
done
#
# Require -m flag
#
if [[ "$OPTIND" -eq 1 ]]; then
printf "\nMissing required option: -m <yes|no>\n"
usage
fi
#
# Install Postfix (non-interactive) and backup main.cf
#
printf "\nInstalling Postfix...\n"
DEBIAN_FRONTEND=noninteractive apt-get install -y postfix >/dev/null 2>&1
[[ -f /etc/postfix/main.cf ]] && cp -p /etc/postfix/main.cf /etc/postfix/main.cf.bak.$(date +%d-%m-%Y-%H%M%S)
systemctl enable postfix >/dev/null 2>&1 && systemctl restart postfix
#
# Optionally install Mailutils
#
if [[ "$install_utils" == "yes" ]]; then apt-get install -y mailutils >/dev/null 2>&1 ; fi
#
# All done
#
printf "\nAll Done...\n"
#
# End of script
#