32 lines
1.2 KiB
JavaScript
32 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
module.exports.install = function (opts, cb) {
|
|
var fs = require('fs');
|
|
var path = require('path');
|
|
var service = '/etc/systemd/system/greenlock.service';
|
|
var rwDirs = [ '/etc/greenlock', '/srv/www', '/var/log/greenlock', '/opt/greenlock' ];
|
|
|
|
fs.readFile(path.join(__dirname, '../dist', service), 'utf8', function (e, text) {
|
|
if (e) { throw e; }
|
|
|
|
text = text
|
|
.replace(/MY_DESC/g, opts.description || 'Greenlock Secure Web Server')
|
|
.replace(/MY_DOCS/g, opts.homepage || 'https://git.coolaj86.com/coolaj86/greenlock-cli.js')
|
|
.replace(/MY_GREENLOCK_PATH/g, opts.greenlockPath || '/opt/greenlock')
|
|
.replace(/MY_CONFIG_PATH/g, opts.greenlockPath || '/etc/greenlock/greenlock.yml')
|
|
.replace(/MY_USER/g, opts.user || 'greenlock')
|
|
.replace(/MY_GROUP/g, opts.user || 'greenlock')
|
|
.replace(/MY_RW_DIRS/g, (opts.writableDirs || rwDirs).join(' '))
|
|
;
|
|
fs.writeFile(service, text, 'utf8', function (e) {
|
|
if (e) { throw e; }
|
|
|
|
console.log("Now reload configs and enable to start on boot:");
|
|
console.log("");
|
|
console.log("\tsudo systemctl daemon-reload");
|
|
console.log("\tsudo systemctl enable greenlock");
|
|
cb(null);
|
|
});
|
|
});
|
|
};
|