diff --git a/install_mailhog_as_service.sh b/install_mailhog_as_service.sh index 491201e..24bb9a5 100644 --- a/install_mailhog_as_service.sh +++ b/install_mailhog_as_service.sh @@ -1,70 +1,64 @@ #!/bin/bash -echo ""; +echo "" set -e -GO_VERSION=1.22.5 # of een andere recente 1.22.x / 1.23.x + +GO_VERSION=1.22.5 + echo "===================================" echo "Installeren van Go ${GO_VERSION}..." echo "===================================" + apt-get update apt-get -y install curl ca-certificates + cd /tmp curl -LO https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz -# Oude Go-installatie weghalen (indien aanwezig) + rm -rf /usr/local/go -# Nieuwe Go installeren tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz -# Go in PATH zetten voor dit script + export PATH=/usr/local/go/bin:$PATH -go version # zou nu go1.22.x moeten tonen -#apt-get -y install golang-go; -#if [ $? == 0 ] ; then -# echo 'golang-go installed' -#else -# echo 'ERROR: Installing golang-go NOT succesfull!' -# exit -#fi -echo ""; -echo "==================================="; -echo "Installing mailhog..."; -echo "==================================="; -go install github.com/mailhog/MailHog@latest; -if [ $? == 0 ] ; then - echo ""; - echo "==================================="; - echo "Mailcatcher installed succesfully!"; - echo "==================================="; - echo ""; -else - echo 'ERROR: Installing Mailcatcher NOT succesfull!' - exit -fi -echo "==================================="; -echo "Copy Mailhog to bin..."; -echo "==================================="; -sudo cp ~/go/bin/MailHog /usr/local/bin/MailHog -if [ $? == 0 ] ; then - echo 'Mailhog copied' -else - echo 'ERROR: Copy Mailhog NOT succesfull!' - exit -fi -echo ""; -echo "==================================="; -echo "Create MailHog service..."; -echo "==================================="; -sudo tee /etc/systemd/system/mailhog.service < /dev/null 2>&1 & +ExecStart=/usr/local/bin/MailHog +Restart=always +User=root +StandardOutput=journal +StandardError=journal + [Install] WantedBy=multi-user.target EOL + +systemctl daemon-reload systemctl enable mailhog systemctl start mailhog -echo ""; -echo "==================================="; -echo "Mailhog service created and started."; -echo "==================================="; \ No newline at end of file + +echo "" +echo "===================================" +echo "MailHog service created and started." +echo "==================================="