aboutsummaryrefslogtreecommitdiff
path: root/multimedia/mediatomb/rc.mediatomb
blob: 92804835b987c13c0f67fc6bb83e6614464b5dee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/sh
# Start/stop/restart mediatomb.
# $Id: rc.mediatomb,v 1.0 2010/11/01
# Authors: Heinz Wiesinger <pprkut@liwjatan.at>
# ---------------------------------------------------------------------------

MEDIATOMB_PIDFILE="/var/run/mediatomb/mediatomb.pid"
MEDIATOMB_LOGFILE="/var/log/mediatomb/mediatomb.log"

# Get additional configuration information from /etc/rc.d/rc.mediatomb.conf:
. /etc/rc.d/rc.mediatomb.conf

mediatomb_start()
{
  echo -n "Starting mediatomb ... "
  if [ -e "${MEDIATOMB_PIDFILE}" ]; then
    echo "already running!"
  else
    if [ "${MEDIATOMB_INTERFACE}" != "" ]; then
        MEDIATOMB_OPTIONS="$MEDIATOMB_OPTIONS --interface ${MEDIATOMB_INTERFACE}"
    fi
    if [ "${MEDIATOMB_PORT}" != "" ]; then
        MEDIATOMB_OPTIONS="$MEDIATOMB_OPTIONS --port ${MEDIATOMB_PORT}"
    fi
    /usr/bin/mediatomb \
        --daemon \
        --user ${MEDIATOMB_USER} \
        --group ${MEDIATOMB_GROUP} \
        --pidfile ${MEDIATOMB_PIDFILE} \
        --logfile ${MEDIATOMB_LOGFILE} \
        --config ${MEDIATOMB_CONFIG} \
        ${MEDIATOMB_OPTIONS}
    echo "done!"
  fi
}

mediatomb_stop()
{
  echo -n "Stopping mediatomb ... "
  if [ -e "${MEDIATOMB_PIDFILE}" ]; then
    kill -TERM $(cat ${MEDIATOMB_PIDFILE}) > /dev/null 2>&1
    echo "done!"
    rm -f "${MEDIATOMB_PIDFILE}"
  else
    echo "not running!"
  fi
}

mediatomb_restart()
{
  mediatomb_stop
  sleep 1
  mediatomb_start
}

mediatomb_status()
{
  if [ -e "${MEDIATOMB_PIDFILE}" ]; then
    echo "mediatomb is running!"
  else
    echo "mediatomb is not running!"
  fi
}

case "$1" in
'start')
  mediatomb_start
  ;;
'stop')
  mediatomb_stop
  ;;
'status')
  mediatomb_status
  ;;
'restart')
  mediatomb_restart
  ;;
*)
  echo "usage $0 start|stop|restart|status"
esac