summaryrefslogtreecommitdiffstats
path: root/meta-facebook/meta-wedge/recipes-wedge/bmc-log/files/bmc-log.sh
blob: 00bf63c23bffb9d7a3d8ccaa327cabff3dbf148f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/sh
#
# Copyright 2014-present Facebook. All Rights Reserved.
#
# This program file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program in a file named COPYING; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301 USA
#

### BEGIN INIT INFO
# Provides:          bmc-log
# Required-Start:
# Required-Stop:
# Default-Start:     S
# Default-Stop:
# Short-Description: Collect micro-server kernel logs through serial port
### END INIT INFO

. /etc/default/bmc-log
. /etc/init.d/functions

DAEMON=/usr/sbin/bmc-log
NAME=bmc-log
DESC="Micro-Server log collection"

TTY=${US_TTY:-/dev/ttyS1}
IP=${LOG_SERVER_IP_VERSION:-4}
LOG_SERVER=${LOG_SERVER_NAME:-}
PORT=${LOG_SERVER_PORT:-}
BAUD_RATE=${TTY_BAUD_RATE:-}

if [ -z "$LOG_SERVER" ] || [ -z "$PORT" ]
then
	echo "Error: Server and/or port not set"
	exit 0
fi


ACTION="$1"

case "$ACTION" in
  start)
  	echo -e "Starting $DESC"
	$DAEMON $TTY $IP $LOG_SERVER $PORT $BAUD_RATE
    ;;
  stop)
    echo -e "Stopping $DESC: "
    start-stop-daemon --stop --quiet --exec $DAEMON
    ;;
   restart|force-reload)
    echo -e "Restarting $DESC: "
    start-stop-daemon --stop --quiet --exec $DAEMON
    sleep 1
    $DAEMON $TTY $IP $LOG_SERVER $PORT $BAUD_RATE
    ;;
  status)
    stat $DAEMON
    exit $?
    ;;
  *)
    N=${0##*/}
    N=${N#[SK]??}
    echo "Usage: $N {start|stop|status|restart|force-reload}" >&2
    exit 1
    ;;
esac
OpenPOWER on IntegriCloud