Skip to content

Commit

Permalink
Merge branch 'master' into ubuntu
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson authored Aug 26, 2024
2 parents fe14797 + 7bc4458 commit f6d1eb4
Show file tree
Hide file tree
Showing 98 changed files with 3,562 additions and 1,898 deletions.
44 changes: 42 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,54 @@
name: CI Tests

on: [ push, pull_request ]
on:
push:
pull_request:

jobs:
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
env:
SHELLCHECK_OPTS: -s bash -e SC1004,SC1091,SC2009,SC2016,SC2039,SC2086,SC2119,SC2153

bats:
name: Bats
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: Setup Bats
run: git submodule update --init --recursive
- name: bats test
run: |
./test/bats/bin/bats test/*.bats
./test/bats/bin/bats test/include/*.bats
freebsd:
if: false
runs-on: ubuntu-latest
name: FreeBSD
env:
MYTOKEN : ${{ secrets.MYTOKEN }}
MYTOKEN2: "value2"
steps:
- uses: actions/checkout@v4
- name: Test in FreeBSD
id: test
uses: vmactions/freebsd-vm@v1
with:
envs: 'MYTOKEN MYTOKEN2'
usesh: true
prepare: |
pkg install -y curl
run: |
pwd
ls -lah
whoami
env
freebsd-version
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ node_modules
*.tar.gz
*.txt
*.php
*.mt6
14 changes: 11 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
image: auchida/freebsd:latest
#timeout: 80

# Instructions for creating your own test runner:
# https://github.com/msimerson/Mail-Toaster-6/wiki/Develop-CI-Testing/
Expand All @@ -20,6 +19,7 @@ stages:

host_setup:
stage: host_setup
timeout: 10 minutes
script:
- sh test/get_jail_ip.sh
- echo "export TOASTER_HOSTNAME=`hostname`" >> mail-toaster.conf
Expand All @@ -33,25 +33,29 @@ host_setup:

dns:
stage: dns
timeout: 5 minutes
script:
- sh provision/dns.sh
# enabling caching doubles gitlab runner builds (~30 to 60m)
- sh provision/bsd_cache.sh
# - sh provision/bsd_cache.sh
tags:
- freebsd
- ssh

db:
stage: db
timeout: 5 minutes
script:
- sh provision/mysql.sh
- sh provision/redis.sh
# - sh provision/geoip.sh
tags:
- freebsd
- ssh

mailstore:
stage: mailstore
timeout: 15 minutes
script:
- sh provision/vpopmail.sh
- sh provision/dovecot.sh
Expand All @@ -61,6 +65,7 @@ mailstore:

mta:
stage: mta
timeout: 15 minutes
script:
- sh provision/clamav.sh
- sh provision/dcc.sh
Expand All @@ -72,18 +77,20 @@ mta:

webmail:
stage: webmail
timeout: 15 minutes
script:
- sh provision/haproxy.sh
- sh provision/webmail.sh
- sh provision/roundcube.sh
- sh provision/snappymail.sh
- sh provision/squirrelmail.sh
# - sh provision/squirrelmail.sh
tags:
- freebsd
- ssh

extras:
stage: extras
timeout: 10 minutes
script:
- sh provision/spamassassin.sh
# - sh provision/elasticsearch.sh
Expand All @@ -94,6 +101,7 @@ extras:

test:
stage: test
timeout: 5 minutes
script:
- sh provision/mailtest.sh
tags:
Expand Down
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "test/bats"]
path = test/bats
url = https://github.com/bats-core/bats-core.git
[submodule "test/test_helper/bats-support"]
path = test/test_helper/bats-support
url = https://github.com/bats-core/bats-support.git
[submodule "test/test_helper/bats-assert"]
path = test/test_helper/bats-assert
url = https://github.com/bats-core/bats-assert.git
2 changes: 1 addition & 1 deletion .shellcheckrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
disable=SC1004,SC1091,SC2009,SC2016,SC2039,SC2086,SC2119,SC2120,SC2153,SC2154,SC3033,SC3043
disable=1004,1091,2009,2016,2039,2086,2119,2120,2153,2154,3033,3037,3043
41 changes: 41 additions & 0 deletions contrib/exorcise_maildrop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh

# shellcheck disable=SC2044
for _f in $(find /data/vpopmail/ -type f -name .qmail); do

# ignore files that don't specify maildrop
if ! grep -q maildrop "$_f"; then continue; fi

_lines=$(wc -l < "$_f" | bc)
if [ "$_lines" = 1 ]; then
# files with only a mailfilter rule can be deleted
echo "$_lines: rm $_f"
rm "$_f"
continue
fi

# multiple delivery rules are in the file (see 'man dot-qmail')

# extract all that isn't a maildrop invocation
_contents=$(grep -v maildrop "$_f")

# replace the maildrop rule with fully qualified path to Maildir
_maildir="$(dirname "$_f" | sed -e 's|/data/vpopmail/home|/usr/local/vpopmail|')/Maildir/"

echo "$_lines"
echo "$_f"
echo

#echo "$_contents"
#echo

# write a new .qmail with the FQ Maildir + other delivery rules
echo "$_contents" > "$_f.new" || exit 1
echo "$_maildir" >> "$_f.new" || exit 1
chown 89:89 "$_f.new" || exit 1
chmod 600 "$_f.new" || exit 1

# atomically replace the existing .qmail
#echo "mv $_f.new $_f"
#mv "$_f.new" "$_f"
done
41 changes: 41 additions & 0 deletions contrib/pfrule.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh

# pfrule.sh
#
# Use pfctl to load and unload PF config files into named PF anchors.
# Config files are named for the anchor they'll be inserted
# at. See https://github.com/msimerson/Mail-Toaster-6/wiki/PF
#
# Matt Simerson, matt@tnpi.net, 2023-06

_etcpath="$(dirname -- "$( readlink -f -- "$0"; )";)"

usage() {
echo " usage: $0 [ load | unload ]"
echo " "
exit 1
}

for _f in "$_etcpath"/*.conf; do
[ -f "$_f" ] || continue

_anchor=$(basename $_f .conf) # nat, rdr, allow
_jailname=$(basename "$(dirname "$(dirname $_etcpath)")")

case "$1" in
"load" )
_cmd="pfctl -a $_anchor/$_jailname -f $_f"
;;
"unload" )
_cmd="pfctl -a $_anchor/$_jailname -F all"
;;
*)
usage
;;
esac

echo "$_cmd"
$_cmd || exit 1
done

exit
Loading

0 comments on commit f6d1eb4

Please sign in to comment.