-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdaemon.php
62 lines (51 loc) · 984 Bytes
/
daemon.php
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
<?php
require("includes/functions.php");
require("includes/tasker.php");
function runDaemon() {
// do Init
daemonCallInit();
//periodically call Tasker::doWork()
while(true) {
Tasker::doWork();
sleep(1);
}
}
function printHelp() {
echo "Parameters are:\n";
echo "-h Help\n";
echo "-f Scan filesystem\n";
echo "-p Scan playlists\n";
echo "-d Run daemon\n";
echo "-t truncate Database (use with caution!)\n";
echo "-m return m3u of playlog\n";
echo "(no parameters) Run daemon\n";
}
if(count(getopt("h::"))>0) {
printHelp();
die();
}
if(count(getopt("f::"))>0) {
scanF();
die();
}
if(count(getopt("p::"))>0) {
scanP();
die();
}
if(count(getopt("d::"))>0) {
runDaemon();
die();
}
if(count(getopt("t::"))>0) {
truncateDatabase();
die();
}
if(count(getopt("m::"))>0) {
returnm3u();
die();
}
//no parameters
printHelp();
echo "\nrunning daemon\n";
runDaemon();
?>