#!/bin/sh
# logviewer.sh - a demonstration of opie-sh
#
# Copyright (C) 2002 gonz@directbox.com
#
# This program 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; either version 2, or (at your option)
# any later version.
#
# 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.
#
# 20020526-1a - initial release...
#
OPIE_SH=$OPIEDIR/bin/opie-sh
INITPATH=/etc/init.d
######################################################################
# subroutines
about() {
( echo ""
echo "
"
) | $OPIE_SH -t logviewer -f &
SCREENCLEAN=$!
sleep 1
}
cleanup() {
kill $SCREENCLEAN 2>/dev/null
rm -f /tmp/qcop-msg-logviewer.sh
}
choose_log() {
# ask what to do (start/stop/status)
#
$OPIE_SH -m -t "Select Log" \
-M "which logfile are you interested in ?
" \
-g -0 "PROC" -1 "SYSLOG"
RETURNCODE=$?
case $RETURNCODE in
-1) echo unexpected input detected, exiting.
cleanup ;;
0) LOGMETHOD=proc ;;
1) LOGMETHOD=syslog ;;
esac
}
######################################################################
# main
about
choose_log
case $LOGMETHOD in
proc) $OPIE_SH -m -t "Select Log" \
-M "which procfile ?
" \
-g -0 kmsg -1 "ksyms"
RETURNCODE=$?
case $RETURNCODE in
-1) cleanup ;;
0)
cat /proc/kmsg >/tmp/log.$$ &
PID=$!
sleep 2
kill $PID
( echo ""
echo "