aboutsummaryrefslogtreecommitdiff
var fs = require("fs");
var parse = require("url").parse;
var path = require("path");

try {
    fs.mkdirSync("./tmp");
} catch (e) {
    if (e.code != "EEXIST") throw e;
}

function local(url) {
    return path.join("./tmp", encodeURIComponent(url));
}

function read(url) {
    return fs.createReadStream(local(url));
}

module.exports = function(url, callback) {
    var result = read(url);
    result.on("error", function(e) {
        if (e.code != "ENOENT") return callback(e);
        var options = parse(url);
        options.rejectUnauthorized = false;
        require(options.protocol.slice(0, -1)).get(options, function(res) {
            if (res.statusCode !== 200) return callback(res.statusCode);
            res.pipe(fs.createWriteStream(local(url)));
            callback(null, res);
        });
    }).on("open", function() {
        callback(null, result);
    });
};
tooltip'>* gnu/services/admin.scm (file-database-configuration)[excluded-directories]: Mention that these are regexps. (%default-file-database-excluded-directories): Likewise. * doc/guix.texi (File Search Services): Adjust accordingly. Ludovic Courtès 2023-08-22services: file-database: Set 'PATH' for 'updatedb'....Previously 'updatedb' would fail to find 'sed', 'rm', etc. * gnu/services/admin.scm (file-database-mcron-jobs): Set PATH before invoking 'updatedb'. Ludovic Courtès 2023-08-07services: Add 'package-database' service....* gnu/services/admin.scm (%default-package-database-update-schedule): New variable. (<package-database-configuration>): New record type. (package-database-mcron-jobs): New procedure. (package-database-service-type): New variable. * doc/guix.texi (File Search Services): Document it. Ludovic Courtès 2023-08-07services: Add 'file-database' service....* gnu/services/admin.scm (%default-file-database-update-schedule) (%default-file-database-excluded-directories): New variables. (<file-database-configuration>): New record type. (file-database-mcron-jobs): New procedure. (file-database-service-type): New variable. * doc/guix.texi (File Search Services): New node. Ludovic Courtès 2023-01-10services: unattended-upgrade: Add 'operating-system-expression' field....* gnu/services/admin.scm (<unattended-upgrade-configuration>) [operating-system-expression]: New field. (unattended-upgrade-mcron-jobs): Honor it. * doc/guix.texi (Unattended Upgrades): Document it. Co-authored-by: Ludovic Courtès <ludo@gnu.org> Giacomo Leidi 2022-08-01services: rottlog: More convenient default options for <log-rotation>....* gnu/services/admin.scm (%default-log-rotation-options): New variable. (%default-rotations): Use it. * gnu/services/cuirass.scm (cuirass-log-rotations): Likewise. * doc/guix.texi (Log Rotation): Adjust accordingly. Ludovic Courtès 2022-08-01services: rottlog: Keep important /var/log files for 16 weeks....The default "rotate" value is 1 as of rottlog 0.72.2, meaning that only one rotated file would be kept in addition to the active file. * gnu/services/admin.scm (%default-rotations): Add "rotate" option for %ROTATED-FILES. Ludovic Courtès