blob: 289727073277317763281612c95b087220437888 [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}
DongRyeol Cha5c0a9f02018-05-17 14:32:55 +090012remote_scp=$ONOS_USER@[${remote:-$OCI}]
Brian O'Connor0a53fac2015-03-19 22:21:18 -070013message=$2
14
15if [ -z "$message" ]; then
16 echo "Usage: onos-log-write <instance> <message>"
17 exit
18fi
19if [ -z $(which figlet) ]; then
20 echo "Install figlet; example: brew install figlet"
21 exit
22fi
23
24#text=$(figlet $message)
25#echo "Writing to $remote:"
26#echo $text
27#echo
28
29[ -n "$instance" ] && \
30 LOG=$ONOS_INSTALL_DIR/$KARAF_DIST/instances/$instance/data/log/karaf.log || \
31 LOG=$ONOS_INSTALL_DIR/log/karaf.log
32
33#broken by special chars like `
34#ssh -t $remote "sudo mkdir -p $(dirname $LOG) && echo $text | sudo tee -a $LOG"
35
36figlet $message > /tmp/message.txt
DongRyeol Cha5c0a9f02018-05-17 14:32:55 +090037scp /tmp/message.txt $remote_scp:/tmp
Brian O'Connor0a53fac2015-03-19 22:21:18 -070038ssh -t $remote "sudo mkdir -p $(dirname $LOG) && cat /tmp/message.txt | sudo tee -a $LOG; rm /tmp/message.txt"