82 lines
2.5 KiB
Bash
Executable File
82 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
NO_DB=${NO_DB:-FALSE}
|
|
NO_SSH=${NO_SSH:-TRUE}
|
|
NO_MAIL=${NO_MAIL:-FALSE}
|
|
NO_HTTP=${NO_HTTP:-FALSE}
|
|
|
|
NAME="LAMPS"
|
|
|
|
function stop {
|
|
echo "Stopping ${NAME}"
|
|
[ "$NO_MAIL" != "TRUE" ] && kill $(cat /var/run/opendkim.pid) && kill $(cat /var/run/sendmail.pid|head -1)
|
|
[ "$NO_SSH" != "TRUE" ] && kill $(cat /var/run/sshd.pid)
|
|
[ "$NO_DB" != "TRUE" ] && kill $(cat /var/run/mariadb/mariadb.pid)
|
|
[ "$NO_HTTP" != "TRUE" ] && rm -f /var/run/httpd/authdigest_shm.$(cat /var/run/httpd/httpd.pid) && kill $(cat /var/run/httpd/httpd.pid)
|
|
}
|
|
|
|
function firststart {
|
|
if [ -x /usr/local/sbin/firststart.sh ]; then
|
|
/usr/local/sbin/firststart.sh
|
|
[ $? -eq 0 ] && rm /usr/local/sbin/firststart.sh
|
|
fi
|
|
}
|
|
|
|
trap 'stop' SIGTERM
|
|
|
|
if [ -z "$1" ]; then
|
|
if [ "$NO_MAIL" != "TRUE" ]; then
|
|
if [ -z `hostname --domain` ]; then
|
|
echo "You must start this container with --hostname= specifying a domain name"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Starting OpenDKIM..."
|
|
[ ! -f /etc/opendkim/keys/default.private ] && /usr/sbin/opendkim-default-keygen
|
|
[ -x /usr/sbin/opendkim ] && /usr/sbin/opendkim -x /etc/opendkim.conf -P /var/run/opendkim.pid -f &
|
|
echo "Starting Sendmail..."
|
|
[ -f /etc/mail/authinfo ] && /usr/sbin/saslauthd -m /run/saslauthd -a pam
|
|
cd /etc/mail && make && m4 sendmail.mc > sendmail.cf && /usr/sbin/sendmail -q1h -bD &
|
|
else
|
|
echo "! NOT starting MAIL"
|
|
fi
|
|
|
|
if [ "$NO_SSH" != "TRUE" ]; then
|
|
echo "Starting SSHD..."
|
|
[ ! -d /etc/leenooks/ssh ] && mkdir /etc/leenooks/ssh && chmod 750 /etc/leenoks/ssh
|
|
getent passwd lamp || useradd -c "Hosting Admin User" -m lamp
|
|
[ -x /usr/sbin/sshd-keygen ] && /usr/sbin/sshd-keygen
|
|
[ -x /usr/sbin/sshd ] && /usr/sbin/sshd -D &
|
|
else
|
|
echo "! NOT starting SSH"
|
|
fi
|
|
|
|
if [ "$NO_DB" != "TRUE" ]; then
|
|
echo "Starting Maria DB..."
|
|
[ -x /usr/libexec/mariadb-prepare-db-dir ] && /usr/libexec/mariadb-prepare-db-dir
|
|
[ -x /usr/bin/mysqld_safe ] && /usr/bin/mysqld_safe --basedir=/usr &
|
|
else
|
|
echo "! NOT starting DB"
|
|
fi
|
|
|
|
if [ "$NO_HTTP" != "TRUE" ]; then
|
|
if [ -d /etc/awstats ]; then
|
|
find /etc/awstats/ -type l | xargs -n 5 rm -f
|
|
[ -e /etc/leenooks/awstats/awstats*conf ] && find /etc/leenooks/awstats/awstats*conf -type f -exec ln -sf {} /etc/awstats/ \;
|
|
fi
|
|
echo "Starting HTTP..."
|
|
find /etc/httpd/conf.d/ -type l | xargs -n 5 rm -f
|
|
[ -d /etc/leenooks/httpd ] && find /etc/leenooks/httpd -type f -exec ln -sf {} /etc/httpd/conf.d/ \;
|
|
[ -x /usr/sbin/httpd ] && /usr/sbin/httpd -DFOREGROUND &
|
|
else
|
|
echo "! NOT starting HTTP"
|
|
fi
|
|
|
|
firststart
|
|
wait
|
|
|
|
else
|
|
exec $@
|
|
fi
|