Commit 89be2973 authored by Alessandro Rubini's avatar Alessandro Rubini

build: set up logging for daemons from Kconfig values

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 28b0dbe1
......@@ -109,6 +109,33 @@ config SNMP_RW_COMMUNITY
for production. Please note, however, that the switch processes
SNMP only on the CPU Ethernet port (the copper "management" port).
config WRS_LOG_HAL
string "Logging directions for the WR hal"
default "daemon.info"
help
The string can be a pathname (e.g. /dev/kmsg) or a <facility>.<level>
spefification like "daemon.debug". An empty strings is used
to represent no logging (like /dev/null). Please note that
unknown facility names will generate a runtime error on the switch.
config WRS_LOG_RTU
string "Logging directions for the RTU daemon"
default "daemon.info"
help
The string can be a pathname (e.g. /dev/kmsg) or a <facility>.<level>
spefification like "daemon.debug". An empty strings is used
to represent no logging (like /dev/null). Please note that
unknown facility names will generate a runtime error on the switch.
config WRS_LOG_PTP
string "Logging directions for the PTP server (ptpd or ppsi)"
default "daemon.info"
help
The string can be a pathname (e.g. /dev/kmsg) or a <facility>.<level>
spefification like "daemon.debug". An empty strings is used
to represent no logging (like /dev/null). Please note that
unknown facility names will generate a runtime error on the switch.
config KEEP_ROOTFS
bool "Keep generated filesystem and related script"
help
......
......@@ -70,6 +70,14 @@ set | grep CONFIG_SNMP | sed 's/=/ /' | while read varname value; do
sed -i "/\$varname/ s/\$varname/\$value/" \$cfgfile
done
# Fix log values
cfgfile="$TMPFS/wr/sbin/start-daemons.sh"
set | grep CONFIG_WRS_LOG | sed 's/=/ /' | while read varname value; do
if [ -z "\$value" ]; then continue; fi
sed -i "/\$varname/ s,\$varname,\$value," \$cfgfile
done
mkdir -p $TMPFS/root/.ssh
#cat $HOME/.ssh/id_?sa.pub >> $TMPFS/root/.ssh/authorized_keys
if [ -f $WRS_BASE_DIR/authorized_keys ]; then
......
#!/bin/ash
echo "Starting up WR daemons..."
# The following variables are modified at build time, with Kconfig values
LOG_HAL=CONFIG_WRS_LOG_HAL
LOG_RTU=CONFIG_WRS_LOG_RTU
LOG_PTP=CONFIG_WRS_LOG_PTP
# The loop below is a little intricate because of the eval, but I need it this
# to have pipe and file as both supported.
# Also, to have both stdout and stderr, we need "2>&1" before the pipe, but
# after the file redirection (why????)
for n in HAL RTU PTP; do
# if empty turn it to /dev/null
if eval test -z "\$LOG_$n"; then LOG_$n="/dev/null"; fi
# if a pathname, use it
eval value="\$LOG_$n"
if echo "$value" | grep / > /dev/null; then
eval LOGPIPE_$n=\" \> $value 2\>\&1 \";
continue;
fi
# not a pathname: use verbatim
eval LOGPIPE_$n=\" 2\>\&1 \| logger -t wr-switch -p $value\"
done
export WR_HOME="/wr"
$WR_HOME/bin/wrsw_hal -c $WR_HOME/etc/wrsw_hal.conf &> /dev/kmsg &
$WR_HOME/bin/wrsw_rtud >& /dev/kmsg &
eval $WR_HOME/bin/wrsw_hal -c $WR_HOME/etc/wrsw_hal.conf $LOGPIPE_HAL \&
eval $WR_HOME/bin/wrsw_rtud $LOGPIPE_RTU \&
# run ptp-noposix or ppsi, whatever is installed
if [ -x $WR_HOME/bin/ptpd ]; then
$WR_HOME/bin/ptpd -A -c >& /dev/null &
eval $WR_HOME/bin/ptpd -A -c $LOGPIPE_PTP \&
exit 0
fi
if [ ! -x $WR_HOME/bin/ppsi ]; then
......@@ -24,6 +46,6 @@ for i in $(seq 1 10); do
if [ -S /tmp/.minipc/wrsw_hal ]; then break; fi
sleep 1
done
$WR_HOME/bin/ppsi >& /dev/kmsg &
eval $WR_HOME/bin/ppsi $LOGPIPE_PTP \&
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment