-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdaemon_remote_conf.php
More file actions
55 lines (39 loc) · 1.02 KB
/
daemon_remote_conf.php
File metadata and controls
55 lines (39 loc) · 1.02 KB
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
<?php
//YOUR REMOTE CONF URL - Use http not https
$your_config_url="http://configmaker.com/my/VirtualEarnestWhiteHagfish.txt";
//TIME TO CHECK - IN SECONDS
$time_check=360;
//ROUTE TO SAVE LENGTH
$LOCAL_CONF = '/home/ethos/length.txt';
while (TRUE) {
check_file($LOCAL_CONF,retrieve_server_config($your_config_url));
sleep($time_check);
}
function retrieve_server_config($url){
$text = file_get_contents($url);
$size = strlen($text);
return $size;
}
function check_file($file,$size){
//Use the function is_file to check if the file already exists or not.
if(!is_file($file)){
file_put_contents($file, $size);
}
else{
if(read_file($file)!=$size)
{
file_put_contents($file, $size);
echo "Remote Conf Change\n";
echo "Execute command putconf && minestop\n";
shell_exec('putconf && minestop');
echo "Execute command r\n";
shell_exec('r');
}
}
}
function read_file($file){
$myfile = fopen($file, "r") or die("Unable to open file!");
return fread($myfile,filesize($file));
fclose($myfile);
}
?>