restart.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  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. get_service_command() {
  13. for command in systemctl service; do
  14. if which $command &>/dev/null; then
  15. echo $command && return
  16. fi
  17. done
  18. echo "sysv"
  19. }
  20. cmd="$( get_service_command )"
  21. echo "Detected service control platform '$cmd'; using it to restart Jellyfin..."
  22. case $cmd in
  23. 'systemctl')
  24. echo "sleep 0.5; /usr/bin/sudo $( which systemctl ) start jellyfin" | at now
  25. ;;
  26. 'service')
  27. echo "sleep 0.5; /usr/bin/sudo $( which service ) jellyfin start" | at now
  28. ;;
  29. 'sysv')
  30. echo "sleep 0.5; /usr/bin/sudo /etc/init.d/jellyfin start" | at now
  31. ;;
  32. esac
  33. exit 0