Skip to content

Commit

Permalink
add runit service, fix nginx conf
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierGuilloux committed Jan 25, 2019
1 parent 778cef0 commit a1e2d56
Show file tree
Hide file tree
Showing 20 changed files with 379 additions and 130 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
docker-entrypoint-initdb.d
data
.sandboxes
1 change: 0 additions & 1 deletion etc/apt/sources.list.d/backports.list

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@ server {
include fastcgi_sympa;
}

location /static-sympa/ {
alias /usr/local/var/lib/sympa/static_content/;
}

location /sympa-static/ {
alias /var/lib/sympa/static_content/;
alias /usr/local/var/lib/sympa/static_content/;
}

location /lists-static/ {
alias /var/lib/sympa/static_content/;
alias /usr/local/var/lib/sympa/static_content/;

}

location ~ /\. {
Expand Down
26 changes: 26 additions & 0 deletions etc/nginx/fastcgi_params
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
fastcgi_param SCRIPT_FILENAME $request_filename;

2 changes: 1 addition & 1 deletion etc/nginx/fastcgi_sympasoap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include fastcgi_soap_host;
include fastcgi_params;
fastcgi_split_path_info ^(/sympasoap)(.*)$;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME /usr/lib/cgi-bin/sympa/sympa_soap_server.fcgi;
fastcgi_param SCRIPT_FILENAME /usr/local/lib/sympa/cgi/sympa_soap_server.fcgi;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SERVER_NAME $host;
fastcgi_intercept_errors on;
Expand Down
66 changes: 49 additions & 17 deletions etc/rsyslog.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,24 @@
#
# For more information see
# /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html
#
# Default logging rules can be found in /etc/rsyslog.d/50-default.conf


#################
#### MODULES ####
#################

$ModLoad imuxsock # provides support for local system logging
$ModLoad imklog # provides kernel logging support
#$ModLoad immark # provides --MARK-- message capability
module(load="imuxsock") # provides support for local system logging
module(load="imklog") # provides kernel logging support
#module(load="immark") # provides --MARK-- message capability

# provides UDP syslog reception
#$ModLoad imudp
#$UDPServerRun 514
#module(load="imudp")
#input(type="imudp" port="514")

# provides TCP syslog reception
#$ModLoad imtcp
#$InputTCPServerRun 514
#module(load="imtcp")
#input(type="imtcp" port="514")

# Enable non-kernel facility klog messages
$KLogPermitNonKernelFacility on

###########################
#### GLOBAL DIRECTIVES ####
Expand All @@ -35,19 +31,14 @@ $KLogPermitNonKernelFacility on
#
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat

# Filter duplicated messages
$RepeatedMsgReduction on

#
# Set the default permissions for all log files.
#
$FileOwner syslog
$FileOwner root
$FileGroup adm
$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022
#$PrivDropToUser syslog
#$PrivDropToGroup syslog

#
# Where to place spool and state files
Expand All @@ -59,3 +50,44 @@ $WorkDirectory /var/spool/rsyslog
#
$IncludeConfig /etc/rsyslog.d/*.conf


###############
#### RULES ####
###############

#
# First some standard log files. Log by facility.
#
auth,authpriv.* /var/log/auth.log
*.*;auth,authpriv.none -/var/log/syslog
#cron.* /var/log/cron.log
daemon.* -/var/log/daemon.log
kern.* -/var/log/kern.log
lpr.* -/var/log/lpr.log
mail.* -/var/log/mail.log
user.* -/var/log/user.log

#
# Logging for the mail system. Split it up so that
# it is easy to write scripts to parse these files.
#
mail.info -/var/log/mail.info
mail.warn -/var/log/mail.warn
mail.err /var/log/mail.err

#
# Some "catch-all" log files.
#
*.=debug;\
auth,authpriv.none;\
news.none;mail.none -/var/log/debug
*.=info;*.=notice;*.=warn;\
auth,authpriv.none;\
cron,daemon.none;\
mail,news.none -/var/log/messages

#
# Emergencies are sent to everybody logged in.
#
*.emerg :omusrmsg:*
local1.* /var/log/sympa.log
12 changes: 12 additions & 0 deletions etc/service/nginx/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash -e

if [ -n "$SET_REAL_IP_FROM" ]; then
echo "set_real_ip_from $SET_REAL_IP_FROM;" > /etc/nginx/conf.d/set_real_ip_from.conf
else
rm -f /etc/nginx/conf.d/set_real_ip_from.conf
fi

# Initialization hook.
[ -f /etc/service/nginx/run.initialization ] && source /etc/service/nginx/run.initialization

exec /usr/sbin/nginx -g "daemon off;" 2>&1
2 changes: 1 addition & 1 deletion etc/service/nullmailer/run
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
chown mail /var/spool/nullmailer

# If directory is empty, we restore it from our copy of initial files
[[ $(ls -A /var/spool/nullmailer | grep -v placeholder) ]] || cp -a /var/spool/nullmailer.orig/* /var/spool/nullmailer/
#[[ $(ls -A /var/spool/nullmailer | grep -v placeholder) ]] || cp -a /var/spool/nullmailer.orig/* /var/spool/nullmailer/

if [ ! -p /var/spool/nullmailer/trigger ]; then
rm -f /var/spool/nullmailer/trigger
Expand Down
3 changes: 2 additions & 1 deletion etc/service/rsyslog/run
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ rm -f /var/run/rsyslogd.pid

# No need to create any extra directory because logging for Sympa is already configured.

exec /usr/sbin/rsyslogd -n -c5 2>&1
exec /usr/sbin/rsyslogd -n 2>&1
#exec /usr/sbin/rsyslogd 2>&1
2 changes: 1 addition & 1 deletion etc/service/soapsympa/run
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export FCGI_SOCKET_PATH="$FCGI_HOST:$FCGI_SOAP_PORT"
echo fastcgi_pass "$FCGI_HOST:$FCGI_SOAP_PORT;" > /etc/nginx/fastcgi_soap_host

# /usr/bin/spawn-fcgi -F 1 -P /run/sympa/sympasoap.pid -u sympa -g sympa -p 10000 -- /usr/lib/cgi-bin/sympa/sympa_soap_server-wrapper.fcgi
exec chpst -u sympa:sympa /usr/bin/spawn-fcgi -p $FCGI_SOAP_PORT /usr/lib/cgi-bin/sympa/sympa_soap_server-wrapper.fcgi &
exec chpst -u sympa:sympa /usr/bin/spawn-fcgi -p $FCGI_SOAP_PORT /usr/local/lib/sympa/cgi/sympa_soap_server-wrapper.fcgi &
22 changes: 14 additions & 8 deletions etc/service/sympa/run
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#!/bin/bash -e

mkdir -p /var/lib/sympa/list_data
chown -Rh :sympa /etc/sympa/*
chown -Rh sympa:sympa /var/lib/sympa /var/spool/sympa
chmod 771 /var/spool/sympa
chmod 750 /etc/sympa/includes
chmod 640 /etc/sympa/includes/*
chown -Rh :sympa /etc/sympa/includes/*
find /etc/sympa/includes/ -type f -exec chmod 640 {} \;
find /etc/sympa/includes/ -type f -exec chown -Rh :sympa {} \;


# If directory is empty, we restore it from our copy of initial files.
[[ $(ls -A /var/lib/sympa | grep -v placeholder) ]] || cp -a /var/lib/sympa.orig/* /var/lib/sympa/
[[ $(ls -A /var/spool/sympa | grep -v placeholder) ]] || cp -a /var/spool/sympa.orig/* /var/spool/sympa/
#[[ $(ls -A /var/lib/sympa | grep -v placeholder) ]] || cp -a /var/lib/sympa.orig/* /var/lib/sympa/
#[[ $(ls -A /var/spool/sympa | grep -v placeholder) ]] || cp -a /var/spool/sympa.orig/* /var/spool/sympa/

# If installation time cookie file exists, remove it, we are using one mapped from outside.
if [ -e /etc/sympa/cookie ]; then
Expand All @@ -25,14 +27,18 @@ if [ -e /etc/sympa/shared ]; then
ssh-keygen -t rsa -f /etc/sympa/shared/id_rsa -N ''
fi

rm -f /etc/sympa/shared/known_hosts
echo -n 'sympa ' > /etc/sympa/shared/known_hosts
cat /etc/ssh/ssh_host_rsa_key.pub >> /etc/sympa/shared/known_hosts
# rm -f /etc/sympa/shared/known_hosts
# echo -n 'sympa ' > /etc/sympa/shared/known_hosts
# cat /etc/ssh/ssh_host_rsa_key.pub >> /etc/sympa/shared/known_hosts

mkdir -p /var/lib/sympa/.ssh
echo -n 'no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty,command="/etc/sympa/run.sh" ' > /var/lib/sympa/.ssh/authorized_keys
cat /etc/sympa/shared/id_rsa.pub >> /var/lib/sympa/.ssh/authorized_keys
fi

# All output is logged to /var/log/sympa/sympa.log so we redirect stdout and stderr to /dev/null.
exec chpst -u sympa:sympa /usr/lib/sympa/bin/sympa.pl --foreground > /dev/null 2>&1
#echo "sympa.pl Starting"; > /var/log/sympa.log
if [ ! -f $PIDFILE ] ; then
/usr/local/sbin/sympa.pl --health_check
exec chpst -u sympa:sympa /usr/local/sbin/sympa_msg.pl 2>&1 >> /var/log/sympa.log
fi
2 changes: 1 addition & 1 deletion etc/service/sympa_archived/run
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
sleep 10

# All output is logged to /var/log/sympa/sympa.log so we redirect stdout and stderr to /dev/null.
exec chpst -u sympa:sympa /usr/lib/sympa/bin/archived.pl --foreground > /dev/null 2>&1
exec chpst -u sympa:sympa /usr/local/sbin/archived.pl --foreground > /dev/null 2>&1
2 changes: 1 addition & 1 deletion etc/service/sympa_bounced/run
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
sleep 10

# All output is logged to /var/log/sympa/sympa.log so we redirect stdout and stderr to /dev/null.
exec chpst -u sympa:sympa /usr/lib/sympa/bin/bounced.pl --foreground > /dev/null 2>&1
exec chpst -u sympa:sympa /usr/local/sbin/bounced.pl --foreground > /dev/null 2>&1
2 changes: 1 addition & 1 deletion etc/service/sympa_bulk/run
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
sleep 10

# All output is logged to /var/log/sympa/sympa.log so we redirect stdout and stderr to /dev/null.
exec chpst -u sympa:sympa /usr/lib/sympa/bin/bulk.pl --foreground > /dev/null 2>&1
exec chpst -u sympa:sympa /usr/local/sbin/bulk.pl --foreground > /dev/null 2>&1
2 changes: 1 addition & 1 deletion etc/service/sympa_task_manager/run
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
sleep 10

# All output is logged to /var/log/sympa/sympa.log so we redirect stdout and stderr to /dev/null.
exec chpst -u sympa:sympa /usr/lib/sympa/bin/task_manager.pl --foreground > /dev/null 2>&1
exec chpst -u sympa:sympa /usr/local/sbin/task_manager.pl --foreground > /dev/null 2>&1
2 changes: 1 addition & 1 deletion etc/service/wwsympa/run
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ sleep 10
export FCGI_SOCKET_PATH="$FCGI_HOST:$FCGI_PORT"
echo fastcgi_pass "$FCGI_HOST:$FCGI_PORT;" > /etc/nginx/fastcgi_host

exec chpst -u sympa:sympa /usr/lib/cgi-bin/sympa/wwsympa.fcgi 2>&1
exec chpst -u sympa:sympa /usr/local/lib/sympa/cgi/wwsympa.fcgi 2>&1
11 changes: 6 additions & 5 deletions etc/sympa/conf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
CONF=(
DOMAIN=localhost
[email protected]
WWSYMPA_URL=http://localhost/lists
WWSYMPA_URL=http://127.0.0.1:8008/lists
COOKIE=GenerateSring
DB_HOST=localhost
DB_PASSWD=password
HTTP_HOST=http://localhost/
SOAP_URL=http://localhost/sympasoap
DB_HOST=sympa_db
DB_PASSWD=sympa
HTTP_HOST=http://127.0.0.1:8008/
SOAP_URL=http://127.0.0.1:8008/sympasoap
COOKIE_DOMAIN=127.0.0.1
)

function applyConf() {
Expand Down
Loading

0 comments on commit a1e2d56

Please sign in to comment.