From: John F. <jo...@us...> - 2013-09-06 14:34:20
|
Update of /cvsroot/ingex/ingex/studio/scripts In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv11534 Added Files: ingex.sh Log Message: New start/stop script - works better on recent kde although can't close tabs --- NEW FILE: ingex.sh --- #!/bin/sh # Starts the Ingex processes as enabled in the file ~/ingex.conf or /etc/ingex.conf usage="Usage: $0 [-start|-stop] [-h] Options: -a [start|stop] Action (start or stop) -h HD mode (only needed for start) " HD_MODE=0 START=1 while getopts 'a:h' OPT do case $OPT in h) HD_MODE=1 ;; a) if [ "$OPTARG" == "start" ] then START=1 elif [ "$OPTARG" == "stop" ] then START=0 else echo "${usage}" exit 1 fi ;; ?) echo "${usage}" exit 1 ;; esac done # Set defaults for Ingex processes and parameters # These can be overidden by ~/ingex.conf or /etc/ingex.conf declare -x INGEX_DIR="/home/ingex/ap-workspace/ingex" CAPTURE=1 MULTICAST=0 TRANSFER=0 INGEX_MONITOR=0 SYSTEM_MONITOR=0 QUAD_SPLIT=0 RECORDERS= CAPTURE_PROGRAM="DVS_SDI" # Nameserver details NAMESERVER=":8888" DOTTED_DECIMAL=1 # Database details DB_HOST='localhost' DB_NAME='prodautodb' DB_USER='bamzooki' DB_PASS='bamzooki' # *** Default HD Capture options **** HD_CAPTURE_CHANNELS=2 HD_CAPTURE_MODE="1920x1080i50" HD_CAPTURE_PRIMARY_BUFFER="YUV422" HD_CAPTURE_SECONDARY_BUFFER="YUV422" HD_CAPTURE_TIMECODE="LTC" #HD_CAPTURE_OPTIONS="-aes8" HD_CAPTURE_OPTIONS="" # HD Recorders (space-separated) HD_RECORDERS="Ingex-HD" # HD Quad player options HD_QUAD_OPTIONS="--disable-shuttle --audio-lineup -18 --audio-mon 2 --source-aspect 16:9 --quad-split --hide-progress-bar --shm-in 0s --shm-in 1s" # Default SD Capture options SD_CAPTURE_CHANNELS=4 SD_CAPTURE_MODE="PAL" SD_CAPTURE_PRIMARY_BUFFER="YUV422" SD_CAPTURE_SECONDARY_BUFFER="None" SD_CAPTURE_TIMECODE="LTC" SD_CAPTURE_OPTIONS="" # SD Recorders (space-separated) SD_RECORDERS="Ingex" # SD Quad player options SD_QUAD_OPTIONS="--disable-shuttle --audio-lineup -18 --audio-mon 2 --source-aspect 16:9 --quad-split --hide-progress-bar --shm-in 0p --shm-in 1p --shm-in 2p --shm-in 3p" # Transfer (copy) options # Set COPY_FTP_SERVER to be the hostname of your ftp server, # otherwise the transfer will be done by file copying. COPY_FTP_SERVER= #COPY_FTP_SERVER='yourFTPserver' COPY_FTP_USER='ingex' COPY_FTP_PASSWORD='ingex' # Priority 1 files (usually the offline quality) can also be copied to a second destination, typically a local USB drive. Put the destination here to activate this (e.g. /video_removeable which might link to your usb drive) #COPY_EXTRA_DEST='/video_removeable' COPY_EXTRA_DEST= # **** end of transfer options **** # ***** Multicasting ***** # Set the multicast address and first port to use. The same address will # be used for all channels (on this PC) but the port number will increment MULTICAST_ADDR='239.255.1.1' MULTICAST_FIRST_PORT=2000 # Set size of down-scaled image. Suggest 360x288 for an mpeg stream or 240x192 # for simple down-scaling #MULTICAST_SIZE='240x192' MULTICAST_SIZE='360x288' # For an mpeg transport stream set the next parameter to 1, for image scaling # only set it to zero. Set your desired mpeg bitrate (kb/s) too. MULTICAST_MPEG_TS=1 MULTICAST_MPEG_BIT_RATE='1000' # **** end of multicast options **** # ********** There are no options to edit below this line ************* #********************************************************************** # Get the required configuration if [ -r $HOME/ingex.conf ] then # Read in ingex mode configuration . $HOME/ingex.conf elif [ -r /etc/ingex.conf ] then # Read in ingex mode configuration . /etc/ingex.conf fi # set up paths etc capture_path="$INGEX_DIR/studio/capture/" xfer_path="$INGEX_DIR/studio/processing/media_transfer/" scripts_path="$INGEX_DIR/studio/scripts/" # recorder details recorder_path="$INGEX_DIR/studio/ace-tao/Recorder/" run_recorder="./Recorder" routerlogger_path="$INGEX_DIR/studio/ace-tao/routerlog/" run_routerLogger="./run_routerlogger.sh" # assemble the database arguments DB_PARAMS="--dbhost $DB_HOST --dbname $DB_NAME --dbuser $DB_USER --dbpass $DB_PASS" # Allow KDE apps to work properly over the network #export $(dbus-launch) # Check to see if capture is already running. If it is, check with the user to avoid stopping it by mistake ABORT=0 if sudo killall -q -0 -e dvs_sdi then kdialog --title "Confirm... " --warningyesno "Ingex is running. Are you sure you want to stop it?" ABORT=$? fi if sudo killall -q -0 -e bmd_sdi then kdialog --title "Confirm... " --warningyesno "Ingex is running. Are you sure you want to stop it?" ABORT=$? fi if [ $ABORT -ne 0 ] ; then exit 1 fi # Kill Ingex processes, if they're running echo "Checking for Ingex processes..." PROCESSES="player Recorder nexus_multicast nexus_web system_info_web dvs_sdi dvs_dummy bmd_sdi testgen xferserver.pl" for PROC in $PROCESSES ; do if sudo killall -q -0 -e ${PROC} then sudo killall -s SIGINT -e ${PROC} while sudo killall -q -0 -e ${PROC} do usleep 100000 done fi done # Can't kill konsole because all konsoles use same PID # killall konsole # You can find shells in konsole tabs with ps -fC bash and suitable grep but killing them # doesn't close tab. # To close a tab you can use # qdbus org.kde.konsole /Sessions/12 sendText "exit # " # Just need to find Session number # qdbus org.kde.konsole # To start a new window # qdbus org.kde.konsole /MainApplication org.kde.KUniqueApplication.newInstance # If any were already running, by now, all Ingex precesses [and their konsoles] should have stopped echo "All Ingex processes stopped." # If not starting, exit here if [ $START -ne 1 ] then exit 0 fi # We are starting Ingex echo "Starting Ingex..." # set corba options CORBA_OPTIONS="-ORBDefaultInitRef corbaloc:iiop:$NAMESERVER -ORBDottedDecimalAddresses $DOTTED_DECIMAL" # set the capture mode for HD or SD if [ $HD_MODE -ge 1 ] ; then # Set capture options to HD CAPTURE_CHANNELS="${HD_CAPTURE_CHANNELS}" CAPTURE_MODE="${HD_CAPTURE_MODE}" CAPTURE_PRIMARY_BUFFER="${HD_CAPTURE_PRIMARY_BUFFER}" CAPTURE_SECONDARY_BUFFER="${HD_CAPTURE_SECONDARY_BUFFER}" CAPTURE_TIMECODE="${HD_CAPTURE_TIMECODE}" CAPTURE_OPTIONS="${HD_CAPTURE_OPTIONS}" # Recorders RECORDERS="${HD_RECORDERS}" # Quad player options QUAD_OPTIONS="${HD_QUAD_OPTIONS}" else # Set capture options to SD CAPTURE_CHANNELS="${SD_CAPTURE_CHANNELS}" CAPTURE_MODE="${SD_CAPTURE_MODE}" CAPTURE_PRIMARY_BUFFER="${SD_CAPTURE_PRIMARY_BUFFER}" CAPTURE_SECONDARY_BUFFER="${SD_CAPTURE_SECONDARY_BUFFER}" CAPTURE_TIMECODE="${SD_CAPTURE_TIMECODE}" CAPTURE_OPTIONS="${SD_CAPTURE_OPTIONS}" # Recorders (space-separated) RECORDERS="${SD_RECORDERS}" # Quad player options QUAD_OPTIONS="${SD_QUAD_OPTIONS}" fi # export some settings, so other scripts can pick them up if necessary declare -x INGEX_CHANNELS=${CAPTURE_CHANNELS} function SetupTab { # arg: name of tab RC_FILE=/tmp/ingex-$1-bashrc HISTORY=~/.ingex-$1-bash-history rm $HISTORY 2>/dev/null echo "HISTFILE=$HISTORY" > $RC_FILE #separate history for each tab so that we can easily repeat commands echo "konsole -p tabtitle=$1 --new-tab -e bash --rcfile $RC_FILE" >> $KONSOLE_CMD_FILE } function WriteCommand { #arg: command echo "echo \"$1\"" >> $RC_FILE #so that we can see what the command is; quotes allow semicolons echo $1 >> $RC_FILE #execute the command on startup echo $1 >> $HISTORY #allow the command to be manually re-issued } KONSOLE_CMD_FILE=/tmp/ingex-tabs # the file given to the konsole command, containing tab names and a command to be executed for each tab, which only seems to work as a single word, so each points to an executable file rm $KONSOLE_CMD_FILE 2>/dev/null # set the required script path to all sessions if [ $CAPTURE -ge 1 ] ; then SetupTab "Capture" WriteCommand "cd $capture_path" if [ $CAPTURE_PROGRAM = "DVS_SDI" ] ; then # sudo nice -10 WriteCommand "sudo nice --10 ./dvs_sdi -c $CAPTURE_CHANNELS -mode $CAPTURE_MODE -f $CAPTURE_PRIMARY_BUFFER -s $CAPTURE_SECONDARY_BUFFER -mc 0 -tt $CAPTURE_TIMECODE $CAPTURE_OPTIONS" elif [ $CAPTURE_PROGRAM = "DVS_DUMMY" ] ; then WriteCommand "sudo nice --10 ./dvs_dummy -c $CAPTURE_CHANNELS -mode $CAPTURE_MODE -f $CAPTURE_PRIMARY_BUFFER -s $CAPTURE_SECONDARY_BUFFER -mc 0 -tt $CAPTURE_TIMECODE $CAPTURE_OPTIONS" elif [ $CAPTURE_PROGRAM = "BMD_SDI" ] ; then WriteCommand "sudo nice --10 ./bmd_sdi -c $CAPTURE_CHANNELS -mode $CAPTURE_MODE -f $CAPTURE_PRIMARY_BUFFER -s $CAPTURE_SECONDARY_BUFFER -mc 0 -tt $CAPTURE_TIMECODE $CAPTURE_OPTIONS" elif [ $CAPTURE_PROGRAM = "TESTGEN" ] ; then WriteCommand "sudo nice --10 ./testgen -c $CAPTURE_CHANNELS" else echo "Invalid ingex.conf or argument. exit." return 1 fi fi # ** multicasting ** if [ $MULTICAST -ge 1 ] ; then SetupTab "Multicast" WriteCommand "cd $capture_path" # Prepare options. If mpeg transport stream, set -t option and bitrate if [ $MULTICAST_MPEG_TS -ge 1 ] ; then OPTIONS="-t -b ${MULTICAST_MPEG_BIT_RATE}" fi OPTIONS="${OPTIONS} -s ${MULTICAST_SIZE}" PORT=$MULTICAST_FIRST_PORT CHAN=0 while [ "$CHAN" -lt "$CAPTURE_CHANNELS" ] ; do #echo "Starting multicast channel ${CHAN}" WriteCommand "./nexus_multicast -c ${CHAN} -q ${OPTIONS} ${MULTICAST_ADDR}:${PORT} &\n" let CHAN=$CHAN+1 let PORT=$PORT+1 done fi # ** Transfer ** if [ $TRANSFER -ge 1 ] ; then SetupTab "Copy" WriteCommand "cd $xfer_path" if [ -n "${COPY_EXTRA_DEST}" ] ; then EXTRA_DEST="-e ${COPY_EXTRA_DEST}" fi if [ -z "${COPY_FTP_SERVER}" ] ; then WriteCommand "./xferserver.pl ${EXTRA_DEST}" else FTP_OPTIONS="'${COPY_FTP_SERVER} ${COPY_FTP_USER} ${COPY_FTP_PASSWORD}'" WriteCommand "./xferserver.pl ${EXTRA_DEST} -f $FTP_OPTIONS" fi fi if [ $INGEX_MONITOR -ge 1 ] ; then SetupTab "nexusWeb" WriteCommand "cd $capture_path" WriteCommand "./nexus_web" fi if [ $SYSTEM_MONITOR -ge 1 ] ; then SetupTab "sysInfo" WriteCommand "cd $capture_path" WriteCommand "./system_info_web" fi if [ $QUAD_SPLIT -ge 1 ] ; then SetupTab "Quad" WriteCommand "cd $scripts_path" WriteCommand "$INGEX_DIR/player/ingex_player/player $QUAD_OPTIONS" fi if [ $ROUTER_LOGGER -ge 1 ] ; then SetupTab "RouterLogger" WriteCommand "${run_routerLogger}" fi # Start recorders if any are set in the configuration - in the same konsole as they can be detached by the user if [ -n "$RECORDERS" ] ; then echo $RECORDERS for REC in $RECORDERS ; do echo "Starting recorder: $REC" SetupTab "Recorder_$REC" WriteCommand "cd $recorder_path" WriteCommand "${run_recorder} --name ${REC} ${DB_PARAMS} ${CORBA_OPTIONS}" done fi # Start it all up #konsole --tabs-from-file $KONSOLE_CMD_FILE --name "Ingex" #konsole --name "Ingex" -e bash $KONSOLE_CMD_FILE exec bash $KONSOLE_CMD_FILE |