diff --git a/app.js b/app.js index d95d2d9..c496138 100755 --- a/app.js +++ b/app.js @@ -38,6 +38,7 @@ app.get(routes.root, function(req, res) { routes : JSON.stringify(routes), crontabs : JSON.stringify(docs), backups : crontab.get_backup_names(), + env : crontab.get_env() }); }); }) diff --git a/crontab.js b/crontab.js index 129c850..5401850 100644 --- a/crontab.js +++ b/crontab.js @@ -6,8 +6,10 @@ db.loadDatabase(function (err) { var exec = require('child_process').exec; var fs = require('fs'); var cron_parser = require("cron-parser") +var os = require("os") exports.log_folder = __dirname + '/crontabs/logs'; +exports.env_file = __dirname + '/crontabs/env.db'; crontab = function(name, command, schedule, stopped, logging){ var data = {}; @@ -70,6 +72,8 @@ exports.set_crontab = function(env_vars){ crontab_string += tab.schedule + " " + tab.command + "\n"; } }); + + fs.writeFile(exports.env_file, env_vars); fs.writeFile("/tmp/crontab", crontab_string, function(err) { exec("crontab /tmp/crontab"); }); @@ -118,6 +122,13 @@ exports.reload_db= function(){ db.loadDatabase(); } +exports.get_env = function(){ + if (fs.existsSync(exports.env_file)) { + return fs.readFileSync(exports.env_file , 'utf8').replace("\n", "\n"); + } + return "" +} + // TODO exports.import_crontab = function(){ exec("crontab -l", function(error, stdout, stderr){ diff --git a/package.json b/package.json index ba2e1df..58136b7 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "crontab-ui", - "version": "0.1.5", + "version": "0.1.6", "description": "Easy and safe way to manage your crontab file", "main": "index.js", "scripts": { diff --git a/views/index.ejs b/views/index.ejs index 045a1de..6073ac7 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -13,6 +13,7 @@ $('[data-toggle="tooltip"]').tooltip(); crontabs = JSON.parse('<%- crontabs.replace(/\\\\/g, "\\\\\\\\").replace(/\\\"/g,"\\\\\"") %>'); routes = JSON.parse('<%- routes %>'); + $("#env_vars").val(`<%- env %>`); })