-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
65 lines (56 loc) · 1.84 KB
/
index.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
63
64
65
<?php
//high error reporting
error_reporting(E_ALL);
ini_set('display_errors', 1);
//load the Yocto API
require_once('yocto_api.php');
YAPI::RegisterHub("callback");
//array of URL endpoints to recieve
$tentacles = [
"http://10.0.1.55/trailsendmonitor/hopper/post",
"http://10.0.1.55/YoctoCloud/index.php"
];
// string for debug feedback
$output = "";
// forward to endpoints
foreach($tentacles as $endpoint){
YAPI::ForwardHTTPCallback($endpoint, $output);
echo "\n";
echo "Endpoint: " . $endpoint . "\n";
echo "Result: " . $output . "\n";
echo "---------------------------------------------------\n";
}
// push YoctoCloud data to online implementation with rsync
// -c, --checksum skip based on checksum, not mod-time & size
// -r, --recursive recurse into directories
// -a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)
// -z, --compress compress file data during the transfer
// -P same as --partial --progress
// -v, --verbose increase verbosity
// Don't forget to generate the 'monitor' ssh key and make it accessible by the www-data user
echo "Rsync YC Data to cloud:\n";
$output = [];
exec('rsync -crahvzP -e "ssh -i /var/www/.ssh/monitor" /mnt/datadisk/YoctoCloud/data/ [email protected]:/var/www/evansharp.ca/YoctoCloud/data',
$output, $exit_code);
if( !empty($output) ){
foreach($output as $line){
echo $line . "\n";
}
}
echo "\n";
switch( $exit_code ){
case 0:
echo "Rsync completed successfully. (code 0)";
break;
case 1:
echo "Syntax error in rsync command. (code 1)";
break;
case 255:
echo "Probably an SSH error. (code 255)";
break;
default:
echo "Something weird happened. Code " . $exit_code;
}
//release api resources
YAPI::FreeAPI();
?>