summaryrefslogtreecommitdiff
blob: e934d05d880c387fd5239c08f737ae17b043b566 (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
#!/bin/bash
MULOG=0
PIDPATH="$HOME/.museekd"

while getopts ckmqrsh name
do
  case $name in
    c) close=1;;
    k) kill=1;;
    m) mucous=1;;
    q) museeq=1;;
    r) restart=1;;
    s) scan=1;;
    h|?) help=1;;
  esac
done

if [ $help ]; then
  echo -e "Usage: `basename $0` [OPTIONS]"
  echo -e "This will start museekd by default. The following can be done in addition:"
  echo -e "  -r restart museekd"
  echo -e "  -s rescan shares"
  echo -e "  -q start museeq"
  echo -e "  -m start mucous"
  echo -e "  -c kill museekd when mucous closes"
  echo -e "  -k kill museekd and exit"
  echo -e "  -h display this help and exit"
  exit 0
elif [ "$kill" -o "$restart" ]; then
  killall museekd
  [ $kill ] && exit
fi

if [ ! -d  "/proc/`cat $PIDPATH/museekd.pid`" ]; then
  exec museekd &
  echo $! > $PIDPATH/museekd.pid
fi

if [ $MULOG != 0 -a $MULOG -a ! -d "/proc/`cat $PIDPATH/mulog.pid`" ]; then
  exec mulog &
  echo $! > $PIDPATH/mulog.pid
fi

[ $scan ] && muscan -r >/dev/null 2>&1 && killall -q -HUP museekd &
[ $museeq ] && exec museeq >/dev/null 2>&1 &
[ $mucous ] && mucous; [ $close ] && killall -q museekd