summaryrefslogtreecommitdiff
path: root/multimedia/plexmediaserver/rc.plexmediaserver
diff options
context:
space:
mode:
authorLionel Young <lionelyoung@gmail.com>2013-12-07 01:26:38 +0700
committerErik Hanson <erik@slackbuilds.org>2013-12-14 10:53:00 -0600
commit6a96285402c4e872bddda77f55bdd9a4caa661c8 (patch)
tree3fc10c31cbc5b65784aa4f474cd1f2ddfbcb94e3 /multimedia/plexmediaserver/rc.plexmediaserver
parent7311b5c40ee55ae70890e74bf7ba270575ccb3b2 (diff)
downloadslackbuilds-6a96285402c4e872bddda77f55bdd9a4caa661c8.tar.gz
multimedia/plexmediaserver: Added (media center server).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'multimedia/plexmediaserver/rc.plexmediaserver')
-rw-r--r--multimedia/plexmediaserver/rc.plexmediaserver62
1 files changed, 62 insertions, 0 deletions
diff --git a/multimedia/plexmediaserver/rc.plexmediaserver b/multimedia/plexmediaserver/rc.plexmediaserver
new file mode 100644
index 0000000000..93598b361c
--- /dev/null
+++ b/multimedia/plexmediaserver/rc.plexmediaserver
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+# /etc/rc.d/rc.plexmediaserver - Start/stop/restart the plexmediaserver daemon.
+# To make plexmediaserver start automatically at boot, make this
+# file executable: chmod 0755 /etc/rc.d/rc.plexmediaserver and add it
+# to slackware's startup scripts (ie: rc.local)
+#
+
+PIDFILE="/var/run/plexmediaserver.pid"
+
+plexmediaserver_start() {
+ echo "Starting plexmediaserver..."
+ CHECK=$(ps aux | grep /usr/bin/start_pms | grep -v grep)
+ STATUS=$?
+
+ # make sure plexmediaserver isn't running yet
+ if [ "$STATUS" == "1" ]; then
+ touch $PIDFILE
+ chown plex:plex $PIDFILE
+
+ # Start plexmediaserver
+ sudo -u plex /usr/bin/start_pms &
+ else
+ echo "plexmediaserver is already active and running under PID: $(cat $PIDFILE)"
+ echo "if you think this is wrong, remove the offending PID file"
+ echo "and restart plexmediaserver"
+ exit 1
+ fi
+}
+
+plexmediaserver_stop() {
+ echo -n "Stopping plexmediaserver..."
+ if [ -r $PIDFILE ]; then
+ kill $(cat $PIDFILE)
+ killall "Plex Media Server"
+ rm $PIDFILE
+ echo "done"
+ else
+ killall "Plex Media Server"
+ rm $PIDFILE
+ echo "done"
+ fi
+}
+
+# Let's see how we are being called.
+case "$1" in
+ start)
+ plexmediaserver_start
+ ;;
+ stop)
+ plexmediaserver_stop
+ ;;
+ restart)
+ plexmediaserver_start
+ sleep 3
+ plexmediaserver_stop
+ ;;
+ *)
+ echo "Usage: $(basename $0) {start|stop|restart}"
+ exit 1
+ ;;
+esac