blob: 4e9109aba15b36375ae77a249f74d53bbc507a62 [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 "Ensure moblab home directory exists."
author "chromium-os-dev@chromium.org"
start on starting boot-services
script
# In case stateful is wiped, recreate the moblab home directory and ensure
# moblab owns it.
MOBLAB_HOME=/home/moblab
mkdir -p "${MOBLAB_HOME}"
# Add aliases to simplify common commands from the shell prompt.
if [ ! -e "${MOBLAB_HOME}"/.bash_profile ]; then
cp /root/.bash_profile "${MOBLAB_HOME}"
fi
chown -R moblab:moblab "${MOBLAB_HOME}"
# Copy over the ssh keys if they don't already exist.
MOBLAB_SSH_DIR=/home/moblab/.ssh
if [ ! -e "${MOBLAB_SSH_DIR}"/id_rsa ]; then
mkdir -p "${MOBLAB_SSH_DIR}"
cp /root/.ssh/* "${MOBLAB_SSH_DIR}"
# since we romoved inbound ssh for root user, some files
# are copied from /usr/share instead.
cp /usr/share/chromeos-ssh-config/keys/* "${MOBLAB_SSH_DIR}"
chown -R moblab:moblab "${MOBLAB_SSH_DIR}"
fi
# Create a placeholder for the boto file.
MOBLAB_BOTO_FILE=/home/moblab/.boto
touch "${MOBLAB_BOTO_FILE}"
chown moblab:moblab "${MOBLAB_BOTO_FILE}"
chmod 660 "${MOBLAB_BOTO_FILE}"
# Create a placeholder for the Launch Control key file.
MOBLAB_LAUNCH_CONTROL_KEY_FILE=/home/moblab/.launch_control_key
touch "${MOBLAB_LAUNCH_CONTROL_KEY_FILE}"
chown moblab:moblab "${MOBLAB_LAUNCH_CONTROL_KEY_FILE}"
chmod 660 "${MOBLAB_LAUNCH_CONTROL_KEY_FILE}"
end script