diff --git a/Makefile b/Makefile index 53ee92e1..f02b05b0 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,7 @@ run: -v "`pwd`/test/config":/tmp/docker-mailserver \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -v "`pwd`/test/onedir":/var/mail-state \ + -v "`pwd`/test/config/user-patches/user-patches.sh":/tmp/docker-mailserver/user-patches.sh \ -e ENABLE_CLAMAV=1 \ -e SPOOF_PROTECTION=1 \ -e ENABLE_SPAMASSASSIN=1 \ diff --git a/config/user-patches.sh.dist b/config/user-patches.sh.dist new file mode 100644 index 00000000..0e374662 --- /dev/null +++ b/config/user-patches.sh.dist @@ -0,0 +1,6 @@ +#!/bin/bash +## +# This user script will be executed between configuration and starting daemons +# To enable it you must save it in your config directory as "user-patches.sh" +## +echo "Default user-patches.sh successfully executed" diff --git a/target/start-mailserver.sh b/target/start-mailserver.sh index e0560530..405d88a0 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -174,7 +174,8 @@ function register_functions() { if [ "$LOGWATCH_TRIGGER" != "none" ]; then _register_setup_function "_setup_logwatch" fi - + + _register_setup_function "_setup_user_patches" # Compute last as the config files are modified in-place _register_setup_function "_setup_chksum_file" @@ -1491,6 +1492,18 @@ function _setup_logwatch() { esac } +function _setup_user_patches() { + notify 'inf' 'Executing user-patches.sh' + + if [ -f /tmp/docker-mailserver/user-patches.sh ]; then + chmod +x /tmp/docker-mailserver/user-patches.sh + /tmp/docker-mailserver/user-patches.sh + notify 'inf' "Executed 'config/user-patches.sh'" + else + notify 'inf' "No user patches executed because optional '/tmp/docker-mailserver/user-patches.sh' is not provided." + fi +} + function _setup_environment() { notify 'task' 'Setting up /etc/environment' diff --git a/test/config/user-patches/user-patches.sh b/test/config/user-patches/user-patches.sh new file mode 100644 index 00000000..2a315070 --- /dev/null +++ b/test/config/user-patches/user-patches.sh @@ -0,0 +1,6 @@ +#!/bin/bash +## +# This user script will be executed between configuration and starting daemons +# To enable it you must save it in your config directory as "user-patches.sh" +## +echo "Default user-patches.sh successfully executed" \ No newline at end of file diff --git a/test/tests.bats b/test/tests.bats index 4dd2241f..f73d37fe 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -27,6 +27,11 @@ function count_processed_changes() { # configuration checks # +@test "checking configuration: user-patches.sh executed" { + run echo -n "`docker logs mail | grep 'user\-patches\.sh'`" + assert_output --partial "Default user-patches.sh successfully executed" +} + @test "checking configuration: hostname/domainname" { run docker run `docker inspect --format '{{ .Config.Image }}' mail` assert_success