I have a program that I start in a console with the command /etc/init.d/stream start
It works fine but I don't get a return to the hash prompt in the console like I should. What I get in the console is:
Code:
[root@localhost ~]# /etc/init.d/stream start
Starting service
Service started
[root@localhost ~]# Found AV/C device with GUID 0x002011011501d694
Waiting for DV...
Capture Started
if I press return again on the keyboard the hash prompt comes back but I need it to occur automatically.
this is the startup script (/etc/init.d/stream):
Code:
#!/bin/sh
### BEGIN INIT INFO
# Provides: stream
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: start ffmpeg
### END INIT INFO
SCRIPT="dvgrab -format dv1 - | ffmpeg -deinterlace -f dv -i - -f flv \
-vcodec flv -s 640x360 -qscale 3.5 -acodec libmp3lame \
-ab 32k -ar 22050 'rtmp://172.16.1.250:1935/live/livestream1'"
RUNAS=root
PIDFILE=/var/run/stream.pid
LOGFILE=/var/log/stream.log
start() {
if [ -f /var/run/$PIDNAME ] && kill -0 $(cat /var/run/$PIDNAME); then
echo 'Service already running' >&2
return 1
fi
echo 'Starting serviceā¦' >&2
local CMD="$SCRIPT &> \"$LOGFILE\" & echo \$!"
su -c "$CMD" $RUNAS > "$PIDFILE"
echo 'Service started' >&2
}
stop() {
if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
echo 'Service not running' >&2
return 1
fi
echo 'Stopping serviceā¦' >&2
kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
echo 'Service stopped' >&2
}
uninstall() {
echo -n "Are you really sure you want to uninstall this service? That cannot be undone. [yes|No] "
local SURE
read SURE
if [ "$SURE" = "yes" ]; then
stop
rm -f "$PIDFILE"
echo "Notice: log file is not be removed: '$LOGFILE'" >&2
update-rc.d -f stream remove
rm -fv "$0"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
uninstall)
uninstall
;;
retart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart|uninstall}"
esac
I've tried both '&' and '$' on the command both in the console and in the script but it doesn't work.
what do I need to do to make this this script behave poperly in the console?