blob: 840c43f5b1df56f05da0a26a4d14344049e2c441 [file] [log] [blame]
Brian O'Connor0a53fac2015-03-19 22:21:18 -07001#!/bin/bash
2# -----------------------------------------------------------------------------
3# Writes block text into the remote ONOS log file on the specified node.
4# -----------------------------------------------------------------------------
5
6[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7. $ONOS_ROOT/tools/build/envDefaults
8. $ONOS_ROOT/tools/test/bin/find-node.sh
9
10remote=$(find_node $1)
11remote=$ONOS_USER@${remote:-$OCI}
12message=$2
13
14if [ -z "$message" ]; then
15 echo "Usage: onos-log-write <instance> <message>"
16 exit
17fi
18if [ -z $(which figlet) ]; then
19 echo "Install figlet; example: brew install figlet"
20 exit
21fi
22
23#text=$(figlet $message)
24#echo "Writing to $remote:"
25#echo $text
26#echo
27
28[ -n "$instance" ] && \
29 LOG=$ONOS_INSTALL_DIR/$KARAF_DIST/instances/$instance/data/log/karaf.log || \
30 LOG=$ONOS_INSTALL_DIR/log/karaf.log
31
32#broken by special chars like `
33#ssh -t $remote "sudo mkdir -p $(dirname $LOG) && echo $text | sudo tee -a $LOG"
34
35figlet $message > /tmp/message.txt
36scp /tmp/message.txt $remote:/tmp
37ssh -t $remote "sudo mkdir -p $(dirname $LOG) && cat /tmp/message.txt | sudo tee -a $LOG; rm /tmp/message.txt"