Commit c660bcf2 authored by Stefan Galinski's avatar Stefan Galinski 🎮
Browse files

[TASK] Initial commit

parents
name 'mailcatcher'
maintainer 'sgalinski Internet Services'
maintainer_email 'stefan@sgalinski.de'
license 'Apache 2.0'
description 'MailCatcher'
long_description 'MailCatcher'
version '1.0.0'
recipe 'mailcatcher::default', 'Main recipe'
depends 'apt'
depends 'build-essential'
\ No newline at end of file
#
# Cookbook Name:: mailcatcher
# Recipe:: default
#
# Copyright sgalinski Internet Services
#
# 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.
#####################################
### Remove existing mail programs ###
#####################################
%w{sendmail postfix exim4 mutt}.each do |name|
package name do
action :remove
end
end
###################
### Update Ruby ###
###################
apt_repository('ruby-ng') do
uri 'http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu'
deb_src true
trusted true
keyserver 'keyserver.ubuntu.com'
key 'C3173AA6'
distribution 'trusty'
components [:main]
arch 'amd64,i386'
action :add
end
package 'ruby2.2', {:action => :upgrade}
package 'ruby2.2-dev', {:action => :upgrade}
###########################
### Install mailcatcher ###
###########################
include_recipe 'build-essential'
package 'libsqlite3-dev'
gem_package 'mailcatcher'
###############################
### Add mailcatcher service ###
###############################
template '/etc/init.d/mailcatcher' do
source 'initd.sh.erb'
owner 'root'
group 'root'
mode '0755'
action :create
notifies :restart, 'service[mailcatcher]', :delayed
end
service 'mailcatcher' do
supports :restart => true, :reload => false, :status => false
action [:enable, :start]
end
######################################
### Integrate mailcatcher into PHP ###
######################################
replace_or_add 'change sendmail in the apache2 php configuration for mailcatcher' do
path '/etc/php5/apache2/php.ini'
pattern ';sendmail_path ='
line 'sendmail_path = "/usr/bin/env catchmail"'
end
replace_or_add 'change sendmail in the apache2 php configuration for mailcatcher' do
path '/etc/php5/cli/php.ini'
pattern ';sendmail_path ='
line 'sendmail_path = "/usr/bin/env catchmail"'
end
service 'apache2' do
action :restart
end
\ No newline at end of file
#!/usr/bin/env bash
### BEGIN INIT INFO
#
# Taken from:
# https://gist.github.com/augustohp/8a94c7b8b456d7a925a6
#
# Provides: mailcatcher
# Required-Start: $local_fs $network $syslog $portmap
# Required-Stop: $local_fs $network $syslog $portmap
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: false
# Short-Description: Start/stop mailcatcher daemon.
### END INIT INFO
# ex: ft=shell et ts=8 sw=8:
set -e
[[ -n "$DEBUG" ]] && set -x || set +x
PID_FILE="/var/run/mailcatcher.pid"
NAME="mailcatcher"
PROG=/usr/local/bin/mailcatcher
PROG_ARGS="--http-ip 0.0.0.0 --foreground"
. /lib/lsb/init-functions
pidof_mailcatcher() {
if [ -e "$PID_FILE" ]; then
local PID_IN_FILE=$(cat $PID_FILE)
local PID=$(ps --no-headers -p $PID_IN_FILE);
if [ -n "$PID" ]; then
echo $PID_IN_FILE
return 0;
fi
fi
return 1
}
start_mailcatcher() {
start-stop-daemon \
--start \
--pidfile $PID_FILE \
--make-pidfile \
--background \
--exec "$PROG" \
-- \
$PROG_ARGS
return $?
}
stop_mailcatcher() {
start-stop-daemon --stop --oknodo --pidfile $PID_FILE > /dev/null 2>&1
return $?
}
case "$1" in
start)
log_daemon_msg "Starting SMTP server" "$NAME"
if start_mailcatcher; then
log_end_msg 0
else
log_end_msg 1
fi
;;
stop)
log_daemon_msg "Stopping SMTP server" "$NAME"
if stop_mailcatcher; then
log_end_msg 0
else
log_end_msg 1
fi
;;
force-reload|restart)
$0 stop
$0 start
;;
status)
PID=$(pidof_mailcatcher) || true
if [ -n "$PID" ]; then
echo "$NAME is running (PID $PID)."
exit 0
else
echo "$NAME it not running."
if [ -e $PID_FILE ]; then
exit 1;
else
exit 3;
fi
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment