diff --git a/plex.sh b/plex.sh new file mode 100755 index 0000000..8e5680d --- /dev/null +++ b/plex.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# create bash shell script accepts parameters from the command line and performs an action for each parameter. the script will be used to start, stop, restart, and return the current status of the Plex Media Server +PLEX_SERVICE="plexmediaserver" + +start_plex() { + sudo systemctl start $PLEX_SERVICE + echo "Plex Media Server started." +} + +stop_plex() { + sudo systemctl stop $PLEX_SERVICE + echo "Plex Media Server stopped." +} + +restart_plex() { + sudo systemctl restart $PLEX_SERVICE + echo "Plex Media Server restarted." +} + +status_plex() { + sudo systemctl status $PLEX_SERVICE +} + +if [ $# -eq 0 ]; then + echo "Usage: $0 {start|stop|restart|status}" + exit 1 +fi + +case "$1" in + start) + start_plex + ;; + stop) + stop_plex + ;; + restart) + restart_plex + ;; + status) + status_plex + ;; + *) + echo "Usage: $0 {start|stop|restart|status}" + exit 1 + ;; +esac \ No newline at end of file