blob: 677545adbb5aa1e9fbdea8094f03de743a3231eb [file] [log] [blame]
# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
description "Start apache for moblab."
author "chromium-os-dev@chromium.org"
start on (started moblab-database-init and
stopped moblab-homedir-init and
stopped moblab-external-storage-init RESULT=ok)
env CROS_CACHEDIR=/mnt/moblab/cros_cache_apache
env BOTO_CONFIG=/home/moblab/.boto
normal exit 0
pre-start script
mkdir -p /var/log/bootup/
exec >>/var/log/bootup/${UPSTART_JOB}.log 2>&1
set -x
set -e
logger -t "${UPSTART_JOB}" "Starting."
mkdir -p --mode 775 "${CROS_CACHEDIR}"
chown -R apache:apache "${CROS_CACHEDIR}"
APACHE_LOG_DIR=/var/log/apache2
mkdir -p "${APACHE_LOG_DIR}"
chown -R apache:apache "${APACHE_LOG_DIR}"
APACHE_RUN_DIR=/run/apache
mkdir -p "${APACHE_RUN_DIR}"
chown -R apache:apache "${APACHE_RUN_DIR}"
APACHE_SSH_DIR=/var/www/.ssh
if [ ! -e "${APACHE_SSH_DIR}"/id_rsa ]; then
mkdir -p "${APACHE_SSH_DIR}"
cp /root/.ssh/* "${APACHE_SSH_DIR}"
chown -R apache:apache "${APACHE_SSH_DIR}"
fi
APACHE_DIR=/var/www/
if [ ! -e "${APACHE_DIR}".gsutil ]; then
mkdir "${APACHE_DIR}".gsutil
chown apache:apache "${APACHE_DIR}".gsutil
fi
logger -t "${UPSTART_JOB}" "Ending."
end script
# apache2 will fork once and exit.
expect fork
exec apache2