From 09ddf8fcfac3facc7de8ea3c842f4b6e7ab6b7b1 Mon Sep 17 00:00:00 2001 From: Peter Wood Date: Fri, 27 Sep 2024 08:08:48 -0400 Subject: [PATCH] created shell script to {start|stop|restart|status} Plex Media Server --- plex.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 plex.sh 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