now writing configs properly to disk
This commit is contained in:
parent
9864dcc56a
commit
43e8549042
10
dist/smartnginx.classes.nginxconfig.js
vendored
10
dist/smartnginx.classes.nginxconfig.js
vendored
@ -6,11 +6,13 @@ var snippets = require("./smartnginx.snippets");
|
||||
var allConfigs = [];
|
||||
var NginxConfig = (function () {
|
||||
function NginxConfig() {
|
||||
this.zones = [];
|
||||
this.isDeployed = false;
|
||||
}
|
||||
;
|
||||
// interact with Zones
|
||||
NginxConfig.prototype.addZone = function (zoneArg) {
|
||||
this.zones.push(zoneArg);
|
||||
};
|
||||
NginxConfig.prototype.listZones = function () {
|
||||
return this.zones;
|
||||
@ -21,8 +23,9 @@ var NginxConfig = (function () {
|
||||
// handle deployment of zones
|
||||
NginxConfig.prototype.deploy = function (nginxRestartArg) {
|
||||
if (nginxRestartArg === void 0) { nginxRestartArg = false; }
|
||||
plugins.smartfile.fs.remove(paths.nginxConfigBase);
|
||||
plugins.smartfile.fs.ensureDir(paths.nginxConfigBase);
|
||||
plugins.smartfile.fs.removeSync(paths.nginxConfigBase);
|
||||
plugins.smartfile.fs.ensureDirSync(paths.nginxConfigBase);
|
||||
plugins.smartfile.fs.ensureDirSync(paths.nginxZoneBase);
|
||||
for (var _i = 0, allConfigs_1 = allConfigs; _i < allConfigs_1.length; _i++) {
|
||||
var config = allConfigs_1[_i];
|
||||
config.isDeployed = false;
|
||||
@ -38,10 +41,11 @@ var NginxConfig = (function () {
|
||||
if (nginxRestartArg) {
|
||||
command.restart(this);
|
||||
}
|
||||
;
|
||||
};
|
||||
;
|
||||
return NginxConfig;
|
||||
}());
|
||||
exports.NginxConfig = NginxConfig;
|
||||
;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jbGFzc2VzLm5naW54Y29uZmlnLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRuZ2lueC5jbGFzc2VzLm5naW54Y29uZmlnLn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sQ0FBYSxVQUFVLEVBQVYsS0FBQSxJQUFJLENBQUMsS0FBSyxFQUFWLGNBQVUsRUFBVixJQUFVLENBQUM7WUFBdkIsSUFBSSxJQUFJLFNBQUE7WUFDUixJQUFJLENBQUMsTUFBTSxFQUFFLENBQUM7U0FDakI7UUFBQSxDQUFDO1FBQ0YsT0FBTyxDQUFDLFNBQVMsQ0FBQyxNQUFNLENBQUMsUUFBUSxDQUM3QixRQUFRLENBQUMsbUJBQW1CLEVBQUUsRUFDOUIsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDLGVBQWUsRUFBQyxZQUFZLENBQUMsQ0FDeEQsQ0FBQztRQUNGLEVBQUUsQ0FBQSxDQUFDLGVBQWUsQ0FBQyxDQUFBLENBQUM7WUFDaEIsT0FBTyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUMxQixDQUFDO1FBQUEsQ0FBQztJQUNOLENBQUM7O0lBQ0wsa0JBQUM7QUFBRCxDQUFDLEFBdENELElBc0NDO0FBdENZLG1CQUFXLGNBc0N2QixDQUFBO0FBQUEsQ0FBQyJ9
|
2
dist/smartnginx.classes.nginxzone.d.ts
vendored
2
dist/smartnginx.classes.nginxzone.d.ts
vendored
@ -4,6 +4,8 @@ export declare enum zoneTypes {
|
||||
}
|
||||
export declare class NginxZone {
|
||||
zoneName: string;
|
||||
type: zoneTypes;
|
||||
destination: string;
|
||||
configString: string;
|
||||
constructor(optionsArg: {
|
||||
zoneName: string;
|
||||
|
5
dist/smartnginx.classes.nginxzone.js
vendored
5
dist/smartnginx.classes.nginxzone.js
vendored
@ -9,6 +9,9 @@ var snippets = require("./smartnginx.snippets");
|
||||
var zoneTypes = exports.zoneTypes;
|
||||
var NginxZone = (function () {
|
||||
function NginxZone(optionsArg) {
|
||||
this.zoneName = optionsArg.zoneName;
|
||||
this.type = optionsArg.type;
|
||||
this.destination = optionsArg.destination;
|
||||
this.configString = snippets.getZoneConfigString(optionsArg.zoneName, optionsArg.destination);
|
||||
}
|
||||
;
|
||||
@ -21,4 +24,4 @@ var NginxZone = (function () {
|
||||
}());
|
||||
exports.NginxZone = NginxZone;
|
||||
;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jbGFzc2VzLm5naW54em9uZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbnguY2xhc3Nlcy5uZ2lueHpvbmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQVksT0FBTyxXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFDaEQsSUFBWSxLQUFLLFdBQU0sb0JBQW9CLENBQUMsQ0FBQTtBQUU1QyxJQUFZLFFBQVEsV0FBTSx1QkFDMUIsQ0FBQyxDQURnRDtBQUNqRCxXQUFZLFNBQVM7SUFDZCx5REFBWSxDQUFBO0lBQ1osNkNBQU0sQ0FBQTtBQUNiLENBQUMsRUFIVyxpQkFBUyxLQUFULGlCQUFTLFFBR3BCO0FBSEQsSUFBWSxTQUFTLEdBQVQsaUJBR1gsQ0FBQTtBQUVEO0lBR0ksbUJBQVksVUFJWDtRQUNHLElBQUksQ0FBQyxZQUFZLEdBQUcsUUFBUSxDQUFDLG1CQUFtQixDQUFDLFVBQVUsQ0FBQyxRQUFRLEVBQUMsVUFBVSxDQUFDLFdBQVcsQ0FBQyxDQUFDO0lBQ2pHLENBQUM7O0lBQ0QsMEJBQU0sR0FBTjtRQUNJLElBQUksUUFBUSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxhQUFhLEVBQUMsSUFBSSxDQUFDLFFBQVEsR0FBRyxPQUFPLENBQUMsQ0FBQztRQUM5RSxPQUFPLENBQUMsU0FBUyxDQUFDLE1BQU0sQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLFlBQVksR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FBUSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxhQUFhLEVBQUMsSUFBSSxDQUFDLFFBQVEsR0FBRyxPQUFPLENBQUMsQ0FBQztRQUM5RSxPQUFPLENBQUMsU0FBUyxDQUFDLE1BQU0sQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLFlBQVksRUFBQyxRQUFRLENBQUMsQ0FBQztJQUNsRSxDQUFDOztJQUNMLGdCQUFDO0FBQUQsQ0FBQyxBQW5CRCxJQW1CQztBQW5CWSxpQkFBUyxZQW1CckIsQ0FBQTtBQUFBLENBQUMifQ==
|
2
dist/smartnginx.snippets.d.ts
vendored
2
dist/smartnginx.snippets.d.ts
vendored
@ -1,2 +1,2 @@
|
||||
export declare let getBaseConfigString: () => void;
|
||||
export declare let getBaseConfigString: () => string;
|
||||
export declare let getZoneConfigString: (zoneNameArg: string, destinationIpArg: string) => string;
|
||||
|
3
dist/smartnginx.snippets.js
vendored
3
dist/smartnginx.snippets.js
vendored
@ -2,9 +2,10 @@
|
||||
var plugins = require("./smartnginx.plugins");
|
||||
exports.getBaseConfigString = function () {
|
||||
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");
|
||||
return baseConfig;
|
||||
};
|
||||
exports.getZoneConfigString = function (zoneNameArg, destinationIpArg) {
|
||||
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;
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5zbmlwcGV0cy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbnguc25pcHBldHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQVksT0FBTyxXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFDckMsMkJBQW1CLEdBQUc7SUFDaEMsSUFBSSxVQUFVLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLDY0Q0FrRXJELENBQUMsQ0FBQztBQUNKLENBQUMsQ0FBQTtBQUdVLDJCQUFtQixHQUFHLFVBQUMsV0FBa0IsRUFBQyxnQkFBdUI7SUFDM0UsSUFBSSxVQUFVLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLG9CQUMxQyxXQUFXLHlCQUNaLGdCQUFnQix5RUFLWCxXQUFXLDBDQUNFLFdBQVcsb0dBS3hCLFdBQVcsMkNBQ0csV0FBVyw2REFDUCxXQUFXLHVFQUd0QixXQUFXLDBIQU9qQyxDQUFDLENBQUM7SUFDSCxNQUFNLENBQUMsVUFBVSxDQUFDO0FBQ25CLENBQUMsQ0FBQyJ9
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5zbmlwcGV0cy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbnguc25pcHBldHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQVksT0FBTyxXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFDckMsMkJBQW1CLEdBQUc7SUFDaEMsSUFBSSxVQUFVLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLDY0Q0FrRXJELENBQUMsQ0FBQztJQUNILE1BQU0sQ0FBQyxVQUFVLENBQUM7QUFDbkIsQ0FBQyxDQUFBO0FBR1UsMkJBQW1CLEdBQUcsVUFBQyxXQUFrQixFQUFDLGdCQUF1QjtJQUMzRSxJQUFJLFVBQVUsR0FBRyxPQUFPLENBQUMsV0FBVyxDQUFDLE1BQU0sQ0FBQyxTQUFTLENBQUMsb0JBQzFDLFdBQVcseUJBQ1osZ0JBQWdCLHlFQUtYLFdBQVcsMENBQ0UsV0FBVyxvR0FLeEIsV0FBVywyQ0FDRyxXQUFXLDZEQUNQLFdBQVcsdUVBR3RCLFdBQVcsMEhBT2pDLENBQUMsQ0FBQztJQUNILE1BQU0sQ0FBQyxVQUFVLENBQUM7QUFDbkIsQ0FBQyxDQUFDIn0=
|
@ -8,7 +8,7 @@ events {
|
||||
}
|
||||
|
||||
http {
|
||||
server_names_hash_bucket_size 128;
|
||||
server_names_hash_bucket_size 128;
|
||||
|
||||
##
|
||||
# Basic Settings
|
||||
@ -62,4 +62,4 @@ http {
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
include /etc/nginx/sites-enabled/*;
|
||||
}
|
||||
daemon off;
|
||||
daemon off;
|
||||
|
@ -5,7 +5,8 @@
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "(npmts)"
|
||||
"test": "(npmts)",
|
||||
"cleanTest":"(rm -r nginxconfig)"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
12
test/test.js
12
test/test.js
@ -22,6 +22,16 @@ describe("smartnginx", function () {
|
||||
testNginxConfig = new smartnginx.NginxConfig();
|
||||
testNginxConfig.should.be.instanceof(smartnginx.NginxConfig);
|
||||
});
|
||||
describe(".addZone()", function () {
|
||||
it("should add a zone to NginxConfig Object", function () {
|
||||
testNginxConfig.addZone(testNginxZone01);
|
||||
});
|
||||
});
|
||||
describe(".deploy()", function () {
|
||||
it("should deploy a config from an instance", function () {
|
||||
testNginxConfig.deploy();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsUUFBTyxRQUFRLENBQUMsQ0FBQTtBQUNoQixJQUFZLFVBQVUsV0FBTSxlQUFlLENBQUMsQ0FBQTtBQUU1QyxRQUFRLENBQUMsWUFBWSxFQUFDO0lBQ2xCLElBQUksZUFBc0MsQ0FBQztJQUMzQyxJQUFJLGVBQW9DLENBQUM7SUFDekMsSUFBSSxlQUFvQyxDQUFDO0lBQ3pDLFFBQVEsQ0FBQyxXQUFXLEVBQUM7UUFDakIsRUFBRSxDQUFDLCtEQUE2RCxFQUFDO1lBQzdELGVBQWUsR0FBRyxJQUFJLFVBQVUsQ0FBQyxTQUFTLENBQUM7Z0JBQ3ZDLFFBQVEsRUFBQyxlQUFlO2dCQUN4QixJQUFJLEVBQUMsVUFBVSxDQUFDLFNBQVMsQ0FBQyxZQUFZO2dCQUN0QyxXQUFXLEVBQUMsaUJBQWlCO2FBQ2hDLENBQUMsQ0FBQztZQUNILGVBQWUsQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLFVBQVUsQ0FBQyxVQUFVLENBQUMsU0FBUyxDQUFDLENBQUM7WUFDM0QsT0FBTyxDQUFDLEdBQUcsQ0FBQyxlQUFlLENBQUMsWUFBWSxDQUFDLENBQUM7UUFDOUMsQ0FBQyxDQUFDLENBQUM7SUFDUCxDQUFDLENBQUMsQ0FBQztJQUNILFFBQVEsQ0FBQyxhQUFhLEVBQUM7UUFDbkIsRUFBRSxDQUFDLGlFQUErRCxFQU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ENBQUMsWUFBWSxDQUFDLENBQUM7UUFDOUMsQ0FBQyxDQUFDLENBQUM7SUFDUCxDQUFDLENBQUMsQ0FBQztJQUNILFFBQVEsQ0FBQyxhQUFhLEVBQUM7UUFDbkIsRUFBRSxDQUFDLGlFQUErRCxFQUFDO1lBQy9ELGVBQWUsR0FBRyxJQUFJLFVBQVUsQ0FBQyxXQUFXLEVBQUUsQ0FBQztZQUMvQyxlQUFlLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUMsVUFBVSxDQUFDLFdBQVcsQ0FBQyxDQUFDO1FBQ2pFLENBQUMsQ0FBQyxDQUFDO1FBQ0gsUUFBUSxDQUFDLFlBQVksRUFBQztZQUNsQixFQUFFLENBQUMseUNBQXlDLEVBQUM7Z0JBQ3pDLGVBQWUsQ0FBQyxPQUFPLENBQUMsZUFBZSxDQUFDLENBQUM7WUFDN0MsQ0FBQyxDQUFDLENBQUE7UUFDTixDQUFDLENBQUMsQ0FBQztRQUNILFFBQVEsQ0FBQyxXQUFXLEVBQUM7WUFDakIsRUFBRSxDQUFDLHlDQUF5QyxFQUFDO2dCQUN6QyxlQUFlLENBQUMsTUFBTSxFQUFFLENBQUM7WUFDN0IsQ0FBQyxDQUFDLENBQUE7UUFDTixDQUFDLENBQUMsQ0FBQztJQUNQLENBQUMsQ0FBQyxDQUFDO0FBQ1AsQ0FBQyxDQUFDLENBQUMifQ==
|
12
test/test.ts
12
test/test.ts
@ -21,6 +21,16 @@ describe("smartnginx",function(){
|
||||
it(`"new NginxConfig()" should produce an instance of NginxConfig`,function(){
|
||||
testNginxConfig = new smartnginx.NginxConfig();
|
||||
testNginxConfig.should.be.instanceof(smartnginx.NginxConfig);
|
||||
});
|
||||
});
|
||||
describe(".addZone()",function(){
|
||||
it("should add a zone to NginxConfig Object",function(){
|
||||
testNginxConfig.addZone(testNginxZone01);
|
||||
})
|
||||
});
|
||||
describe(".deploy()",function(){
|
||||
it("should deploy a config from an instance",function(){
|
||||
testNginxConfig.deploy();
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -6,7 +6,7 @@ import {NginxZone} from "./smartnginx.classes.nginxzone";
|
||||
let allConfigs:NginxConfig[] = [];
|
||||
|
||||
export class NginxConfig {
|
||||
zones:NginxZone[];
|
||||
zones:NginxZone[] = [];
|
||||
isDeployed:boolean = false;
|
||||
constructor(){
|
||||
|
||||
@ -14,7 +14,7 @@ export class NginxConfig {
|
||||
|
||||
// interact with Zones
|
||||
addZone(zoneArg:NginxZone){
|
||||
|
||||
this.zones.push(zoneArg);
|
||||
}
|
||||
listZones():NginxZone[] {
|
||||
return this.zones;
|
||||
@ -25,8 +25,9 @@ export class NginxConfig {
|
||||
|
||||
// handle deployment of zones
|
||||
deploy(nginxRestartArg:boolean = false){
|
||||
plugins.smartfile.fs.remove(paths.nginxConfigBase);
|
||||
plugins.smartfile.fs.ensureDir(paths.nginxConfigBase);
|
||||
plugins.smartfile.fs.removeSync(paths.nginxConfigBase);
|
||||
plugins.smartfile.fs.ensureDirSync(paths.nginxConfigBase);
|
||||
plugins.smartfile.fs.ensureDirSync(paths.nginxZoneBase);
|
||||
for(let config of allConfigs){
|
||||
config.isDeployed = false;
|
||||
};
|
||||
@ -40,7 +41,6 @@ export class NginxConfig {
|
||||
);
|
||||
if(nginxRestartArg){
|
||||
command.restart(this);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
@ -9,12 +9,17 @@ export enum zoneTypes {
|
||||
|
||||
export class NginxZone {
|
||||
zoneName:string; // the zone name e.g. domain name
|
||||
type:zoneTypes;
|
||||
destination:string;
|
||||
configString:string; // the actual zone config file as string
|
||||
constructor(optionsArg:{
|
||||
zoneName:string,
|
||||
type:zoneTypes,
|
||||
destination:string
|
||||
}){
|
||||
this.zoneName = optionsArg.zoneName;
|
||||
this.type = optionsArg.type;
|
||||
this.destination = optionsArg.destination;
|
||||
this.configString = snippets.getZoneConfigString(optionsArg.zoneName,optionsArg.destination);
|
||||
};
|
||||
deploy(){
|
||||
|
@ -67,6 +67,7 @@ export let getBaseConfigString = () => {
|
||||
}
|
||||
daemon off;
|
||||
`);
|
||||
return baseConfig;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user