diff --git a/lib/function.sh b/lib/function.sh index 14f7345..fae6eb3 100644 --- a/lib/function.sh +++ b/lib/function.sh @@ -100,7 +100,6 @@ debmaker_run(){ } debmaker_debootstrapUpdate(){ - zdebmaker_getDep [ -d ${DEBOOTSTRAP_DIR} ] || mkdir ${DEBOOTSTRAP_DIR} URL=https://salsa.debian.org/installer-team/debootstrap/-/archive/master/debootstrap-master.tar.gz FILES="debootstrap-master/debootstrap debootstrap-master/scripts/ debootstrap-master/functions" diff --git a/ressources/mailhog/debmaker b/ressources/mailhog/debmaker new file mode 100755 index 0000000..0b00fc9 --- /dev/null +++ b/ressources/mailhog/debmaker @@ -0,0 +1,40 @@ +#!/bin/bash + +VERSION=1.1.0 + +[ -e ./lib/function.sh ] && source ./lib/function.sh + +APP=mailhog +DEPOT=https://github.com/mailhog/MailHog.git +GIT_VERSION=v$VERSION-beta1 +DEB_VERSION=$VERSION-$(date +%Y%m%d%H%M) +DEBIAN_VERSION_CODENAME=bullseye +IMAGE_SIZE=2 + +STEP="envinit prebuild build makedeb" + +envinit() { + apt-get update + apt-get dist-upgrade -y + apt install -y --no-install-recommends build-essential git wget ca-certificates dpkg fakeroot + wget -qO - https://go.dev/dl/go1.18.linux-amd64.tar.gz | tar -C /usr/local -xz +} + +prebuild(){ + [ -e /tmp/${APP} ] && rm -fr /tmp/${APP} + git clone --depth 1 -b ${GIT_VERSION} ${DEPOT} /tmp/${APP} +} + +build() { + cd /tmp/${APP} + PATH=$PATH:/usr/local/go/bin + go build -o mailhog main.go +} + +makedeb(){ + PATH_DEB=/tmp/src/rootfs + + cp /tmp/${APP}/mailhog ${PATH_DEB}/usr/bin/mailhog + sed -i "s/%VERSION%/$DEB_VERSION/" ${PATH_DEB}/DEBIAN/control + fakeroot dpkg-deb -Z gzip --build ${PATH_DEB} /tmp/dist +} diff --git a/ressources/mailhog/rootfs/DEBIAN/changelog b/ressources/mailhog/rootfs/DEBIAN/changelog new file mode 100644 index 0000000..e69de29 diff --git a/ressources/mailhog/rootfs/DEBIAN/conffiles b/ressources/mailhog/rootfs/DEBIAN/conffiles new file mode 100644 index 0000000..2e79f83 --- /dev/null +++ b/ressources/mailhog/rootfs/DEBIAN/conffiles @@ -0,0 +1 @@ +/etc/default/mailhog diff --git a/ressources/mailhog/rootfs/DEBIAN/control b/ressources/mailhog/rootfs/DEBIAN/control new file mode 100644 index 0000000..3f6e10c --- /dev/null +++ b/ressources/mailhog/rootfs/DEBIAN/control @@ -0,0 +1,7 @@ +Package: mailhog +Version: %VERSION% +Section: base +Priority: optional +Architecture: all +Maintainer: Thomas Legay +Description: mailhog diff --git a/ressources/mailhog/rootfs/DEBIAN/postinst b/ressources/mailhog/rootfs/DEBIAN/postinst new file mode 100755 index 0000000..ab2705c --- /dev/null +++ b/ressources/mailhog/rootfs/DEBIAN/postinst @@ -0,0 +1,4 @@ +#!/bin/bash + +id mailhog &> /dev/null || useradd mailhog -r -s /bin/false -d / + diff --git a/ressources/mailhog/rootfs/etc/default/mailhog b/ressources/mailhog/rootfs/etc/default/mailhog new file mode 100644 index 0000000..e6dbf05 --- /dev/null +++ b/ressources/mailhog/rootfs/etc/default/mailhog @@ -0,0 +1,4 @@ +MH_AUTH_FILE=/etc/mailhog/passwd +MH_API_BIND_ADDR=127.0.0.1:8025 +MH_UI_BIND_ADDR=127.0.0.1:8025 +MH_SMTP_BIND_ADDR=172.16.1.247:1025 diff --git a/ressources/mailhog/rootfs/etc/mailhog/passwd b/ressources/mailhog/rootfs/etc/mailhog/passwd new file mode 100644 index 0000000..fc8bb70 --- /dev/null +++ b/ressources/mailhog/rootfs/etc/mailhog/passwd @@ -0,0 +1 @@ +email-lanvin:$2y$10$vc.G.PfDFg/OCkvPif6/Q.ObkdNXnxAh5MfqCoHd/jVUEjKh/5Fxu diff --git a/ressources/mailhog/rootfs/usr/bin/.gitkeep b/ressources/mailhog/rootfs/usr/bin/.gitkeep new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/ressources/mailhog/rootfs/usr/bin/.gitkeep @@ -0,0 +1 @@ + diff --git a/ressources/mailhog/rootfs/usr/lib/systemd/system/mailhog.service b/ressources/mailhog/rootfs/usr/lib/systemd/system/mailhog.service new file mode 100644 index 0000000..8f7a0a8 --- /dev/null +++ b/ressources/mailhog/rootfs/usr/lib/systemd/system/mailhog.service @@ -0,0 +1,37 @@ +[Unit] +Description=service mailhog +Documentation=https://github.com/mautrix/MailHog + +After=network.target + +[Service] +User=mailhog +Group=mailhog +EnvironmentFile=/etc/default/mailhog +ExecStart=/usr/bin/mailhog +WorkingDirectory=/tmp +Restart=on-failure +RestartSec=30s +#ReadWritePaths=/tmp +NoNewPrivileges=yes +MemoryDenyWriteExecute=true +PrivateDevices=yes +PrivateTmp=yes +ProtectHome=yes +ProtectSystem=strict +ProtectControlGroups=true +RestrictSUIDSGID=true +RestrictRealtime=true +LockPersonality=true +ProtectKernelLogs=true +ProtectKernelTunables=true +ProtectHostname=true +ProtectKernelModules=true +PrivateUsers=true +ProtectClock=true +SystemCallArchitectures=native +SystemCallErrorNumber=EPERM +SystemCallFilter=@system-service + +[Install] +WantedBy=multi-user.target