now creating config as standard

This commit is contained in:
2016-06-26 16:16:12 +02:00
parent 062f3ad060
commit f74b3a51b0
7 changed files with 54 additions and 32 deletions

View File

@@ -14,14 +14,15 @@ export class SshConfig {
*/
store(dirPathArg:string){
let done = plugins.q.defer();
let configArray:configObject[];
let configArray:configObject[] = [];
let configString;
for(let key in this.sshKeyArray){
let sshKey = this.sshKeyArray[key];
if(sshKey.host){
configString = "Host " + sshKey.host + "\n" +
" HostName " + sshKey.host + "\n" +
" IdentityFile ~/.ssh/" + sshKey.host + "\n"
" IdentityFile ~/.ssh/" + sshKey.host + "\n" +
" StrictHostKeyChecking no" + "\n"
}
configArray.push({
configString:configString,
@@ -33,7 +34,7 @@ export class SshConfig {
for(let key in configArray){
configFile = configFile + configArray[key].configString + "\n";
};
plugins.smartfile.memory.toFsSync(configFile,dirPathArg);
plugins.smartfile.memory.toFsSync(configFile,plugins.path.join(dirPathArg,"config"));
return done.promise;
}
read(dirPathArg){

View File

@@ -5,27 +5,31 @@ import {SshInstance} from "./smartssh.classes.sshinstance";
import {SshKey} from "./smartssh.classes.sshkey";
import {SshConfig} from "./smartssh.classes.sshconfig";
export class SshDir { // sshDir class -> NOT EXPORTED, ONLY FOR INTERNAL USE
path:string; // the path of the ssh directory
private sshKeyArray:SshKey[];
private sshConfig:SshConfig;
private _path:string; // the path of the ssh directory
private _sshKeyArray:SshKey[];
private _sshConfig:SshConfig;
constructor(sshKeyArray:SshKey[],sshConfig:SshConfig,sshDirPathArg?:string){
this.sshKeyArray = sshKeyArray;
this._sshKeyArray = sshKeyArray;
this._sshConfig = sshConfig;
if(sshDirPathArg){
this.path = sshDirPathArg;
this._path = sshDirPathArg;
} else {
this.path = plugins.path.join(plugins.smartpath.get.home(),".ssh/");
this._path = plugins.path.join(plugins.smartpath.get.home(),".ssh/");
};
}
writeToDir(){ // syncs sshInstance to directory
this.sshKeyArray.forEach((sshKeyArg) => {
sshKeyArg.store(this.path);
this._sshKeyArray.forEach((sshKeyArg) => {
sshKeyArg.store(this._path);
});
this.sshConfig.store(this.path);
this._sshConfig.store(this._path);
};
readFromDir(){ // syncs sshInstance from directory
}
updateDirPath(dirPathArg:string){
this._path = dirPathArg;
};
getKeys(){
return helpers.sshKeyArrayFromDir(this.path);
return helpers.sshKeyArrayFromDir(this._path);
}
}