Created
May 5, 2020 22:53
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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