File: //proc/11864/root/usr/sbin/paas-start
#!/bin/bash -e
# (C) 2011-2024 Gandi.
# Redistribution or use outside of Gandi's platform is prohibited.
echo "cmdline: $*"
export PAAS='lamp0'
export PATH="/usr/sbin:/usr/bin:/sbin/:/bin"
source /lib/start-lib.sh
parse_arguments "$@"
parse_json /srv/data/.paas
umask 002
if [ ! -L "$HOME" ]; then
ln -s "${CUSTOMER_DIR}/home" "$HOME"
fi
go_console
case "$WWW_ENGINE" in
php ) DAEMONS="$DB_ENGINE php-fpm apache2" ;;
nodejs) DAEMONS="$DB_ENGINE php-admin nodejs apache2" ;;
python) DAEMONS="$DB_ENGINE php-admin python apache2" ;;
ruby ) DAEMONS="$DB_ENGINE php-admin ruby apache2" ;;
*)
echo "$WWW_ENGINE: invalid engine"
exit 1
;;
esac
cd "$HOME"
# PATH /srv/admin present
source /srv/admin/scripts/kill-lib.sh
# job control enabled
set -o monitor
trap on_exit EXIT
trap 'on_err $? ${BASH_SOURCE[0]} ${LINENO}' ERR
trap on_sigterm TERM
trap on_sigusr1 USR1
# Allow to receive SIGUSR2 from dumb-init. If the trap is not defined bash will
# exit.
trap 'echo SIGUSR2 received' USR2
sysctl -p
echo "Calling /srv/admin/scripts/init.sh"
source /srv/admin/scripts/init.sh
echo "Services started"
# Makes sure all services are running
check_daemons
do_as "${SYS_USER}" touch /srv/data/.bootstrapped
if [[ "${SHELL_START}" ]]; then
/srv/admin/scripts/init.d/shell start
fi
# load sleep builtin in order to catch further signals
enable -f /usr/lib/bash/sleep sleep
unset LD_PRELOAD
while true; do
LAST=$SECONDS
on_cron
# This is a non interruptible sleep to let the anacron user process finish
# in order to avoid receiving a SIGUSR2 from dumb-init that would interrupt
# the sleep builtin. This would lead to an infinite recursion.
/bin/sleep 2
SLEEP=$(( LAST + 3600 - SECONDS ))
if [ $SLEEP -ge 0 ]; then
# This is interrupted when we receive SIGUSR2 from dumb-init
# dumb-init is patched to send SIGUSR2 when some of its child terminates
#
# Note: we don't use SIGCHLD anymore because the sleep builtin of bash
# 5.x no longer handle it correctly.
sleep $SLEEP
# This is run:
# - every hour
# - when builtin sleep is interrupted by SIGUSR2
check_daemons
fi
done