From 739aa2ccd43fa07dbda86f5beb5720daa2193ffe Mon Sep 17 00:00:00 2001 From: alse Date: Tue, 26 Nov 2019 21:38:02 -0800 Subject: [PATCH 01/13] Fixing include statements in ejs --- views/index.ejs | 4 ++-- views/restore.ejs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/views/index.ejs b/views/index.ejs index e0bb897..565439b 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -21,7 +21,7 @@ -<% include navbar %> +<%- include('navbar.ejs') -%>

Cronjobs

@@ -99,7 +99,7 @@
-<% include popup.ejs %> +<%- include('popup.ejs') -%> -<% include navbar %> +<%- include('navbar.ejs') -%>

<%= db %>

@@ -60,6 +60,6 @@ Restore Delete -<% include popup.ejs %> +<%- include('popup.ejs') -%> From 9d5238b0aa1de2368d74e4a0f5f8053fe206f253 Mon Sep 17 00:00:00 2001 From: alse Date: Tue, 26 Nov 2019 21:42:02 -0800 Subject: [PATCH 02/13] Fixing case where the log folder path has spaces --- crontab.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crontab.js b/crontab.js index c195d2b..2d492fe 100644 --- a/crontab.js +++ b/crontab.js @@ -103,8 +103,8 @@ exports.set_crontab = function(env_vars, callback){ if (tab.logging && tab.logging == "true") { crontab_string += "; if test -f " + stderr + - "; then date >> " + log_file + - "; cat " + stderr + " >> " + log_file + + "; then date >> \"" + log_file + "\"" + + "; cat " + stderr + " >> \"" + log_file + "\"" + "; fi"; } From ee3aad8a2f33e147f0cd001917ce31acbb9b37fd Mon Sep 17 00:00:00 2001 From: alse Date: Tue, 26 Nov 2019 21:55:45 -0800 Subject: [PATCH 03/13] Ability to view stdout added --- app.js | 20 +++++++++++++++----- crontab.js | 6 ++++++ routes.js | 1 + views/index.ejs | 3 ++- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/app.js b/app.js index fa63511..2e10b30 100755 --- a/app.js +++ b/app.js @@ -184,13 +184,23 @@ app.get(routes.import_crontab, function(req, res) { res.end(); }); -// get the log file a given job. id passed as query param -app.get(routes.logger, function(req, res) { - _file = crontab.log_folder +"/"+req.query.id+".log"; - if (fs.existsSync(_file)) - res.sendFile(_file); +function sendLog(path, req, res) { + if (fs.existsSync(path)) + res.sendFile(path); else res.end("No errors logged yet"); +} + +// get the log file a given job. id passed as query param +app.get(routes.logger, function(req, res) { + let _file = crontab.log_folder + "/" + req.query.id + ".log"; + sendLog(_file, req, res); +}); + +// get the log file a given job. id passed as query param +app.get(routes.stdout, function(req, res) { + let _file = crontab.log_folder + "/" + req.query.id + ".stdout.log"; + sendLog(_file, req, res); }); // error handler diff --git a/crontab.js b/crontab.js index 2d492fe..d5c941f 100644 --- a/crontab.js +++ b/crontab.js @@ -95,6 +95,7 @@ exports.set_crontab = function(env_vars, callback){ let stderr = path.join(cronPath, tab._id + ".stderr"); let stdout = path.join(cronPath, tab._id + ".stdout"); let log_file = path.join(exports.log_folder, tab._id + ".log"); + let log_file_stdout = path.join(exports.log_folder, tab._id + ".stdout.log"); if(tab.command[tab.command.length-1] != ";") // add semicolon tab.command +=";"; @@ -106,6 +107,11 @@ exports.set_crontab = function(env_vars, callback){ "; then date >> \"" + log_file + "\"" + "; cat " + stderr + " >> \"" + log_file + "\"" + "; fi"; + + crontab_string += "; if test -f " + stdout + + "; then date >> \"" + log_file_stdout + "\"" + + "; cat " + stdout + " >> \"" + log_file_stdout + "\"" + + "; fi"; } if (tab.hook) { diff --git a/routes.js b/routes.js index 210f79e..3770272 100644 --- a/routes.js +++ b/routes.js @@ -14,4 +14,5 @@ exports.routes = { "import": "/import", // this is import from database "import_crontab": "/import_crontab", // this is from existing crontab "logger": "/logger", + "stdout": "/stdout", }; diff --git a/views/index.ejs b/views/index.ejs index 565439b..d2f48dc 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -82,7 +82,8 @@ <% if (!crontab.stopped) { %> <% if (crontab.logging && crontab.logging != "false") {%> - + + <% } %> Run Edit From b24f4db688d3fe962108240d35f86163b26a81c2 Mon Sep 17 00:00:00 2001 From: alse Date: Tue, 26 Nov 2019 21:58:20 -0800 Subject: [PATCH 04/13] releasing 0.3.9 --- Makefile | 2 +- package-lock.json | 253 +++++++++++++++++++++++----------------------- package.json | 2 +- 3 files changed, 126 insertions(+), 131 deletions(-) diff --git a/Makefile b/Makefile index 7e767d8..fa2e750 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VER=0.3.8 +VER=0.3.9 release: sed -i '' "s/version\": \".*/version\": \"$(VER)\",/" package.json diff --git a/package-lock.json b/package-lock.json index b3f947a..f714578 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,16 @@ { "name": "crontab-ui", - "version": "0.3.5", + "version": "0.3.8", "lockfileVersion": 1, "requires": true, "dependencies": { "accepts": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", - "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", + "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", "requires": { - "mime-types": "~2.1.18", - "negotiator": "0.6.1" + "mime-types": "~2.1.24", + "negotiator": "0.6.2" } }, "array-flatten": { @@ -40,20 +40,20 @@ } }, "body-parser": { - "version": "1.18.3", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz", - "integrity": "sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ=", + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", + "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", "requires": { - "bytes": "3.0.0", + "bytes": "3.1.0", "content-type": "~1.0.4", "debug": "2.6.9", "depd": "~1.1.2", - "http-errors": "~1.6.3", - "iconv-lite": "0.4.23", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", "on-finished": "~2.3.0", - "qs": "6.5.2", - "raw-body": "2.3.3", - "type-is": "~1.6.16" + "qs": "6.7.0", + "raw-body": "2.4.0", + "type-is": "~1.6.17" } }, "busboy": { @@ -65,9 +65,9 @@ } }, "bytes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", - "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", + "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" }, "connect-busboy": { "version": "0.0.2", @@ -78,9 +78,12 @@ } }, "content-disposition": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", - "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", + "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", + "requires": { + "safe-buffer": "5.1.2" + } }, "content-type": { "version": "1.0.4", @@ -88,9 +91,9 @@ "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" }, "cookie": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", - "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", + "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==" }, "cookie-signature": { "version": "1.0.6", @@ -98,12 +101,12 @@ "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" }, "cron-parser": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-2.11.0.tgz", - "integrity": "sha512-L5LAGlvq2xmCLErhjQRX8IL5v72y8jhGOaxrarYOhse0kJjJGb/vY/0sV/c7F/SylJGkUIY2iZPPJXZD3glZqA==", + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-2.13.0.tgz", + "integrity": "sha512-UWeIpnRb0eyoWPVk+pD3TDpNx3KCFQeezO224oJIkktBrcW6RoAPOx5zIKprZGfk6vcYSmA8yQXItejSaDBhbQ==", "requires": { "is-nan": "^1.2.1", - "moment-timezone": "^0.5.23" + "moment-timezone": "^0.5.25" } }, "debug": { @@ -146,9 +149,9 @@ "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" }, "ejs": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/ejs/-/ejs-2.6.1.tgz", - "integrity": "sha512-0xy4A/twfrRCnkhfk8ErDi5DqdAsAqeGxht4xkCUrsvhhbQNs7E+4jV0CN7+NKIY0aHE72+XvqtBIXzD31ZbXQ==" + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.0.1.tgz", + "integrity": "sha512-cuIMtJwxvzumSAkqaaoGY/L6Fc/t6YvoP9/VIaK0V/CyqKLEQ8sqODmYfy/cjXEdZ9+OOL8TecbJu+1RsofGDw==" }, "encodeurl": { "version": "1.0.2", @@ -166,47 +169,40 @@ "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" }, "express": { - "version": "4.16.4", - "resolved": "https://registry.npmjs.org/express/-/express-4.16.4.tgz", - "integrity": "sha512-j12Uuyb4FMrd/qQAm6uCHAkPtO8FDTRJZBDd5D2KOL2eLaz1yUNdUB/NOIyq0iU4q4cFarsUCrnFDPBcnksuOg==", + "version": "4.17.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", + "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", "requires": { - "accepts": "~1.3.5", + "accepts": "~1.3.7", "array-flatten": "1.1.1", - "body-parser": "1.18.3", - "content-disposition": "0.5.2", + "body-parser": "1.19.0", + "content-disposition": "0.5.3", "content-type": "~1.0.4", - "cookie": "0.3.1", + "cookie": "0.4.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "~1.1.2", "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "etag": "~1.8.1", - "finalhandler": "1.1.1", + "finalhandler": "~1.1.2", "fresh": "0.5.2", "merge-descriptors": "1.0.1", "methods": "~1.1.2", "on-finished": "~2.3.0", - "parseurl": "~1.3.2", + "parseurl": "~1.3.3", "path-to-regexp": "0.1.7", - "proxy-addr": "~2.0.4", - "qs": "6.5.2", - "range-parser": "~1.2.0", + "proxy-addr": "~2.0.5", + "qs": "6.7.0", + "range-parser": "~1.2.1", "safe-buffer": "5.1.2", - "send": "0.16.2", - "serve-static": "1.13.2", - "setprototypeof": "1.1.0", - "statuses": "~1.4.0", - "type-is": "~1.6.16", + "send": "0.17.1", + "serve-static": "1.14.1", + "setprototypeof": "1.1.1", + "statuses": "~1.5.0", + "type-is": "~1.6.18", "utils-merge": "1.0.1", "vary": "~1.1.2" - }, - "dependencies": { - "statuses": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", - "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" - } } }, "express-basic-auth": { @@ -218,24 +214,17 @@ } }, "finalhandler": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", - "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", + "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", "requires": { "debug": "2.6.9", "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "on-finished": "~2.3.0", - "parseurl": "~1.3.2", - "statuses": "~1.4.0", + "parseurl": "~1.3.3", + "statuses": "~1.5.0", "unpipe": "~1.0.0" - }, - "dependencies": { - "statuses": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", - "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" - } } }, "forwarded": { @@ -249,20 +238,21 @@ "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" }, "http-errors": { - "version": "1.6.3", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", - "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", + "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", "requires": { "depd": "~1.1.2", "inherits": "2.0.3", - "setprototypeof": "1.1.0", - "statuses": ">= 1.4.0 < 2" + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" } }, "iconv-lite": { - "version": "0.4.23", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", - "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", "requires": { "safer-buffer": ">= 2.1.2 < 3" } @@ -322,21 +312,21 @@ "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" }, "mime": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", - "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" }, "mime-db": { - "version": "1.40.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", - "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" + "version": "1.42.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.42.0.tgz", + "integrity": "sha512-UbfJCR4UAVRNgMpfImz05smAXK7+c+ZntjaA26ANtkXLlOe947Aag5zdIcKQULAiF9Cq4WxBi9jUs5zkA84bYQ==" }, "mime-types": { - "version": "2.1.24", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", - "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "version": "2.1.25", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.25.tgz", + "integrity": "sha512-5KhStqB5xpTAeGqKBAMgwaYMnQik7teQN4IAzC7npDv6kzeU6prfkR67bc87J1kWMPGkoaZSq1npmexMgkmEVg==", "requires": { - "mime-db": "1.40.0" + "mime-db": "1.42.0" } }, "minimist": { @@ -358,9 +348,9 @@ "integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==" }, "moment-timezone": { - "version": "0.5.25", - "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.25.tgz", - "integrity": "sha512-DgEaTyN/z0HFaVcVbSyVCUU6HeFdnNC3vE4c9cgu2dgMTvjBUBdBzWfasTBmAW45u5OIMeCJtU8yNjM22DHucw==", + "version": "0.5.27", + "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.27.tgz", + "integrity": "sha512-EIKQs7h5sAsjhPCqN6ggx6cEbs94GK050254TIJySD1bzoM5JTYDwAU1IoVOeTOL6Gm27kYJ51/uuvq1kIlrbw==", "requires": { "moment": ">= 2.9.0" } @@ -383,14 +373,14 @@ } }, "negotiator": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", - "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", + "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" }, "nodemailer": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.1.1.tgz", - "integrity": "sha512-/x5MRIh56VyuuhLfcz+DL2SlBARpZpgQIf2A4Ao4hMb69MHSgDIMPwYmFwesGT1lkRDZ0eBSoym5+JoIZ3N+cQ==" + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.3.1.tgz", + "integrity": "sha512-j0BsSyaMlyadEDEypK/F+xlne2K5m6wzPYMXS/yxKI0s7jmT1kBx6GEKRVbZmyYfKOsjkeC/TiMVDJBI/w5gMQ==" }, "object-keys": { "version": "1.1.1", @@ -425,23 +415,23 @@ } }, "qs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" }, "range-parser": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", - "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" }, "raw-body": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.3.tgz", - "integrity": "sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", + "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", "requires": { - "bytes": "3.0.0", - "http-errors": "1.6.3", - "iconv-lite": "0.4.23", + "bytes": "3.1.0", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", "unpipe": "1.0.0" } }, @@ -456,9 +446,9 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "send": { - "version": "0.16.2", - "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", - "integrity": "sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw==", + "version": "0.17.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", + "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", "requires": { "debug": "2.6.9", "depd": "~1.1.2", @@ -467,36 +457,36 @@ "escape-html": "~1.0.3", "etag": "~1.8.1", "fresh": "0.5.2", - "http-errors": "~1.6.2", - "mime": "1.4.1", - "ms": "2.0.0", + "http-errors": "~1.7.2", + "mime": "1.6.0", + "ms": "2.1.1", "on-finished": "~2.3.0", - "range-parser": "~1.2.0", - "statuses": "~1.4.0" + "range-parser": "~1.2.1", + "statuses": "~1.5.0" }, "dependencies": { - "statuses": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", - "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" } } }, "serve-static": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz", - "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", + "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", "requires": { "encodeurl": "~1.0.2", "escape-html": "~1.0.3", - "parseurl": "~1.3.2", - "send": "0.16.2" + "parseurl": "~1.3.3", + "send": "0.17.1" } }, "setprototypeof": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", - "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" }, "statuses": { "version": "1.5.0", @@ -508,10 +498,15 @@ "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz", "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=" }, + "toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" + }, "type-is": { - "version": "1.6.17", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.17.tgz", - "integrity": "sha512-jYZzkOoAPVyQ9vlZ4xEJ4BBbHC4a7hbY1xqyCPe6AiQVVqfbZEulJm0VpqK4B+096O1VQi0l6OBGH210ejx/bA==", + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", "requires": { "media-typer": "0.3.0", "mime-types": "~2.1.24" diff --git a/package.json b/package.json index 776563a..27e8f95 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "crontab-ui", - "version": "0.3.8", + "version": "0.3.9", "description": "Easy and safe way to manage your crontab file", "main": "index.js", "scripts": { From ca78c54afb004d9900c7c5750f1b928405a9b612 Mon Sep 17 00:00:00 2001 From: Suresh Alse Date: Sun, 1 Dec 2019 12:42:06 -0800 Subject: [PATCH 05/13] Adding Docker section to Readme --- README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index aef3726..f182327 100644 --- a/README.md +++ b/README.md @@ -42,14 +42,30 @@ If you need to autosave your changes to crontab directly: crontab-ui --autosave -Setting up with docker. You can use the prebuilt images in the [dockerhub](https://hub.docker.com/r/alseambusher/crontab-ui/tags) or build it yourself like this: +## Docker +You can use crontab-ui with docker. You can use the prebuilt images in the [dockerhub](https://hub.docker.com/r/alseambusher/crontab-ui/tags) +```bash +docker run -d -p 8000:8000 alseambusher/crontab-ui +``` +You can also build it yourself if you want to customize, like this: ```bash git clone https://github.com/alseambusher/crontab-ui.git cd crontab-ui docker build -t alseambusher/crontab-ui . docker run -d -p 8000:8000 alseambusher/crontab-ui ``` + +If you want to use it with authentication, You can pass `BASIC_AUTH_USER` and `BASIC_AUTH_PWD` as env variables +```bash +docker run -e BASIC_AUTH_USER=user -e BASIC_AUTH_PWD=SecretPassword -d -p 8000:8000 alseambusher/crontab-ui +``` + +You can also mount a folder to store the db and logs. +```bash +mkdir -p crontabs/logs +docker run --mount type=bind,source="$(pwd)"/crontabs/,target=/crontab-ui/crontabs/ -d -p 8000:8000 alseambusher/crontab-ui +``` ## Resources From 08360cd91bbac9487df33d72e2057ec3e423deb0 Mon Sep 17 00:00:00 2001 From: alse Date: Mon, 8 Jun 2020 15:43:52 +0530 Subject: [PATCH 06/13] Adding a callback for logging error on deleting backup --- restore.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/restore.js b/restore.js index 859076c..7864028 100644 --- a/restore.js +++ b/restore.js @@ -14,5 +14,12 @@ exports.crontabs = function(db_name, callback){ }; exports.delete = function(db_name){ - fs.unlink(__dirname + '/crontabs/' + db_name); + fs.unlink(__dirname + '/crontabs/' + db_name, function(err){ + if(err) { + return console.log("Delete error: " + err); + } + else{ + console.log("Backup deleted"); + } + }); }; From 860495a3b001531248af47b025492c9123850970 Mon Sep 17 00:00:00 2001 From: alse Date: Mon, 8 Jun 2020 15:44:05 +0530 Subject: [PATCH 07/13] Updating dockerignore --- .dockerignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index d992b0f..69cd475 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,5 @@ +.git +*.swp node_modules -.git \ No newline at end of file +crontabs/*.db +crontabs/logs/*.log \ No newline at end of file From 7d132871b04d2a61b3608152706a3079d9a133e3 Mon Sep 17 00:00:00 2001 From: alse Date: Mon, 8 Jun 2020 15:45:56 +0530 Subject: [PATCH 08/13] Security fix for packages --- package-lock.json | 203 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 154 insertions(+), 49 deletions(-) diff --git a/package-lock.json b/package-lock.json index f714578..7a73702 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "crontab-ui", - "version": "0.3.8", + "version": "0.3.9", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -13,15 +13,28 @@ "negotiator": "0.6.2" } }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "^1.9.0" + } + }, "array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" }, "async": { - "version": "0.2.10", - "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", - "integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=" + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", + "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=" + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, "basic-auth": { "version": "2.0.1", @@ -56,6 +69,15 @@ "type-is": "~1.6.17" } }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "busboy": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/busboy/-/busboy-0.3.1.tgz", @@ -69,6 +91,34 @@ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, "connect-busboy": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/connect-busboy/-/connect-busboy-0.0.2.tgz", @@ -101,12 +151,12 @@ "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" }, "cron-parser": { - "version": "2.13.0", - "resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-2.13.0.tgz", - "integrity": "sha512-UWeIpnRb0eyoWPVk+pD3TDpNx3KCFQeezO224oJIkktBrcW6RoAPOx5zIKprZGfk6vcYSmA8yQXItejSaDBhbQ==", + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-2.15.0.tgz", + "integrity": "sha512-rMFkrQw8+oG5OuwjiXesup4KeIlEG/IU82YtG4xyAHbO5jhKmYaHPp/ZNhq9+7TjSJ65E3zV3kQPUbmXSff2/g==", "requires": { - "is-nan": "^1.2.1", - "moment-timezone": "^0.5.25" + "is-nan": "^1.3.0", + "moment-timezone": "^0.5.31" } }, "debug": { @@ -149,9 +199,12 @@ "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" }, "ejs": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.0.1.tgz", - "integrity": "sha512-cuIMtJwxvzumSAkqaaoGY/L6Fc/t6YvoP9/VIaK0V/CyqKLEQ8sqODmYfy/cjXEdZ9+OOL8TecbJu+1RsofGDw==" + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.3.tgz", + "integrity": "sha512-wmtrUGyfSC23GC/B1SMv2ogAUgbQEtDmTIhfqielrG5ExIM9TP4UoYdi90jLF1aTcsWCJNEO0UrgKzP0y3nTSg==", + "requires": { + "jake": "^10.6.1" + } }, "encodeurl": { "version": "1.0.2", @@ -163,6 +216,11 @@ "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, "etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", @@ -213,6 +271,14 @@ "basic-auth": "^2.0.1" } }, + "filelist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.1.tgz", + "integrity": "sha512-8zSK6Nu0DQIC08mUC46sWGXi+q3GGpKydAG36k+JDba6VRpkevvOWUW5a/PhShij4+vHT9M+ghgG7eM+a9JDUQ==", + "requires": { + "minimatch": "^3.0.4" + } + }, "finalhandler": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", @@ -237,6 +303,11 @@ "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, "http-errors": { "version": "1.7.2", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", @@ -268,16 +339,27 @@ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, "ipaddr.js": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz", - "integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==" + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==" }, "is-nan": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.2.1.tgz", - "integrity": "sha1-n69ltvttskt/XAYoR16nH5iEAeI=", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.3.0.tgz", + "integrity": "sha512-z7bbREymOqt2CCaZVly8aC4ML3Xhfi0ekuOnjO2L8vKdl+CttdVoGZQhd4adMFAsxQ5VeRVwORs4tU8RH+HFtQ==", + "requires": { + "define-properties": "^1.1.3" + } + }, + "jake": { + "version": "10.8.1", + "resolved": "https://registry.npmjs.org/jake/-/jake-10.8.1.tgz", + "integrity": "sha512-eSp5h9S7UFzKdQERTyF+KuPLjDZa1Tbw8gCVUn98n4PbIkLEDGe4zl7vF4Qge9kQj06HcymnksPk8jznPZeKsA==", "requires": { - "define-properties": "^1.1.1" + "async": "0.9.x", + "chalk": "^2.4.2", + "filelist": "^1.0.1", + "minimatch": "^3.0.4" } }, "lie": { @@ -289,9 +371,9 @@ } }, "localforage": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/localforage/-/localforage-1.7.3.tgz", - "integrity": "sha512-1TulyYfc4udS7ECSBT2vwJksWbkwwTX8BzeUIiq8Y07Riy7bDAAnxDaPU/tWyOVmQAcWJIEIFP9lPfBGqVoPgQ==", + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/localforage/-/localforage-1.7.4.tgz", + "integrity": "sha512-3EmVZatmNVeCo/t6Te7P06h2alGwbq8wXlSkcSXMvDE2/edPmsVqTPlzGnZaqwZZDBs6v+kxWpqjVsqsNJT8jA==", "requires": { "lie": "3.1.1" } @@ -317,40 +399,48 @@ "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" }, "mime-db": { - "version": "1.42.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.42.0.tgz", - "integrity": "sha512-UbfJCR4UAVRNgMpfImz05smAXK7+c+ZntjaA26ANtkXLlOe947Aag5zdIcKQULAiF9Cq4WxBi9jUs5zkA84bYQ==" + "version": "1.44.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", + "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==" }, "mime-types": { - "version": "2.1.25", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.25.tgz", - "integrity": "sha512-5KhStqB5xpTAeGqKBAMgwaYMnQik7teQN4IAzC7npDv6kzeU6prfkR67bc87J1kWMPGkoaZSq1npmexMgkmEVg==", + "version": "2.1.27", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", + "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", "requires": { - "mime-db": "1.42.0" + "mime-db": "1.44.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" } }, "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" }, "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", "requires": { - "minimist": "0.0.8" + "minimist": "^1.2.5" } }, "moment": { - "version": "2.24.0", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz", - "integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==" + "version": "2.26.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.26.0.tgz", + "integrity": "sha512-oIixUO+OamkUkwjhAVE18rAMfRJNsNe/Stid/gwHSOfHrOtw9EhAY2AHvdKZ/k/MggcYELFCJz/Sn2pL8b8JMw==" }, "moment-timezone": { - "version": "0.5.27", - "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.27.tgz", - "integrity": "sha512-EIKQs7h5sAsjhPCqN6ggx6cEbs94GK050254TIJySD1bzoM5JTYDwAU1IoVOeTOL6Gm27kYJ51/uuvq1kIlrbw==", + "version": "0.5.31", + "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.31.tgz", + "integrity": "sha512-+GgHNg8xRhMXfEbv81iDtrVeTcWt0kWmTEY1XQK14dICTXnWJnT0dxdlPspwqF3keKMVPXwayEsk1DI0AA/jdA==", "requires": { "moment": ">= 2.9.0" } @@ -370,6 +460,13 @@ "localforage": "^1.3.0", "mkdirp": "~0.5.1", "underscore": "~1.4.4" + }, + "dependencies": { + "async": { + "version": "0.2.10", + "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", + "integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=" + } } }, "negotiator": { @@ -378,9 +475,9 @@ "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" }, "nodemailer": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.3.1.tgz", - "integrity": "sha512-j0BsSyaMlyadEDEypK/F+xlne2K5m6wzPYMXS/yxKI0s7jmT1kBx6GEKRVbZmyYfKOsjkeC/TiMVDJBI/w5gMQ==" + "version": "6.4.8", + "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.4.8.tgz", + "integrity": "sha512-UbJD0+g5e2H20bWv7Rpj3B+N3TMMJ0MLoLwaGVJ0k3Vo8upq0UltwHJ5BJfrpST1vFa91JQ8cf7cICK5DSIo1Q==" }, "object-keys": { "version": "1.1.1", @@ -406,12 +503,12 @@ "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" }, "proxy-addr": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", - "integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz", + "integrity": "sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw==", "requires": { "forwarded": "~0.1.2", - "ipaddr.js": "1.9.0" + "ipaddr.js": "1.9.1" } }, "qs": { @@ -498,6 +595,14 @@ "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz", "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=" }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + }, "toidentifier": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", From 516fdeef688ee6950aa7fbbdee68bd87781507c0 Mon Sep 17 00:00:00 2001 From: alse Date: Mon, 8 Jun 2020 16:27:23 +0530 Subject: [PATCH 09/13] Making url paths relative to enable reverse proxy --- app.js | 5 +++-- package.json | 2 +- routes.js | 3 +++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index 2e10b30..23a7de9 100755 --- a/app.js +++ b/app.js @@ -30,6 +30,7 @@ if (BASIC_AUTH_USER && BASIC_AUTH_PWD) { // include the routes var routes = require("./routes").routes; +var routes_relative = require("./routes").relative // set the view engine to ejs app.set('view engine', 'ejs'); @@ -61,7 +62,7 @@ app.get(routes.root, function(req, res) { // send all the required parameters crontab.crontabs( function(docs){ res.render('index', { - routes : JSON.stringify(routes), + routes : JSON.stringify(routes_relative), crontabs : JSON.stringify(docs), backups : crontab.get_backup_names(), env : crontab.get_env(), @@ -130,7 +131,7 @@ app.get(routes.restore, function(req, res) { // get all the crontabs restore.crontabs(req.query.db, function(docs){ res.render('restore', { - routes : JSON.stringify(routes), + routes : JSON.stringify(routes_relative), crontabs : JSON.stringify(docs), backups : crontab.get_backup_names(), db: req.query.db diff --git a/package.json b/package.json index 27e8f95..08f0651 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "crontab-ui", - "version": "0.3.9", + "version": "0.3.10", "description": "Easy and safe way to manage your crontab file", "main": "index.js", "scripts": { diff --git a/routes.js b/routes.js index 3770272..2fb393f 100644 --- a/routes.js +++ b/routes.js @@ -16,3 +16,6 @@ exports.routes = { "logger": "/logger", "stdout": "/stdout", }; + +exports.relative = Object.keys(exports.routes).reduce((p, c) => ({...p, [c]: exports.routes[c].replace(/^\//, '')}), {}); +exports.relative["root"] = "."; \ No newline at end of file From fc553f2938b6b68235a8711c2eb499113178f552 Mon Sep 17 00:00:00 2001 From: alse Date: Mon, 8 Jun 2020 16:29:56 +0530 Subject: [PATCH 10/13] version bump to 0.3.11 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 08f0651..2ca5f3e 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "crontab-ui", - "version": "0.3.10", + "version": "0.3.11", "description": "Easy and safe way to manage your crontab file", "main": "index.js", "scripts": { From 42e677d8d26d11dfc0ade2fade80fbca8c120fd5 Mon Sep 17 00:00:00 2001 From: alse Date: Mon, 8 Jun 2020 22:34:42 +0530 Subject: [PATCH 11/13] Fixing cron not updating inside docker --- Dockerfile | 5 +++-- Makefile | 2 +- crontab.js | 22 ++++++++-------------- package.json | 2 +- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0a08dba..76f271c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,9 @@ # docker run -d -p 8000:8000 alseambusher/crontab-ui FROM alpine:3.10 -RUN mkdir /crontab-ui; touch /etc/crontabs/root; chmod +x /etc/crontabs/root +ENV CRON_PATH /etc/crontabs + +RUN mkdir /crontab-ui; touch $CRON_PATH/root; chmod +x $CRON_PATH/root WORKDIR /crontab-ui @@ -24,7 +26,6 @@ ENV HOST 0.0.0.0 ENV PORT 8000 -ENV CRON_PATH /etc/crontabs ENV CRON_IN_DOCKER true EXPOSE $PORT diff --git a/Makefile b/Makefile index fa2e750..7ac3636 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VER=0.3.9 +VER=0.3.12 release: sed -i '' "s/version\": \".*/version\": \"$(VER)\",/" package.json diff --git a/crontab.js b/crontab.js index d5c941f..5c0c1de 100644 --- a/crontab.js +++ b/crontab.js @@ -131,22 +131,16 @@ exports.set_crontab = function(env_vars, callback){ fs.writeFile(exports.env_file, env_vars, function(err) { if (err) callback(err); // In docker we're running as the root user, so we need to write the file as root and not crontab - var fileName = "crontab" - if(process.env.CRON_IN_DOCKER !== undefined) { - fileName = "root" - } + var fileName = process.env.CRON_IN_DOCKER !== undefined ? "root" : "crontab"; fs.writeFile(path.join(cronPath, fileName), crontab_string, function(err) { if (err) return callback(err); - /// In docker we're running crond using busybox implementation of crond - /// It is launched as part of the container startup process, so no need to run it again - if(process.env.CRON_IN_DOCKER === undefined) { - exec("crontab " + path.join(cronPath, "crontab"), function(err) { - if (err) return callback(err); - else callback(); - }); - } else { - callback(); - } + exec("crontab " + path.join(cronPath, fileName), function(err) { + if (err) { + console.error(err); + return callback(err); + } + else callback(); + }); }); }); }); diff --git a/package.json b/package.json index 2ca5f3e..36849a1 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "crontab-ui", - "version": "0.3.11", + "version": "0.3.12", "description": "Easy and safe way to manage your crontab file", "main": "index.js", "scripts": { From 970e461621e6906ce7259b9dfcacbff90dae858b Mon Sep 17 00:00:00 2001 From: alse Date: Mon, 8 Jun 2020 23:49:00 +0530 Subject: [PATCH 12/13] Handle case where there is invalid cron time expression --- app.js | 2 +- crontab.js | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index 23a7de9..c9309d2 100755 --- a/app.js +++ b/app.js @@ -215,7 +215,7 @@ app.use(function(err, req, res, next) { data.stack = err.stack; } - if (parseInt(data.statusCode) >= 500) { + if (statusCode >= 500) { console.error(err); } diff --git a/crontab.js b/crontab.js index 5c0c1de..dbd701a 100644 --- a/crontab.js +++ b/crontab.js @@ -62,7 +62,12 @@ exports.crontabs = function(callback){ if(docs[i].schedule == "@reboot") docs[i].next = "Next Reboot"; else - docs[i].next = cron_parser.parseExpression(docs[i].schedule).next().toString(); + try { + docs[i].next = cron_parser.parseExpression(docs[i].schedule).next().toString(); + } catch(err) { + console.error(err); + docs[i].next = "invalid"; + } } callback(docs); }); @@ -129,11 +134,18 @@ exports.set_crontab = function(env_vars, callback){ }); fs.writeFile(exports.env_file, env_vars, function(err) { - if (err) callback(err); + if (err) { + console.error(err); + callback(err); + } // In docker we're running as the root user, so we need to write the file as root and not crontab var fileName = process.env.CRON_IN_DOCKER !== undefined ? "root" : "crontab"; fs.writeFile(path.join(cronPath, fileName), crontab_string, function(err) { - if (err) return callback(err); + if (err) { + console.error(err); + return callback(err); + } + exec("crontab " + path.join(cronPath, fileName), function(err) { if (err) { console.error(err); From 8315ca4f5036ef93193486bfff5dd6cd7edd52bb Mon Sep 17 00:00:00 2001 From: alse Date: Tue, 9 Jun 2020 19:08:22 +0530 Subject: [PATCH 13/13] Adding support custom for CRON_DB_PATH --- app.js | 10 +++++----- crontab.js | 17 +++++++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/app.js b/app.js index c9309d2..8e28cca 100755 --- a/app.js +++ b/app.js @@ -153,7 +153,7 @@ app.get(routes.restore_backup, function(req, res) { // export current crontab db so that user can download it app.get(routes.export, function(req, res) { - var file = __dirname + '/crontabs/crontab.db'; + var file = crontab.crontab_db_file; var filename = path.basename(file); var mimetype = mime.lookup(file); @@ -170,7 +170,7 @@ app.post(routes.import, function(req, res) { var fstream; req.pipe(req.busboy); req.busboy.on('file', function (fieldname, file, filename) { - fstream = fs.createWriteStream(__dirname + '/crontabs/crontab.db'); + fstream = fs.createWriteStream(crontab.crontab_db_file); file.pipe(fstream); fstream.on('close', function () { crontab.reload_db(); @@ -244,7 +244,7 @@ app.listen(app.get('port'), app.get('host'), function() { // we do this by watching log file and setting a on change hook to it if (process.argv.includes("--autosave")){ crontab.autosave_crontab(()=>{}); - fs.watchFile(__dirname + '/crontabs/crontab.db', () => { + fs.watchFile(crontab.crontab_db_file, () => { crontab.autosave_crontab(()=>{ console.log("Attempted to autosave crontab"); }); @@ -252,8 +252,8 @@ app.listen(app.get('port'), app.get('host'), function() { } if (process.argv.includes("--reset")){ console.log("Resetting crontab-ui"); - var crontabdb = __dirname + "/crontabs/crontab.db"; - var envdb = __dirname + "/crontabs/env.db"; + var crontabdb = crontab.crontab_db_file; + var envdb = crontab.env_file; console.log("Deleting " + crontabdb); try{ diff --git a/crontab.js b/crontab.js index dbd701a..6e588b1 100644 --- a/crontab.js +++ b/crontab.js @@ -2,7 +2,14 @@ //load database var Datastore = require('nedb'); var path = require("path"); -var db = new Datastore({ filename: __dirname + '/crontabs/crontab.db' }); + +exports.db_folder = process.env.CRON_DB_PATH === undefined ? path.join(__dirname, "crontabs") : process.env.CRON_DB_PATH; +console.log("Cron db path: " + exports.db_folder); +exports.log_folder = path.join(exports.db_folder, 'logs'); +exports.env_file = path.join(exports.db_folder, 'env.db'); +exports.crontab_db_file = path.join(exports.db_folder, 'crontab.db'); + +var db = new Datastore({ filename: exports.crontab_db_file}); var cronPath = "/tmp"; if(process.env.CRON_PATH !== undefined) { @@ -18,8 +25,6 @@ var exec = require('child_process').exec; var fs = require('fs'); var cron_parser = require("cron-parser"); -exports.log_folder = __dirname + '/crontabs/logs'; -exports.env_file = __dirname + '/crontabs/env.db'; crontab = function(name, command, schedule, stopped, logging, mailing){ var data = {}; @@ -160,7 +165,7 @@ exports.set_crontab = function(env_vars, callback){ exports.get_backup_names = function(){ var backups = []; - fs.readdirSync(__dirname + '/crontabs').forEach(function(file){ + fs.readdirSync(exports.db_folder).forEach(function(file){ // file name begins with backup if(file.indexOf("backup") === 0){ backups.push(file); @@ -187,11 +192,11 @@ exports.get_backup_names = function(){ exports.backup = function(){ //TODO check if it failed - fs.createReadStream( __dirname + '/crontabs/crontab.db').pipe(fs.createWriteStream( __dirname + '/crontabs/backup ' + (new Date()).toString().replace("+", " ") + '.db')); + fs.createReadStream(exports.crontab_db_file).pipe(fs.createWriteStream( path.join(exports.db_folder, 'backup ' + (new Date()).toString().replace("+", " ") + '.db'))); }; exports.restore = function(db_name){ - fs.createReadStream( __dirname + '/crontabs/' + db_name).pipe(fs.createWriteStream( __dirname + '/crontabs/crontab.db')); + fs.createReadStream(path.join(exports.db_folder, db_name)).pipe(fs.createWriteStream(exports.crontab_db_file)); db.loadDatabase(); // reload the database };