jellyfin.init 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. ### BEGIN INIT INFO
  2. # Provides: Jellyfin Media Server
  3. # Required-Start: $local_fs $network
  4. # Required-Stop: $local_fs
  5. # Default-Start: 2 3 4 5
  6. # Default-Stop: 0 1 6
  7. # Short-Description: Jellyfin Media Server
  8. # Description: Runs Jellyfin Server
  9. ### END INIT INFO
  10. # Carry out specific functions when asked to by the system
  11. pidfile="/var/run/jellyfin.pid"
  12. pid=`cat $pidfile`
  13. case "$1" in
  14. start)
  15. if [ "$pid" == "" ]; then
  16. echo "Starting Jellyfin..."
  17. . /etc/default/jellyfin
  18. nohup su -u $JELLYFIN_USER -c /usr/bin/jellyfin $JELLYFIN_ARGS
  19. echo ?? > $pidfile
  20. else
  21. echo "Jellyfin already running"
  22. fi
  23. ;;
  24. stop)
  25. if [ "$pid" != "" ]; then
  26. echo "Stopping Jellyfin..."
  27. kill $pid
  28. sleep 2
  29. rm -f $pidfile
  30. else
  31. echo "Jellyfin not running"
  32. fi
  33. ;;
  34. status)
  35. if [ "$pid" != "" ]; then
  36. echo "Jellyfin running as $pid"
  37. ps -f $pid
  38. else
  39. echo "Jellyfin is not running"
  40. fi
  41. ;;
  42. *)
  43. echo "Usage: $0 {start|stop}"
  44. exit 1
  45. ;;
  46. esac