mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 00:00:13 -08:00
created shell script to {start|stop|restart|status} Plex Media Server
This commit is contained in:
47
plex.sh
Executable file
47
plex.sh
Executable 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
|
||||||
Reference in New Issue
Block a user