1. ***This is from /etc/cron.daily/mythtv-backend*** 2. 3. #!/bin/sh 4. 5. su mythtv -c "mythfilldatabase --quiet" 6. 7. 8. ***And this is the init.d start script*** 9. 10. #! /bin/sh 11. ### BEGIN INIT INFO 12. # Provides: mythtv-backend 13. # Required-Start: $local_fs 14. # Required-Stop: $local_fs 15. # Default-Start: 24 16. # Default-Stop: S 17. # Short-Description: Start/Stop the MythTV server. 18. ### END INIT INFO 19. 20. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 21. DAEMON=/usr/bin/mythbackend 22. NAME="mythbackend" 23. DESC="MythTV server" 24. 25. test -x $DAEMON || exit 0 26. 27. set -e 28. 29. USER=mythtv 30. RUNDIR=/var/run/mythtv 31. ARGS="--daemon --logfile /var/log/mythtv/mythbackend.log --pidfile $RUNDIR/$NAME 32. .pid" 33. EXTRA_ARGS="" 34. NICE=0 35. 36. if [ -f /etc/default/mythtv-backend ]; then 37. . /etc/default/mythtv-backend 38. fi 39. 40. ARGS="$ARGS $EXTRA_ARGS" 41. 42. mkdir -p $RUNDIR 43. chown -R $USER $RUNDIR 44. 45. 46. case "$1" in 47. start) 48. if test -e $RUNDIR/$NAME.pid ; then 49. echo "mythbackend already running, use restart instead." 50. else 51. echo -n "Starting $DESC: $NAME" 52. start-stop-daemon --start --pidfile $RUNDIR/$NAME.pid \ 53. --chuid $USER --nicelevel $NICE --exec $DAEMON -- $ARGS 54. echo "." 55. fi 56. ;; 57. stop) 58. echo -n "Stopping $DESC: $NAME " 59. start-stop-daemon --stop --oknodo --pidfile $RUNDIR/$NAME.pid \ 60. --chuid $USER --exec $DAEMON -- $ARGS 61. test -e $RUNDIR/$NAME.pid && rm $RUNDIR/$NAME.pid 62. echo "." 63. ;; 64. restart|force-reload) 65. echo -n "Restarting $DESC: $NAME" 66. start-stop-daemon --stop --oknodo --pidfile $RUNDIR/$NAME.pid \ 67. --chuid $USER --exec $DAEMON -- $ARGS 68. echo "." 69. sleep 3 70. start-stop-daemon --start --pidfile $RUNDIR/$NAME.pid \ 71. --chuid $USER --nicelevel $NICE --exec $DAEMON -- $ARGS 72. echo "." 73. ;; 74. *) 75. N=/etc/init.d/$NAME 76. echo "Usage: $N {start|stop|restart|force-reload}" >&2 77. exit 1 78. ;; 79. esac 80. 81. exit 0