blob: 4777a039c33c77ae734a87a029f040aa41c88abe [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
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/
BOTO_DIR=/home/moblab/
if [ ! -e "${APACHE_DIR}".boto ]; then
ln -s "${BOTO_DIR}".boto "${APACHE_DIR}".boto
chown -h apache:apache "${APACHE_DIR}".boto
fi
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