mptsd reads mpegts streams from udp/multicast or http and combines them into one multiple program stream that is suitable for outputting to DVB-C modulator. Tested with Dektec DTE-3114 Quad QAM Modulator and used in production in small DVB-C networks. https://georgi.unixsol.org/programs/mptsd/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rc.mptsd 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #!/bin/sh
  2. # Server control script
  3. # Copyright (C) 2007-2010 Unix Solutions Ltd.
  4. PATH="/home/iptv:/bin:/sbin:/usr/bin:/usr/local/bin"
  5. export PATH
  6. cd $(dirname $0)
  7. CONFIG="$(basename $0).conf"
  8. if [ ! -r $CONFIG ]
  9. then
  10. echo "[ERROR] $CONFIG is not found."
  11. exit 1
  12. fi
  13. . ./$CONFIG
  14. istart() {
  15. echo "[START] Starting $PRGNAME."
  16. if [ ! -f "$SERVER" -o ! -x "$SERVER" ]
  17. then
  18. echo "[ERROR] $SERVER does not exist or it's not executable."
  19. exit 1
  20. fi
  21. if [ -r "$PIDFILE" ]
  22. then
  23. fpid=$(cat "$PIDFILE" 2>/dev/null)
  24. rpid=$(pidof $PRGNAME 2>/dev/null)
  25. if [ -n "$rpid" -a "0$fpid" -eq "0$rpid" ]
  26. then
  27. echo "[ERROR] $PRGNAME is already running: (pid $rpid)"
  28. exit 1
  29. else
  30. echo "[ERROR] $PIDFILE is stale, $PRGNAME is not running. Deleting it pid file."
  31. rm $PIDFILE
  32. fi
  33. fi
  34. echo "[CMD ] $SERVER $PARAMS"
  35. cd $(dirname $SERVER)
  36. $SERVER $PARAMS
  37. if [ $? -eq 0 ]
  38. then
  39. echo "[OK ] $PRGNAME started."
  40. else
  41. echo "[ERROR] $PRGNAME not started."
  42. fi
  43. }
  44. istop() {
  45. echo "[STOP ] Stopping $PRGNAME."
  46. killall $PRGNAME
  47. if [ $? -eq 0 ]
  48. then
  49. echo -n "[WAIT ] Waiting"
  50. echo -n "." && sleep .3
  51. echo -n "." && sleep .3
  52. echo -n "." && sleep .3
  53. echo -n "." && sleep .2
  54. echo "."
  55. if [ -r "$PIDFILE" ]
  56. then
  57. RPID=$(pidof $PRGNAME 2>/dev/null)
  58. if [ "0$RPID" -ne "0" ]
  59. then
  60. echo "[ERROR] $PRGNAME is still running: (pid $(cat $PIDFILE)). Kill -9ing it."
  61. killall -9 $PRGNAME
  62. fi
  63. fi
  64. echo "[OK ] $PRGNAME is stopped."
  65. fi
  66. }
  67. icheck() {
  68. if [ -r "$PIDFILE" ]
  69. then
  70. fpid=$(cat "$PIDFILE" 2>/dev/null)
  71. rpid=$(pidof $PRGNAME 2>/dev/null)
  72. if [ -n "$rpid" -a "0$fpid" -eq "0$rpid" ]
  73. then
  74. echo "[CHECK] $PRGNAME is already running: (pid $rpid)"
  75. else
  76. istart
  77. fi
  78. else
  79. echo "[CHECK] Stop and start"
  80. istop
  81. istart
  82. fi
  83. }
  84. istatus() {
  85. rpid=$(pidof $PRGNAME 2>/dev/null)
  86. echo "[STATUS] $PRGNAME pidfile pid: $(cat $PIDFILE 2>/dev/null)"
  87. echo "[STATUS] $PRGNAME pidof pid: $rpid"
  88. if [ -z "$rpid" ]
  89. then
  90. echo "[STATUS] $PRGNAME is not running."
  91. else
  92. if [ -n "$rpid" -a "0$(cat $PIDFILE 2>/dev/null)" -eq "0$rpid" ]
  93. then
  94. echo "[STATUS] $PRGNAME is running"
  95. else
  96. echo "[STATUS] $PRGNAME is running but no pid file exist: $PIDFILE"
  97. fi
  98. ps ax | grep "$PRGNAME -i" | grep -v grep
  99. fi
  100. }
  101. ireconnect() {
  102. echo "[RECONN] Sending SIGUSR1 to $PRGNAME causing reconnect"
  103. kill -USR1 $(pidof $PRGNAME)
  104. }
  105. ireload() {
  106. echo "[RECONN] Sending SIGHUP to $PRGNAME causing configuration reload"
  107. kill -HUP $(pidof $PRGNAME)
  108. }
  109. case "$1" in
  110. 'start')
  111. if [ "$2" != "" ]
  112. then
  113. sleep "$2"
  114. fi
  115. istart
  116. ;;
  117. 'stop')
  118. istop
  119. ;;
  120. 'check')
  121. icheck
  122. ;;
  123. 'status')
  124. istatus
  125. ;;
  126. 'restart')
  127. istop
  128. istart
  129. ;;
  130. 'reload')
  131. ireload
  132. ;;
  133. 'reconnect')
  134. ireconnect
  135. ;;
  136. *)
  137. echo "Usage: `basename $0` start|stop|check|restart|reload|reconnect|status"
  138. esac