Commit 96f58043 authored by David Morley's avatar David Morley

use php functions for file updates

parent 212df4e4
Pipeline #809 passed with stage
in 2 minutes and 19 seconds
......@@ -16,7 +16,7 @@ if (!is_cli()) {
$keep_for = 60 * 60 * 6; // 6 hours
$backup_file = c('backup_dir') . '/dump_' . date('Ymd_His') . '.sql';
printf("Making backup of '%s' to '%s'...", c('pgdb'), $backup_file);
debug("Making backup of '%s' to '%s'...", c('pgdb'), $backup_file);
system(sprintf(
'export PGPASSWORD=%3$s &&' .
'"%1$s" --clean --format=tar --username=%2$s %4$s >> "%5$s"',
......@@ -26,7 +26,7 @@ system(sprintf(
c('pgdb'),
$backup_file
), $exit_code);
printf(" %s\n", $exit_code === 0 ? 'Success!' : 'Failed.');
debug(" %s\n", $exit_code === 0 ? 'Success!' : 'Failed.');
$dirh = dir(c('backup_dir'));
while ($entry = $dirh->read()) {
......
......@@ -458,18 +458,13 @@ if (!$_domain) {
if (Carbon::createFromFormat('Y-m-d H:i:s.u', getMeta('cacert_updated', 'date_created'))->diffInHours() > 40) {
$cacert = c('cafullpath');
$getcacert = new NPM\Xec\Command("curl -Lss https://curl.haxx.se/ca/cacert.pem -o {$cacert}");
$getcacert->throwExceptionOnError(false);
$getcacert->execute();
file_put_contents($cacert, file_get_contents("https://curl.haxx.se/ca/cacert.pem"));
updateMeta('cacert_updated');
}
if (Carbon::createFromFormat('Y-m-d H:i:s.u', getMeta('geoip_updated', 'date_created'))->diffInHours() > 45) {
$geo2ip = c('geoip2db');
$getgeo2ip = new NPM\Xec\Command("funzip <(curl -Lss http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz) > {$geo2ip}");
$getgeo2ip->throwExceptionOnError(false);
$getgeo2ip->echoStderr();
$getgeo2ip->execute();
file_put_contents($geo2ip, file_get_contents("compress.zlib://http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz"));
updateMeta('geoip_updated');
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment