diff --git a/.ebextensions/cron-linux.config b/.ebextensions/cron-linux.config new file mode 100644 index 0000000..50a27fc --- /dev/null +++ b/.ebextensions/cron-linux.config @@ -0,0 +1,24 @@ +################################################################################################### +#### Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. +#### +#### Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file +#### except in compliance with the License. A copy of the License is located at +#### +#### http://aws.amazon.com/apache2.0/ +#### +#### or in the "license" file accompanying this file. This file is distributed on an "AS IS" +#### BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +#### License for the specific language governing permissions and limitations under the License. +################################################################################################### + +files: + "/etc/cron.d/drupalcron": + mode: "000644" + owner: root + group: root + content: | + 0,10,20,30,40,50 * * * * root /var/www/html/.platform/cron/drupal.sh +commands: + remove_old_cron: + command: "rm -f /etc/cron.d/drupalcron.bak" + diff --git a/.platform/cron/drupal.sh b/.platform/cron/drupal.sh new file mode 100755 index 0000000..17c241b --- /dev/null +++ b/.platform/cron/drupal.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -e + + +# The Apache webserver runs as webapp, so we need to execute +# the deploy procedure with that user, otherwise we might create +# inacessible files under sites/default/files . +# By default, we login using `ec2-user`. +if [ "$(whoami)" != "webapp" ]; then + + # As root, we make sure we have access to the environment variables. + chmod 644 /opt/elasticbeanstalk/deployment/env + + SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" + sudo -uwebapp "$SCRIPTPATH/drupal.sh" + exit 0 +fi + +export $(cat /opt/elasticbeanstalk/deployment/env | xargs) + +cd /var/www/html || exit 1 +DRUSH="./vendor/bin/drush" +$DRUSH core-cron