restart.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. # restart.sh - Jellyfin server restart script
  3. # Part of the Jellyfin project (https://github.com/jellyfin)
  4. #
  5. # This script restarts the Jellyfin daemon on Linux when using
  6. # the Restart button on the admin dashboard. It supports the
  7. # systemctl, service, and traditional /etc/init.d (sysv) restart
  8. # methods, chosen automatically by which one is found first (in
  9. # that order).
  10. #
  11. # This script is used by the Debian/Ubuntu/Fedora/CentOS packages.
  12. # This is the Right Way(tm) to check if we are booted with
  13. # systemd, according to sd_booted(3)
  14. if [ -d /run/systemd/system ]; then
  15. cmd=systemctl
  16. else
  17. # Everything else is really hard to figure out, so we just use
  18. # service(8) if it's available - that works with most init
  19. # systems/distributions I know of, including FreeBSD
  20. if type service >/dev/null 2>&1; then
  21. cmd=service
  22. else
  23. # If even service(8) isn't available, we just try /etc/init.d
  24. # and hope for the best
  25. if [ -d /etc/init.d ]; then
  26. cmd=sysv
  27. else
  28. echo "Unable to detect a way to restart Jellyfin; bailing out" 1>&2
  29. echo "Please report this bug to https://github.com/jellyfin/jellyfin/issues" 1>&2
  30. exit 1
  31. fi
  32. fi
  33. fi
  34. if type sudo >/dev/null 2>&1; then
  35. sudo_command=sudo
  36. else
  37. sudo_command=
  38. fi
  39. echo "Detected service control platform '$cmd'; using it to restart Jellyfin..."
  40. case $cmd in
  41. 'systemctl')
  42. echo "sleep 0.5; $sudo_command systemctl start jellyfin" | at now
  43. ;;
  44. 'service')
  45. echo "sleep 0.5; $sudo_command service jellyfin start" | at now
  46. ;;
  47. 'sysv')
  48. echo "sleep 0.5; /usr/bin/sudo /etc/init.d/jellyfin start" | at now
  49. ;;
  50. esac
  51. exit 0