Welcome to mirror list, hosted at ThFree Co, Russian Federation.

mumble-server-user-wrapper « scripts - github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a2c3f50fed64b0faab1bf27962a539c8d7465a17 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#! /bin/bash
#
# Copyright 2005-2020 The Mumble Developers. All rights reserved.
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file at the root of the
# Mumble source tree or at <https://www.mumble.info/LICENSE>.

DIR=$HOME/murmur
SYSDIR=/usr/share/doc/mumble-server/examples

if [ $UID == 0 ] || [ $EUID == 0 ]; then
  echo "You should never run this script as root. If you want a system-wide install, see "
  echo "the documentation included with this package."
  exit 2
fi

unset SETPW
DO_KILL=0
DO_STATUS=0
DO_INITONLY=0

while getopts "sid:p:k" flag; do
  case "$flag" in
  	"s")
  		DO_STATUS=1
  		;;
  	"i")
  		DO_INITONLY=1
  		;;
  	"d")
  		DIR=$OPTARG
  		;;
  	"p")
  		SETPW=$OPTARG
  		;;
  	"k")
  		DO_KILL=1
  		;;
  	*)
  		exit 2
  		;;
  esac
done
DBUSFILE=$DIR/.dbus.sh

if [ $DO_KILL == 1 ]; then
	if pkill -U $UID -u $EUID -o -x -f "/usr/sbin/murmurd -ini $DIR/murmur.ini"; then
		echo "Termination signal sent"
	else
		echo "Murmur process not found; not terminated"
        exit 2
	fi
	exit 0
fi

if [ ! -d $DIR ]; then
  echo "Making $DIR"
  mkdir -m 0700 $DIR
fi

cd $DIR || exit 2

if [ ! -f $DIR/murmur.ini ]; then
  echo "Creating $DIR/murmur.ini"
  if [ -f $SYSDIR/murmur.ini ]; then
    cp $SYSDIR/murmur.ini $DIR
  elif [ -f $SYSDIR/murmur.ini.gz ]; then
    gzip -cd $SYSDIR/murmur.ini.gz > $DIR/murmur.ini
  else
    echo "Could not find template for murmur.ini in $SYSDIR."
    exit 2
  fi
elif [ $DO_INITONLY == 1 ]; then
  echo "$DIR/murmur.ini already exists, initialization failed."
  exit 2
fi

if [ $DO_INITONLY == 1 ]; then
  echo "Initialization done. Please edit $DIR/murmur.ini"
  exit 0
fi

if [ "X$SETPW" != "X" ]; then
	echo "Setting superuser password to \"$SETPW\""
	/usr/sbin/murmurd -ini $DIR/murmur.ini -supw $SETPW
	exit 0
fi

PID=$(pgrep -U $UID -u $EUID -o -x -f "/usr/sbin/murmurd -ini $DIR/murmur.ini")

if [ $DO_STATUS == 1 ]; then
	if [ "X$PID" != "X" ]; then
		echo "Murmur is running"
		exit 1
	else
		echo "Murmur is not running"
		exit 0
	fi
fi

if [ "X$PID" != "X" ]; then
  echo "Murmur is already running."
  exit 1
fi

DBUS_SESSION_BUS_ADDRESS=invalid:/
[ -f $DBUSFILE ] && . $DBUSFILE

if ! dbus-send --print-reply --dest=org.freedesktop.DBus --type=method_call / org.freedesktop.DBus.GetId 2> /dev/null > /dev/null; then
  echo "Launching D-Bus session"
  dbus-launch --sh-syntax > $DBUSFILE
  . $DBUSFILE
  if ! dbus-send --print-reply --dest=org.freedesktop.DBus --type=method_call / org.freedesktop.DBus.GetId 2> /dev/null > /dev/null; then
    echo "Failed to launch session DBUS, bailing out."
    exit 2
  fi
fi

echo "Starting Murmur"
exec /usr/sbin/murmurd -ini $DIR/murmur.ini