blob: f5dd7edd3e6a158df5dedfea214b2026c9b2bd31 [file] [log] [blame]
# Copyright 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.
# Responsible for running sensors_server
description "Run sensors_server"
author "chromium-os-dev@chromium.org"
start on started shill
script
# Wait for network to be completely ready.
sleep 10
PROJ_DIR="/usr/local/ts"
BOARD_PATH="$PROJ_DIR/boards/board"
# Determine the machine IP address.
# There are two possibilities that the BB connects to the network.
# Case 1:
# It is connected to a dhcp server, the IP address is automatically
# assigned by the server.
# Case 2:
# It is connected directly to a test host which is typically a chromebook.
# Assign a fixed 192.168.2.3 address in this case.
MACHINE_IP=`ifconfig eth0 | egrep "inet .+netmask .+broadcast" |\
awk '{print $2}'`
if [ -z "$MACHINE_IP" ]; then
MACHINE_IP="192.168.2.3"
ifconfig eth0 "$MACHINE_IP" netmask 255.255.255.0
fi
# Must specify the target board if this program is run on a beagle bone.
BOARD=`test -f "$BOARD_PATH" && cat "$BOARD_PATH" ||\
cat /etc/lsb-release | grep CHROMEOS_RELEASE_BOARD |\
awk -F "=" '{print $2}'`
logger -t "${UPSTART_JOB}" "MACHINE_IP: ${MACHINE_IP}"
logger -t "${UPSTART_JOB}" "BOARD: ${BOARD}"
sudo mount -o remount,rw /
exec sudo python ${PROJ_DIR}/sensors_server.py ${MACHINE_IP}:8000 ${BOARD}
end script