adding env feature
parent
0c6cc5512a
commit
5f52cbcf44
1
app.js
1
app.js
|
@ -38,6 +38,7 @@ app.get(routes.root, function(req, res) {
|
||||||
routes : JSON.stringify(routes),
|
routes : JSON.stringify(routes),
|
||||||
crontabs : JSON.stringify(docs),
|
crontabs : JSON.stringify(docs),
|
||||||
backups : crontab.get_backup_names(),
|
backups : crontab.get_backup_names(),
|
||||||
|
env : crontab.get_env()
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
11
crontab.js
11
crontab.js
|
@ -6,8 +6,10 @@ db.loadDatabase(function (err) {
|
||||||
var exec = require('child_process').exec;
|
var exec = require('child_process').exec;
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var cron_parser = require("cron-parser")
|
var cron_parser = require("cron-parser")
|
||||||
|
var os = require("os")
|
||||||
|
|
||||||
exports.log_folder = __dirname + '/crontabs/logs';
|
exports.log_folder = __dirname + '/crontabs/logs';
|
||||||
|
exports.env_file = __dirname + '/crontabs/env.db';
|
||||||
|
|
||||||
crontab = function(name, command, schedule, stopped, logging){
|
crontab = function(name, command, schedule, stopped, logging){
|
||||||
var data = {};
|
var data = {};
|
||||||
|
@ -70,6 +72,8 @@ exports.set_crontab = function(env_vars){
|
||||||
crontab_string += tab.schedule + " " + tab.command + "\n";
|
crontab_string += tab.schedule + " " + tab.command + "\n";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fs.writeFile(exports.env_file, env_vars);
|
||||||
fs.writeFile("/tmp/crontab", crontab_string, function(err) {
|
fs.writeFile("/tmp/crontab", crontab_string, function(err) {
|
||||||
exec("crontab /tmp/crontab");
|
exec("crontab /tmp/crontab");
|
||||||
});
|
});
|
||||||
|
@ -118,6 +122,13 @@ exports.reload_db= function(){
|
||||||
db.loadDatabase();
|
db.loadDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.get_env = function(){
|
||||||
|
if (fs.existsSync(exports.env_file)) {
|
||||||
|
return fs.readFileSync(exports.env_file , 'utf8').replace("\n", "\n");
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
exports.import_crontab = function(){
|
exports.import_crontab = function(){
|
||||||
exec("crontab -l", function(error, stdout, stderr){
|
exec("crontab -l", function(error, stdout, stderr){
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "crontab-ui",
|
"name": "crontab-ui",
|
||||||
"version": "0.1.5",
|
"version": "0.1.6",
|
||||||
"description": "Easy and safe way to manage your crontab file",
|
"description": "Easy and safe way to manage your crontab file",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
$('[data-toggle="tooltip"]').tooltip();
|
$('[data-toggle="tooltip"]').tooltip();
|
||||||
crontabs = JSON.parse('<%- crontabs.replace(/\\\\/g, "\\\\\\\\").replace(/\\\"/g,"\\\\\"") %>');
|
crontabs = JSON.parse('<%- crontabs.replace(/\\\\/g, "\\\\\\\\").replace(/\\\"/g,"\\\\\"") %>');
|
||||||
routes = JSON.parse('<%- routes %>');
|
routes = JSON.parse('<%- routes %>');
|
||||||
|
$("#env_vars").val(`<%- env %>`);
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
Loading…
Reference in New Issue