integrate cert
This commit is contained in:
parent
244b21ca36
commit
e0757600b6
@ -24,7 +24,7 @@
|
||||
"dependencies": {
|
||||
"@types/q": "*",
|
||||
"beautylog": "^5.0.13",
|
||||
"cert": "0.0.13",
|
||||
"cert": "0.0.15",
|
||||
"q": "^1.4.1",
|
||||
"shelljs": "^0.7.0",
|
||||
"smartfile": "^4.0.10",
|
||||
|
@ -7,9 +7,15 @@ let allConfigs:NginxConfig[] = [];
|
||||
|
||||
export class NginxConfig {
|
||||
zones:NginxZone[] = [];
|
||||
cert:plugins.cert.Cert; // the Cert Instance from which the config gets its certificates
|
||||
isDeployed:boolean = false;
|
||||
constructor(){
|
||||
|
||||
constructor(optionsArg:plugins.cert.CertConstructorOptions){
|
||||
this.cert = new plugins.cert.Cert({
|
||||
cfEmail:optionsArg.cfEmail,
|
||||
cfKey:optionsArg.cfKey,
|
||||
sslDir:optionsArg.sslDir,
|
||||
gitOriginRepo:optionsArg.gitOriginRepo
|
||||
});
|
||||
};
|
||||
|
||||
// interact with Zones
|
||||
@ -25,22 +31,34 @@ export class NginxConfig {
|
||||
|
||||
// handle deployment of zones
|
||||
deploy(nginxRestartArg:boolean = false){
|
||||
let done = plugins.q.defer();
|
||||
plugins.smartfile.fs.removeSync(paths.nginxConfigBase);
|
||||
plugins.smartfile.fs.ensureDirSync(paths.nginxConfigBase);
|
||||
plugins.smartfile.fs.ensureDirSync(paths.nginxZoneBase);
|
||||
plugins.smartfile.fs.ensureDirSync(paths.nginxCertBase);
|
||||
for(let config of allConfigs){
|
||||
config.isDeployed = false;
|
||||
};
|
||||
this.isDeployed = true;
|
||||
for(let zone of this.zones){
|
||||
zone.deploy();
|
||||
};
|
||||
// write base config
|
||||
plugins.smartfile.memory.toFsSync(
|
||||
snippets.getBaseConfigString(),
|
||||
plugins.path.join(paths.nginxConfigBase,"nginx.conf")
|
||||
);
|
||||
// deploy zones
|
||||
let promiseArray = [];
|
||||
for(let zone of this.zones){
|
||||
promiseArray.push(zone.deploy(this.cert));
|
||||
};
|
||||
plugins.q.all(promiseArray)
|
||||
.then(() => {
|
||||
// restart nginx
|
||||
if(nginxRestartArg){
|
||||
command.restart(this);
|
||||
};
|
||||
done.resolve();
|
||||
});
|
||||
|
||||
return done.promise;
|
||||
};
|
||||
};
|
||||
|
@ -22,8 +22,14 @@ export class NginxZone {
|
||||
this.destination = optionsArg.destination;
|
||||
this.configString = snippets.getZoneConfigString(optionsArg.zoneName,optionsArg.destination);
|
||||
};
|
||||
deploy(){
|
||||
deploy(certInstanceArg:plugins.cert.Cert){
|
||||
let done = plugins.q.defer();
|
||||
let filePath = plugins.path.join(paths.nginxZoneBase,this.zoneName + ".conf");
|
||||
// writeConfig
|
||||
plugins.smartfile.memory.toFsSync(this.configString,filePath);
|
||||
// get cert
|
||||
certInstanceArg.getDomainCert(this.zoneName)
|
||||
.then(done.resolve);
|
||||
return done.promise;
|
||||
};
|
||||
};
|
@ -1,5 +1,6 @@
|
||||
import * as plugins from "./smartnginx.plugins"
|
||||
|
||||
export let packageBase = plugins.path.join(__dirname,"../");
|
||||
export let nginxConfigBase = plugins.path.join(packageBase,"nginxconfig/");
|
||||
export let nginxConfigBase = plugins.path.join(packageBase,"nginxconfig");
|
||||
export let nginxZoneBase = plugins.path.join(nginxConfigBase,"zones");
|
||||
export let nginxCertBase = plugins.path.join(nginxConfigBase,"cert");
|
Loading…
Reference in New Issue
Block a user