Skip to content

Instantly share code, notes, and snippets.

@ngmoviedo
Created May 5, 2020 22:53
Show Gist options
  • Save ngmoviedo/c549f625643b1896ce47aec7753bbe55 to your computer and use it in GitHub Desktop.
Save ngmoviedo/c549f625643b1896ce47aec7753bbe55 to your computer and use it in GitHub Desktop.
Simple script to enable and stop Jellyfin media server (requires root proviledges and systemd)
#!/bin/sh
# Check user name and ask for password
[ "$UID" -eq 0 ] || exec sudo "$0" "$@"
# Check if Jellyfin is inactive and start it
sudo systemctl status jellyfin | grep 'inactive' > /dev/null 2>&1
if [ $? != 0 ]
then
sudo systemctl start jellyfin > /dev/null
fi
# Check if Jellyfin has been stopped and enable it
sudo systemctl status jellyfin | grep 'failed' > /dev/null 2>&1
if [ $? != 0 ]
then
sudo systemctl start jellyfin > /dev/null
fi
# Display instructions
printf "\nRunning Jellyfin media server.\nWeb client: http://127.0.0.1:8096\nIP:https://192.168.1.134:8096\nPress 'q' to quit.\n"
# Stop Jellyfin if user presses 'q'
while : ; do
read -n 1 key <&1
if [[ $key = q ]] ; then
sudo systemctl stop jellyfin > /dev/null
printf "\nMedia server stopped.\n"
break
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment