Commit e0a757fe authored by Adam Wujek's avatar Adam Wujek 💬

rootfs: split start-daemons.sh.in into init scripts

Split start-daemons.sh.in into init scripts for:
--HAL
--RTUd
--PPSI
Since HAL, RTUd, PPSI have already waiting for dependent processess
implemented, we're allowed to spawn them (semi) simultaneously.

Additionally:
--Remove start-daemons.sh.in
--Remove updating start-daemons.sh.in log values in apply_dot-config
--Create links in /etc/rcS/ to init scripts

NOTE: Be sure that no init script has the same name as running program.
      It may cause problems for "pidof".
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 040f7d0b
#!/bin/sh
dotconfig=/wr/etc/dot-config
start() {
echo -n "Starting HAL daemon: "
if [ -f $dotconfig ]; then
. $dotconfig
else
echo "$0 unable to source dot-config ($dotconfig)!"
fi
WRS_LOG=$CONFIG_WRS_LOG_HAL
# if empty turn it to /dev/null
if [ -z $WRS_LOG ]; then
WRS_LOG="/dev/null";
fi
# if a pathname, use it
if echo "$WRS_LOG" | grep / > /dev/null; then
eval LOGPIPE=\" \> $WRS_LOG 2\>\&1 \";
else
# not a pathname: use verbatim
eval LOGPIPE=\" 2\>\&1 \| logger -t wr-switch -p $WRS_LOG\"
fi
# be carefull with pidof, no running script should have the same name as process
if pidof wrsw_hal > /dev/null; then
# wrsw_hal already running
echo "Failed (already running?)"
else
eval /wr/bin/wrsw_hal $LOGPIPE \&
echo "OK"
fi
}
stop() {
echo -n "Stopping HAL "
start-stop-daemon -K -q --exec /wr/bin/wrsw_hal
if [ $? -eq 0 ]; then
echo "OK"
else
echo "Failed"
fi
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
;;
esac
#!/bin/sh
dotconfig=/wr/etc/dot-config
start() {
echo -n "Starting PTP daemon: "
if [ -f $dotconfig ]; then
. $dotconfig
else
echo "$0 unable to source dot-config ($dotconfig)!"
fi
WRS_LOG=$CONFIG_WRS_LOG_PTP
# if empty turn it to /dev/null
if [ -z $WRS_LOG ]; then
WRS_LOG="/dev/null";
fi
# if a pathname, use it
if echo "$WRS_LOG" | grep / > /dev/null; then
eval LOGPIPE=\" \> $WRS_LOG 2\>\&1 \";
else
# not a pathname: use verbatim
eval LOGPIPE=\" 2\>\&1 \| logger -t wr-switch -p $WRS_LOG\"
fi
# be carefull with pidof, no running script should have the same name as process
if pidof ppsi > /dev/null; then
# ppsi already running
echo "Failed (already running?)"
else
eval /wr/bin/ppsi $LOGPIPE \&
echo "OK"
fi
}
stop() {
echo -n "Stopping PTP: "
start-stop-daemon -K -q --exec /wr/bin/ppsi
if [ $? -eq 0 ]; then
echo "OK"
else
echo "Failed"
fi
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
;;
esac
#!/bin/sh
dotconfig=/wr/etc/dot-config
start() {
echo -n "Starting RTUd daemon: "
if [ -f $dotconfig ]; then
. $dotconfig
else
echo "$0 unable to source dot-config ($dotconfig)!"
fi
WRS_LOG=$CONFIG_WRS_LOG_RTU
# if empty turn it to /dev/null
if [ -z $WRS_LOG ]; then
WRS_LOG="/dev/null";
fi
# if a pathname, use it
if echo "$WRS_LOG" | grep / > /dev/null; then
eval LOGPIPE=\" \> $WRS_LOG 2\>\&1 \";
else
# not a pathname: use verbatim
eval LOGPIPE=\" 2\>\&1 \| logger -t wr-switch -p $WRS_LOG\"
fi
# be carefull with pidof, no running script should have the same name as process
if pidof rtud > /dev/null; then
# rtud already running
echo "Failed (already running?)"
else
eval /wr/bin/wrsw_rtud $LOGPIPE \&
# ensure we receive UDP PTP frames, since ppsi supports UDP too.
/wr/bin/rtu_stat add 01:00:5e:00:01:81 18 0 &
echo "OK"
fi
}
stop() {
echo -n "Stopping RTUd "
start-stop-daemon -K -q --exec /wr/bin/wrsw_rtud
if [ $? -eq 0 ]; then
echo "OK"
else
echo "Failed"
fi
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
;;
esac
../init.d/hald.sh
\ No newline at end of file
../init.d/ppsi.sh
\ No newline at end of file
../init.d/rtud.sh
\ No newline at end of file
......@@ -80,14 +80,6 @@ set | tr -d \' | grep CONFIG_SNMP | sed 's/=/ /' | while read varname value; do
done
copy_conf /wr/etc/snmpd.conf
# Fix log values
cp /wr/sbin/start-daemons.sh.in $T
set | tr -d \' | grep CONFIG_WRS_LOG | sed 's/=/ /' | while read varname value; do
if [ -z "$value" ]; then continue; fi
sed -i "/$varname/ s,$varname,$value," $T
done
copy_conf /wr/sbin/start-daemons.sh
# Select a ppsi configuration file
if [ "$CONFIG_PTP_PORT_PARAMS" = "y" ]; then
/wr/bin/assembly_ppsi_conf.sh
......
#!/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"
eval $WR_HOME/bin/wrsw_hal $LOGPIPE_HAL \&
eval $WR_HOME/bin/wrsw_rtud $LOGPIPE_RTU \&
eval $WR_HOME/bin/ppsi $LOGPIPE_PTP \&
# ensure we receive UDP PTP frames, since ppsi supports UDP too.
$WR_HOME/bin/rtu_stat add 01:00:5e:00:01:81 18 0 &
......@@ -62,5 +62,4 @@ insmod $WR_HOME/lib/modules/wr-nic.ko macaddr=$val
insmod $WR_HOME/lib/modules/wr_rtu.ko
insmod $WR_HOME/lib/modules/wr_pstats.ko pstats_nports=18
insmod $WR_HOME/lib/modules/wr_clocksource.ko
$WR_HOME/sbin/start-daemons.sh
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