created shell script to {start|stop|restart|status} Plex Media Server

This commit is contained in:
Peter Wood
2024-09-27 08:08:48 -04:00
parent 745c3ef3ff
commit 09ddf8fcfa

47
plex.sh Executable file
View File

@@ -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