start storing configs to FS

This commit is contained in:
LosslessBot 2016-07-08 03:36:51 +02:00
parent c50f1f73dd
commit bd6c76cbfd
8 changed files with 29 additions and 16 deletions

View File

@ -2,6 +2,7 @@
var plugins = require("./smartnginx.plugins"); var plugins = require("./smartnginx.plugins");
var paths = require("./smartnginx.paths"); var paths = require("./smartnginx.paths");
var command = require("./smartnginx.command"); var command = require("./smartnginx.command");
var snippets = require("./smartnginx.snippets");
var allConfigs = []; var allConfigs = [];
var NginxConfig = (function () { var NginxConfig = (function () {
function NginxConfig() { function NginxConfig() {
@ -20,8 +21,8 @@ var NginxConfig = (function () {
// handle deployment of zones // handle deployment of zones
NginxConfig.prototype.deploy = function (nginxRestartArg) { NginxConfig.prototype.deploy = function (nginxRestartArg) {
if (nginxRestartArg === void 0) { nginxRestartArg = false; } if (nginxRestartArg === void 0) { nginxRestartArg = false; }
plugins.smartfile.fs.remove(paths.nginxZoneBase); plugins.smartfile.fs.remove(paths.nginxConfigBase);
plugins.smartfile.fs.ensureDir(paths.nginxZoneBase); plugins.smartfile.fs.ensureDir(paths.nginxConfigBase);
for (var _i = 0, allConfigs_1 = allConfigs; _i < allConfigs_1.length; _i++) { for (var _i = 0, allConfigs_1 = allConfigs; _i < allConfigs_1.length; _i++) {
var config = allConfigs_1[_i]; var config = allConfigs_1[_i];
config.isDeployed = false; config.isDeployed = false;
@ -32,6 +33,8 @@ var NginxConfig = (function () {
var zone = _b[_a]; var zone = _b[_a];
zone.deploy(); zone.deploy();
} }
;
plugins.smartfile.memory.toFsSync(snippets.getBaseConfigString(), plugins.path.join(paths.nginxConfigBase, "nginx.conf"));
if (nginxRestartArg) { if (nginxRestartArg) {
command.restart(this); command.restart(this);
} }
@ -41,4 +44,4 @@ var NginxConfig = (function () {
}()); }());
exports.NginxConfig = NginxConfig; exports.NginxConfig = NginxConfig;
; ;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jbGFzc2VzLm5naW54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CxDQUFDO1FBQ0YsRUFBRSxDQUFBLENBQUMsZUFBZSxDQUFDLENBQUEsQ0FBQztZQUNoQixPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDO1FBQzFCLENBQUM7SUFDTCxDQUFDOztJQUVMLGtCQUFDO0FBQUQsQ0FBQyxBQXRDRCxJQXNDQztBQXRDWSxtQkFBVyxjQXNDdkIsQ0FBQTtBQUFBLENBQUMifQ==

View File

@ -4,3 +4,4 @@ export import path = require("path");
export import q = require("q"); export import q = require("q");
export declare let shelljs: any; export declare let shelljs: any;
export import smartfile = require("smartfile"); export import smartfile = require("smartfile");
export import smartstring = require("smartstring");

View File

@ -5,4 +5,5 @@ exports.path = require("path");
exports.q = require("q"); exports.q = require("q");
exports.shelljs = require("shelljs"); exports.shelljs = require("shelljs");
exports.smartfile = require("smartfile"); exports.smartfile = require("smartfile");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRuZ2lueC5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDVixZQUFJLFdBQVcsTUFBTSxDQUFDLENBQUM7QUFDdkIsWUFBSSxXQUFXLE1BQU0sQ0FBQyxDQUFDO0FBQ3ZCLFNBQUMsV0FBVyxHQUFHLENBQUMsQ0FBQztBQUNwQixlQUFPLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFDO0FBQzFCLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUMifQ== exports.smartstring = require("smartstring");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRuZ2lueC5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDVixZQUFJLFdBQVcsTUFBTSxDQUFDLENBQUM7QUFDdkIsWUFBSSxXQUFXLE1BQU0sQ0FBQyxDQUFDO0FBQ3ZCLFNBQUMsV0FBVyxHQUFHLENBQUMsQ0FBQztBQUNwQixlQUFPLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFDO0FBQzFCLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUM7QUFDakMsbUJBQVcsV0FBVyxhQUFhLENBQUMsQ0FBQyJ9

View File

@ -1,9 +1,10 @@
"use strict"; "use strict";
var plugins = require("./smartnginx.plugins");
exports.getBaseConfigString = function () { exports.getBaseConfigString = function () {
var baseConfig = "\n\t\tuser www-data;\n\t\tworker_processes auto;\n\t\tpid /run/nginx.pid;\n\n\t\tevents {\n\t\t\tworker_connections 768;\n\t\t\t# multi_accept on;\n\t\t}\n\n\t\thttp {\n\t\t\tserver_names_hash_bucket_size 128;\n\n\t\t\t##\n\t\t\t# Basic Settings\n\t\t\t##\n\n\t\t\tsendfile on;\n\t\t\ttcp_nopush on;\n\t\t\ttcp_nodelay on;\n\t\t\tkeepalive_timeout 65;\n\t\t\ttypes_hash_max_size 2048;\n\t\t\t# server_tokens off;\n\n\t\t\t# server_names_hash_bucket_size 64;\n\t\t\t# server_name_in_redirect off;\n\n\t\t\tinclude /etc/nginx/mime.types;\n\t\t\tdefault_type application/octet-stream;\n\n\t\t\t##\n\t\t\t# SSL Settings\n\t\t\t##\n\n\t\t\tssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE\n\t\t\tssl_prefer_server_ciphers on;\n\n\t\t\t##\n\t\t\t# Logging Settings\n\t\t\t##\n\n\t\t\taccess_log /var/log/nginx/access.log;\n\t\t\terror_log /var/log/nginx/error.log;\n\n\t\t\t##\n\t\t\t# Gzip Settings\n\t\t\t##\n\n\t\t\tgzip on;\n\t\t\tgzip_disable \"msie6\";\n\n\t\t\t# gzip_vary on;\n\t\t\t# gzip_proxied any;\n\t\t\t# gzip_comp_level 6;\n\t\t\t# gzip_buffers 16 8k;\n\t\t\t# gzip_http_version 1.1;\n\t\t\t# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;\n\n\t\t\t##\n\t\t\t# Virtual Host Configs\n\t\t\t##\n\n\t\t\tinclude /etc/nginx/conf.d/*.conf;\n\t\t\tinclude /etc/nginx/sites-enabled/*;\n\t\t}\n\t\tdaemon off;\n\t"; var baseConfig = plugins.smartstring.indent.normalize("\n\t\tuser www-data;\n\t\tworker_processes auto;\n\t\tpid /run/nginx.pid;\n\n\t\tevents {\n\t\t\tworker_connections 768;\n\t\t\t# multi_accept on;\n\t\t}\n\n\t\thttp {\n\t\t\tserver_names_hash_bucket_size 128;\n\n\t\t\t##\n\t\t\t# Basic Settings\n\t\t\t##\n\n\t\t\tsendfile on;\n\t\t\ttcp_nopush on;\n\t\t\ttcp_nodelay on;\n\t\t\tkeepalive_timeout 65;\n\t\t\ttypes_hash_max_size 2048;\n\t\t\t# server_tokens off;\n\n\t\t\t# server_names_hash_bucket_size 64;\n\t\t\t# server_name_in_redirect off;\n\n\t\t\tinclude /etc/nginx/mime.types;\n\t\t\tdefault_type application/octet-stream;\n\n\t\t\t##\n\t\t\t# SSL Settings\n\t\t\t##\n\n\t\t\tssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE\n\t\t\tssl_prefer_server_ciphers on;\n\n\t\t\t##\n\t\t\t# Logging Settings\n\t\t\t##\n\n\t\t\taccess_log /var/log/nginx/access.log;\n\t\t\terror_log /var/log/nginx/error.log;\n\n\t\t\t##\n\t\t\t# Gzip Settings\n\t\t\t##\n\n\t\t\tgzip on;\n\t\t\tgzip_disable \"msie6\";\n\n\t\t\t# gzip_vary on;\n\t\t\t# gzip_proxied any;\n\t\t\t# gzip_comp_level 6;\n\t\t\t# gzip_buffers 16 8k;\n\t\t\t# gzip_http_version 1.1;\n\t\t\t# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;\n\n\t\t\t##\n\t\t\t# Virtual Host Configs\n\t\t\t##\n\n\t\t\tinclude /etc/nginx/conf.d/*.conf;\n\t\t\tinclude /etc/nginx/sites-enabled/*;\n\t\t}\n\t\tdaemon off;\n\t");
}; };
exports.getZoneConfigString = function (zoneNameArg, destinationIpArg) { exports.getZoneConfigString = function (zoneNameArg, destinationIpArg) {
var zoneConfig = ("\n\t\tupstream " + zoneNameArg + " {\n\t\t\tserver " + destinationIpArg + ";\n\t\t}\n\n\t\tserver {\n\t\t\tlisten *:80 ;\n\t\t\tserver_name " + zoneNameArg + ";\n\t\t\trewrite ^ https://" + zoneNameArg + "$request_uri? permanent;\n\t\t}\n\n\t\tserver {\n\t\t\tlisten *:443 ssl;\n\t\t\tserver_name " + zoneNameArg + ";\n\t\t\tssl_certificate /LE_CERTS/" + zoneNameArg + "/fullchain.pem;\n\t\t\tssl_certificate_key /LE_CERTS/" + zoneNameArg + "/privkey.pem;\n\n\t\t\tlocation / {\n\t\t\t\tproxy_pass http://" + zoneNameArg + ";\n\t\t\t\tinclude /etc/nginx/proxy_params;\n\t\t\t}\n\t\t\tlocation ~ /.git {\n\t\t\t\tdeny all;\n\t\t\t}\n\t\t}\n\t").trim(); var zoneConfig = plugins.smartstring.indent.normalize("\n\t\tupstream " + zoneNameArg + " {\n\t\t\tserver " + destinationIpArg + ";\n\t\t}\n\n\t\tserver {\n\t\t\tlisten *:80 ;\n\t\t\tserver_name " + zoneNameArg + ";\n\t\t\trewrite ^ https://" + zoneNameArg + "$request_uri? permanent;\n\t\t}\n\n\t\tserver {\n\t\t\tlisten *:443 ssl;\n\t\t\tserver_name " + zoneNameArg + ";\n\t\t\tssl_certificate /LE_CERTS/" + zoneNameArg + "/fullchain.pem;\n\t\t\tssl_certificate_key /LE_CERTS/" + zoneNameArg + "/privkey.pem;\n\n\t\t\tlocation / {\n\t\t\t\tproxy_pass http://" + zoneNameArg + ";\n\t\t\t\tinclude /etc/nginx/proxy_params;\n\t\t\t}\n\t\t\tlocation ~ /.git {\n\t\t\t\tdeny all;\n\t\t\t}\n\t\t}\n\t");
return zoneConfig; return zoneConfig;
}; };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5zbmlwcGV0cy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbnguc25pcHBldHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFXLDJCQUFtQixHQUFHO0lBQ2hDLElBQUksVUFBVSxHQUFHLDY0Q0FrRWhCLENBQUM7QUFDSCxDQUFDLENBQUE7QUFHVSwyQkFBbUIsR0FBRyxVQUFDLFdBQWtCLEVBQUMsZ0JBQXVCO0lBQzNFLElBQUksVUFBVSxHQUFHLHFCQUNMLFdBQVcseUJBQ1osZ0JBQWdCLHlFQUtYLFdBQVcsMENBQ0UsV0FBVyxvR0FLeEIsV0FBVywyQ0FDRyxXQUFXLDZEQUNQLFdBQVcsdUVBR3RCLFdBQVcsMkhBT2pDLENBQUMsSUFBSSxFQUFFLENBQUM7SUFDVCxNQUFNLENBQUMsVUFBVSxDQUFDO0FBQ25CLENBQUMsQ0FBQyJ9 //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5zbmlwcGV0cy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbnguc25pcHBldHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQVksT0FBTyxXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFDckMsMkJBQW1CLEdBQUc7SUFDaEMsSUFBSSxVQUFVLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLDY0Q0FrRXJELENBQUMsQ0FBQztBQUNKLENBQUMsQ0FBQTtBQUdVLDJCQUFtQixHQUFHLFVBQUMsV0FBa0IsRUFBQyxnQkFBdUI7SUFDM0UsSUFBSSxVQUFVLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLG9CQUMxQyxXQUFXLHlCQUNaLGdCQUFnQix5RUFLWCxXQUFXLDBDQUNFLFdBQVcsb0dBS3hCLFdBQVcsMkNBQ0csV0FBVyw2REFDUCxXQUFXLHVFQUd0QixXQUFXLDBIQU9qQyxDQUFDLENBQUM7SUFDSCxNQUFNLENBQUMsVUFBVSxDQUFDO0FBQ25CLENBQUMsQ0FBQyJ9

View File

@ -26,7 +26,7 @@
"q": "^1.4.1", "q": "^1.4.1",
"shelljs": "^0.7.0", "shelljs": "^0.7.0",
"smartfile": "^4.0.10", "smartfile": "^4.0.10",
"smartstring": "^2.0.10" "smartstring": "^2.0.14"
}, },
"devDependencies": { "devDependencies": {
"npmts-g": "^5.2.6", "npmts-g": "^5.2.6",

View File

@ -1,6 +1,7 @@
import * as plugins from "./smartnginx.plugins"; import * as plugins from "./smartnginx.plugins";
import * as paths from "./smartnginx.paths"; import * as paths from "./smartnginx.paths";
import * as command from "./smartnginx.command"; import * as command from "./smartnginx.command";
import * as snippets from "./smartnginx.snippets"
import {NginxZone} from "./smartnginx.classes.nginxzone"; import {NginxZone} from "./smartnginx.classes.nginxzone";
let allConfigs:NginxConfig[] = []; let allConfigs:NginxConfig[] = [];
@ -24,15 +25,19 @@ export class NginxConfig {
// handle deployment of zones // handle deployment of zones
deploy(nginxRestartArg:boolean = false){ deploy(nginxRestartArg:boolean = false){
plugins.smartfile.fs.remove(paths.nginxZoneBase); plugins.smartfile.fs.remove(paths.nginxConfigBase);
plugins.smartfile.fs.ensureDir(paths.nginxZoneBase); plugins.smartfile.fs.ensureDir(paths.nginxConfigBase);
for(let config of allConfigs){ for(let config of allConfigs){
config.isDeployed = false; config.isDeployed = false;
}; };
this.isDeployed = true; this.isDeployed = true;
for(let zone of this.zones){ for(let zone of this.zones){
zone.deploy(); zone.deploy();
} };
plugins.smartfile.memory.toFsSync(
snippets.getBaseConfigString(),
plugins.path.join(paths.nginxConfigBase,"nginx.conf")
);
if(nginxRestartArg){ if(nginxRestartArg){
command.restart(this); command.restart(this);
} }

View File

@ -4,3 +4,4 @@ export import path = require("path");
export import q = require("q"); export import q = require("q");
export let shelljs = require("shelljs"); export let shelljs = require("shelljs");
export import smartfile = require("smartfile"); export import smartfile = require("smartfile");
export import smartstring = require("smartstring");

View File

@ -1,5 +1,6 @@
import * as plugins from "./smartnginx.plugins";
export let getBaseConfigString = () => { export let getBaseConfigString = () => {
let baseConfig = ` let baseConfig = plugins.smartstring.indent.normalize(`
user www-data; user www-data;
worker_processes auto; worker_processes auto;
pid /run/nginx.pid; pid /run/nginx.pid;
@ -65,12 +66,12 @@ export let getBaseConfigString = () => {
include /etc/nginx/sites-enabled/*; include /etc/nginx/sites-enabled/*;
} }
daemon off; daemon off;
`; `);
} }
export let getZoneConfigString = (zoneNameArg:string,destinationIpArg:string) => { export let getZoneConfigString = (zoneNameArg:string,destinationIpArg:string) => {
let zoneConfig = ` let zoneConfig = plugins.smartstring.indent.normalize(`
upstream ${zoneNameArg} { upstream ${zoneNameArg} {
server ${destinationIpArg}; server ${destinationIpArg};
} }
@ -95,7 +96,7 @@ export let getZoneConfigString = (zoneNameArg:string,destinationIpArg:string) =>
deny all; deny all;
} }
} }
`; `);
return zoneConfig; return zoneConfig;
}; };