.IR pkgstatedir .
The server will create this directory on startup if it does not exist.
.TP
-.B plugin \fIPATH\fR
+.B plugins \fIPATH\fR
Adds a directory to the plugin path. (This is also used by the web
interface.)
.IP
_configfile = "pkgconfdir/config"
_dbhome = "pkgstatedir"
+_userconf = True
# various regexps we'll use
_ws = re.compile(r"^[ \t\n\r]+")
self._readfile(_configfile)
if os.path.exists(privconf):
self._readfile(privconf)
- if os.path.exists(passfile):
+ if os.path.exists(passfile) and _userconf:
self._readfile(passfile)
self.state = 'disconnected'
{ "config", required_argument, 0, 'c' },
{ "debug", no_argument, 0, 'd' },
{ "no-debug", no_argument, 0, 'D' },
+ { "syslog", no_argument, 0, 's' },
+ { "no-syslog", no_argument, 0, 'S' },
{ 0, 0, 0, 0 }
};
" --version, -V Display version number\n"
" --config PATH, -c PATH Set configuration file\n"
" --debug, -d Turn on debugging\n"
+ " --[no-]syslog Force logging\n"
"\n"
"Deadlock manager for DisOrder. Not intended to be run\n"
"directly.\n");
}
int main(int argc, char **argv) {
- int n, err, aborted;
+ int n, err, aborted, logsyslog = !isatty(2);
set_progname(argv);
if(!setlocale(LC_CTYPE, "")) fatal(errno, "error calling setlocale");
- while((n = getopt_long(argc, argv, "hVc:dD", options, 0)) >= 0) {
+ while((n = getopt_long(argc, argv, "hVc:dDSs", options, 0)) >= 0) {
switch(n) {
case 'h': help();
case 'V': version();
case 'c': configfile = optarg; break;
case 'd': debugging = 1; break;
case 'D': debugging = 0; break;
+ case 'S': logsyslog = 0; break;
+ case 's': logsyslog = 1; break;
default: fatal(0, "invalid option");
}
}
- /* if stderr is a TTY then log there, otherwise to syslog */
- if(!isatty(2)) {
+ if(logsyslog) {
openlog(progname, LOG_PID, LOG_DAEMON);
log_default = &log_syslog;
}
#include <config.h>
#include "types.h"
+#include <getopt.h>
#include <locale.h>
#include <errno.h>
#include <unistd.h>
#include "log.h"
#include "configuration.h"
#include "speaker-protocol.h"
+#include "defs.h"
+
+static const struct option options[] = {
+ { "help", no_argument, 0, 'h' },
+ { "version", no_argument, 0, 'V' },
+ { "config", required_argument, 0, 'c' },
+ { "debug", no_argument, 0, 'd' },
+ { "no-debug", no_argument, 0, 'D' },
+ { "syslog", no_argument, 0, 's' },
+ { "no-syslog", no_argument, 0, 'S' },
+ { 0, 0, 0, 0 }
+};
+
+/* display usage message and terminate */
+static void help(void) {
+ xprintf("Usage:\n"
+ " disorder-normalize [OPTIONS]\n"
+ "Options:\n"
+ " --help, -h Display usage message\n"
+ " --version, -V Display version number\n"
+ " --config PATH, -c PATH Set configuration file\n"
+ " --debug, -d Turn on debugging\n"
+ " --[no-]syslog Force logging\n"
+ "\n"
+ "Audio format normalizer for DisOrder. Not intended to be run\n"
+ "directly.\n");
+ xfclose(stdout);
+ exit(0);
+}
+
+/* display version number and terminate */
+static void version(void) {
+ xprintf("disorder-normalize version %s\n", disorder_version_string);
+ xfclose(stdout);
+ exit(0);
+}
/** @brief Copy bytes from one file descriptor to another
* @param infd File descriptor read from
int main(int argc, char attribute((unused)) **argv) {
struct stream_header header, latest_format;
- int n, p[2], outfd = -1;
+ int n, p[2], outfd = -1, logsyslog = !isatty(2);
pid_t pid = -1;
set_progname(argv);
if(!setlocale(LC_CTYPE, ""))
fatal(errno, "error calling setlocale");
- if(argc > 1)
- fatal(0, "not intended to be invoked by users");
+ while((n = getopt_long(argc, argv, "hVc:dDSs", options, 0)) >= 0) {
+ switch(n) {
+ case 'h': help();
+ case 'V': version();
+ case 'c': configfile = optarg; break;
+ case 'd': debugging = 1; break;
+ case 'D': debugging = 0; break;
+ case 'S': logsyslog = 0; break;
+ case 's': logsyslog = 1; break;
+ default: fatal(0, "invalid option");
+ }
+ }
if(config_read(1))
fatal(0, "cannot read configuration");
- if(!isatty(2)) {
+ if(logsyslog) {
openlog(progname, LOG_PID, LOG_DAEMON);
log_default = &log_syslog;
}
}
void speaker_setup(ev_source *ev) {
- int sp[2], lfd;
+ int sp[2];
pid_t pid;
struct speaker_message sm;
if(socketpair(PF_UNIX, SOCK_DGRAM, 0, sp) < 0)
fatal(errno, "error calling socketpair");
- if(!isatty(2))
- lfd = logfd(ev, SPEAKER);
- else
- lfd = -1;
if(!(pid = xfork())) {
exitfn = _exit;
ev_signal_atfork(ev);
xdup2(sp[0], 1);
xclose(sp[0]);
xclose(sp[1]);
- if(lfd != -1) {
- xdup2(lfd, 2);
- xclose(lfd);
- }
signal(SIGPIPE, SIG_DFL);
#if 0
execlp("valgrind", "valgrind", SPEAKER, "--config", configfile,
- debugging ? "--debug" : "--no-debug", (char *)0);
+ debugging ? "--debug" : "--no-debug",
+ log_default == &log_syslog ? "--syslog" : "--no-syslog",
+ (char *)0);
#else
execlp(SPEAKER, SPEAKER, "--config", configfile,
- debugging ? "--debug" : "--no-debug", (char *)0);
+ debugging ? "--debug" : "--no-debug",
+ log_default == &log_syslog ? "--syslog" : "--no-syslog",
+ (char *)0);
#endif
fatal(errno, "error invoking %s", SPEAKER);
}
speaker_send(speaker_fd, &sm);
D(("sent SM_PLAY for %s", sm.id));
}
- execlp("disorder-normalize", "disorder-normalize", (char *)0);
+ /* TODO stderr shouldn't be redirected for disorder-normalize
+ * (but it should be for play_track() */
+ execlp("disorder-normalize", "disorder-normalize",
+ log_default == &log_syslog ? "--syslog" : "--no-syslog",
+ (char *)0);
fatal(errno, "executing disorder-normalize");
/* end of the innermost fork */
}
{ "config", required_argument, 0, 'c' },
{ "debug", no_argument, 0, 'd' },
{ "no-debug", no_argument, 0, 'D' },
+ { "syslog", no_argument, 0, 's' },
+ { "no-syslog", no_argument, 0, 'S' },
{ 0, 0, 0, 0 }
};
" --version, -V Display version number\n"
" --config PATH, -c PATH Set configuration file\n"
" --debug, -d Turn on debugging\n"
+ " --[no-]syslog Force logging\n"
"\n"
"Rescanner for DisOrder. Not intended to be run\n"
"directly.\n");
}
int main(int argc, char **argv) {
- int n;
+ int n, logsyslog = !isatty(2);
struct sigaction sa;
set_progname(argv);
mem_init();
if(!setlocale(LC_CTYPE, "")) fatal(errno, "error calling setlocale");
- while((n = getopt_long(argc, argv, "hVc:dD", options, 0)) >= 0) {
+ while((n = getopt_long(argc, argv, "hVc:dDSs", options, 0)) >= 0) {
switch(n) {
case 'h': help();
case 'V': version();
case 'c': configfile = optarg; break;
case 'd': debugging = 1; break;
case 'D': debugging = 0; break;
+ case 'S': logsyslog = 0; break;
+ case 's': logsyslog = 1; break;
default: fatal(0, "invalid option");
}
}
- /* If stderr is a TTY then log there, otherwise to syslog. */
- if(!isatty(2)) {
+ if(logsyslog) {
openlog(progname, LOG_PID, LOG_DAEMON);
log_default = &log_syslog;
}
gcry_randomize(pwbin, sizeof pwbin, GCRY_STRONG_RANDOM);
pwhex = hex(pwbin, sizeof pwbin);
/* Create the file */
- if((fd = open(privconfignew, O_WRONLY|O_CREAT, 0600)) < 0)
- fatal(errno, "error creating %s", privconfignew);
+ if((fd = open(privconfignew, O_WRONLY|O_CREAT, 0600)) < 0) {
+ error(errno, "error creating %s", privconfignew);
+ return; /* not fatal! */
+ }
/* Fix permissions */
if(pw) {
if(fchown(fd, 0, pw->pw_gid) < 0)
{ "config", required_argument, 0, 'c' },
{ "debug", no_argument, 0, 'd' },
{ "no-debug", no_argument, 0, 'D' },
+ { "syslog", no_argument, 0, 's' },
+ { "no-syslog", no_argument, 0, 'S' },
{ 0, 0, 0, 0 }
};
" --version, -V Display version number\n"
" --config PATH, -c PATH Set configuration file\n"
" --debug, -d Turn on debugging\n"
+ " --[no-]syslog Force logging\n"
"\n"
"Speaker process for DisOrder. Not intended to be run\n"
"directly.\n");
}
int main(int argc, char **argv) {
- int n;
+ int n, logsyslog = !isatty(2);
struct sockaddr_un addr;
static const int one = 1;
struct speaker_message sm;
set_progname(argv);
if(!setlocale(LC_CTYPE, "")) fatal(errno, "error calling setlocale");
- while((n = getopt_long(argc, argv, "hVc:dD", options, 0)) >= 0) {
+ while((n = getopt_long(argc, argv, "hVc:dDSs", options, 0)) >= 0) {
switch(n) {
case 'h': help();
case 'V': version();
case 'c': configfile = optarg; break;
case 'd': debugging = 1; break;
case 'D': debugging = 0; break;
+ case 'S': logsyslog = 0; break;
+ case 's': logsyslog = 1; break;
default: fatal(0, "invalid option");
}
}
if((d = getenv("DISORDER_DEBUG_SPEAKER"))) debugging = atoi(d);
- /* If stderr is a TTY then log there, otherwise to syslog. */
- if(!isatty(2)) {
+ if(logsyslog) {
openlog(progname, LOG_PID, LOG_DAEMON);
log_default = &log_syslog;
}
#include <errno.h>
#include <pcre.h>
#include <getopt.h>
+#include <syslog.h>
+#include <unistd.h>
#include "defs.h"
#include "mem.h"
{ "config", required_argument, 0, 'c' },
{ "debug", no_argument, 0, 'd' },
{ "no-debug", no_argument, 0, 'D' },
+ { "syslog", no_argument, 0, 's' },
+ { "no-syslog", no_argument, 0, 'S' },
{ 0, 0, 0, 0 }
};
" --version, -V Display version number\n"
" --config PATH, -c PATH Set configuration file\n"
" --[no-]debug, -d Turn on (off) debugging\n"
+ " --[no-]syslog Force logging\n"
"\n"
"Generate DisOrder database statistics.\n");
xfclose(stdout);
}
int main(int argc, char **argv) {
- int n;
+ int n, logsyslog = !isatty(2);
char **stats;
set_progname(argv);
mem_init();
if(!setlocale(LC_CTYPE, "")) fatal(errno, "error calling setlocale");
- while((n = getopt_long(argc, argv, "hVc:dD", options, 0)) >= 0) {
+ while((n = getopt_long(argc, argv, "hVc:dDSs", options, 0)) >= 0) {
switch(n) {
case 'h': help();
case 'V': version();
case 'c': configfile = optarg; break;
case 'd': debugging = 1; break;
case 'D': debugging = 0; break;
+ case 'S': logsyslog = 0; break;
+ case 's': logsyslog = 1; break;
default: fatal(0, "invalid option");
}
}
+ if(logsyslog) {
+ openlog(progname, LOG_PID, LOG_DAEMON);
+ log_default = &log_syslog;
+ }
if(config_read(0))
fatal(0, "cannot read configuration");
trackdb_init(0);
static pid_t subprogram(ev_source *ev, const char *prog,
int outputfd) {
pid_t pid;
- int lfd;
/* If we're in the background then trap subprocess stdout/stderr */
- if(!isatty(2))
- lfd = logfd(ev, prog);
- else
- lfd = -1;
if(!(pid = xfork())) {
exitfn = _exit;
ev_signal_atfork(ev);
signal(SIGPIPE, SIG_DFL);
- if(lfd != -1) {
- xdup2(lfd, 1);
- xdup2(lfd, 2);
- xclose(lfd);
- }
if(outputfd != -1) {
xdup2(outputfd, 1);
xclose(outputfd);
setpriority(PRIO_PROCESS, 0, 0);
execlp(prog, prog, "--config", configfile,
debugging ? "--debug" : "--no-debug",
+ log_default == &log_syslog ? "--syslog" : "--no-syslog",
(char *)0);
fatal(errno, "error invoking %s", prog);
}
- if(lfd != -1) xclose(lfd);
return pid;
}
#
check:
- PATH=../server:$$PATH \
+ PATH=`pwd`/../server:`pwd`/..clients:$$PATH \
PYTHONPATH=../python \
topsrcdir=${top_srcdir} \
${PYTHON} ${srcdir}/alltests
-EXTRA_DIST=alltests dtest.py nothing.py
+EXTRA_DIST=alltests dtest.py nothing.py version.py
#! /usr/bin/env python
import dtest
-tests = ["nothing"]
+tests = ["nothing", "version"]
for test in tests:
print "Test '%s'" % test
"""Utility module used by tests"""
-import os,os.path,subprocess,sys
+import os,os.path,subprocess,sys,disorder
def copyfile(a,b):
"""copyfile(A, B)
"""maketrack(S)
Make track with relative path S exist"""
- trackpath = "%s/%s" % (testroot, s)
+ trackpath = "%s/tracks/%s" % (testroot, s)
trackdir = os.path.dirname(trackpath)
if not os.path.exists(trackdir):
os.makedirs(trackdir)
"--foreground",
"--config", "%s/config" % testroot],
stderr=errs)
+ disorder._configfile = "%s/config" % testroot
+ disorder._userconf = False
def stop():
"""stop()
global daemon
rc = daemon.poll()
if rc == None:
+ print " stopping daemon"
os.kill(daemon.pid, 15)
rc = daemon.wait()
print " daemon has stopped"
setup()
start(name)
try:
- test()
- except AssertionError, e:
- global failures
- failures += 1
- print e
-
- stop()
+ try:
+ test()
+ except AssertionError, e:
+ global failures
+ failures += 1
+ print e
+ finally:
+ stop()
if report:
if failures:
print " FAILED"
stopword 11 12 13 14 15 16 17 18 19 20
stopword 21 22 23 24 25 26 27 28 29 30
stopword the a an and to too in on of we i am as im for is
+username fred
+password fredpass
+allow fred fredpass
+plugins ../plugins
+player *.mp3 execraw disorder-decode
+player *.ogg execraw disorder-decode
+player *.wav execraw disorder-decode
+player *.flac execraw disorder-decode
+tracklength *.mp3 disorder-tracklength
+tracklength *.ogg disorder-tracklength
+tracklength *.wav disorder-tracklength
+tracklength *.flac disorder-tracklength
""" % (testroot, testroot, testroot, testroot))
copyfile("%s/sounds/scratch.ogg" % topsrcdir,
"%s/scratch.ogg" % testroot)
--- /dev/null
+#! /usr/bin/env python
+import dtest,time,disorder
+
+def test():
+ """Ask the server its version number"""
+ time.sleep(2) # give the daemon a chance to start up
+ c = disorder.client()
+ v = c.version()
+ print "Server version: %s" % v
+
+if __name__ == '__main__':
+ dtest.run(test)