2016-08-11 01:22:20 +00:00
|
|
|
#!/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)
|
|
|
|
}
|
|
|
|
|
2017-04-21 04:02:19 +00:00
|
|
|
function firststart {
|
|
|
|
if [ -x /usr/local/sbin/firststart.sh ]; then
|
|
|
|
/usr/local/sbin/firststart.sh
|
|
|
|
[ $? -eq 0 ] && rm /usr/local/sbin/firststart.sh
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-08-11 01:22:20 +00:00
|
|
|
trap 'stop' SIGTERM
|
|
|
|
|
|
|
|
if [ "$1" == "start" ]; 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..."
|
2016-08-24 13:54:34 +00:00
|
|
|
[ -f /etc/mail/authinfo ] && /usr/sbin/saslauthd -m /run/saslauthd -a pam
|
2016-08-11 01:22:20 +00:00
|
|
|
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..."
|
|
|
|
getent passwd lamp || useradd -c "Hosting Admin User" -m lamp
|
|
|
|
[ -x /usr/sbin/sshd-keygen ] && /usr/sbin/sshd-keygen
|
2017-04-19 11:55:33 +00:00
|
|
|
[ -x /usr/sbin/sshd ] && /usr/sbin/sshd -D &
|
2016-08-11 01:22:20 +00:00
|
|
|
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 /var/www/sites/*/awstats/awstats*conf ] && find /var/www/sites/*/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
|
|
|
|
find /etc/httpd/sites.d -type f -exec ln -sf {} /etc/httpd/conf.d/ \;
|
|
|
|
[ -x /usr/sbin/httpd ] && /usr/sbin/httpd -DFOREGROUND &
|
|
|
|
else
|
|
|
|
echo "! NOT starting HTTP"
|
|
|
|
fi
|
|
|
|
|
2017-04-21 04:02:19 +00:00
|
|
|
firststart
|
2016-08-11 01:22:20 +00:00
|
|
|
wait
|
|
|
|
else
|
2017-04-21 04:02:19 +00:00
|
|
|
firststart
|
2016-08-11 01:22:20 +00:00
|
|
|
exec $@
|
|
|
|
fi
|