Skip to content

Commit 6d49dd0

Browse files
committed
save
1 parent 3544bf2 commit 6d49dd0

File tree

10 files changed

+23
-16
lines changed

10 files changed

+23
-16
lines changed

backends/01ad/config.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
name: 'AD'
33
description: 'Backend for AD'
4-
active: 1
4+
active: 0
55
actions:
66
CHANGEPWD:
77
exec: "changepasswd"
@@ -17,4 +17,3 @@ actions:
1717
exec: 'dummy.sh'
1818
PING:
1919
exec: 'ping.sh'
20-

backends/02openldap/config.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
name: 'openldap'
32
description: 'Backend for openldap'
43
active: 0
@@ -14,4 +13,3 @@ actions:
1413
exec: 'dummy.sh'
1514
PING:
1615
exec: 'ping.sh'
17-

backends/backend1/bin/exemple.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
#!/bin/sh
22
echo "Hello Word"
3-
4-
echo dir : `dirname $0`
53
exit 0

backends/backend1/config.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
21
name: 'config1'
32
description: 'Config1 backend for tests'
4-
active: 0
3+
active: 1
54
actions:
65
CHANGEPWD:
76
exec: "exemple.sh"
87
onError: 'continue'
98
RESETPWD:
10-
exec: "exemple.sh
9+
exec: 'exemple.sh'
1110
onError: 'continue'
1211
ADDIDENT:
1312
exec: 'exemple.sh'
@@ -21,4 +20,3 @@ actions:
2120
PING:
2221
exec: 'exemple.sh'
2322
onError: 'continue'
24-

backends/dummy/bin/dummy.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
#!/bin/sh
22
echo "Hello Word"
3+
exit 0

backends/dummy/config.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
name: 'dummy'
22
description: 'Dummy backend for tests'
3-
active: 0
3+
active: 1
44
actions:
55
CHANGEPWD:
66
exec: "dummy.sh"
77
onError: 'stop'
8+
RESETPWD:
9+
exec: "dummy.sh"
10+
onError: 'stop'
811
ADDIDENT:
912
exec: 'dummy.sh'
1013
onError: 'stop'
@@ -14,5 +17,6 @@ actions:
1417
DELIDENT:
1518
exec: 'dummy.sh'
1619
onError: 'stop'
17-
18-
20+
PING:
21+
exec: 'dummy.sh'
22+
onError : 'continue'

root@172.16.252.136

69.9 MB
Binary file not shown.

sesame-daemon

69.9 MB
Binary file not shown.

src/app.service.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ export class AppService {
2828
let gStatus=0;
2929
this.logger.log('start daemon')
3030
for await(const backend of this.backendsConfig) {
31+
if (job.name === "LISTBACKEND"){
32+
this.logger.log('execute LISTBACKEND')
33+
return {jobId:job.id,status:0,data:this.backendsConfig}
34+
}
3135
if (backend.active === 1){
32-
this.logger.log('Execute backend ' + backend.name)
36+
this.logger.log('Execute backend command '+ job.name +' '+ backend.name)
3337
var task=backend.actions[job.name]
3438
this.logger.debug(backend.path +'/bin/'+ task.exec)
3539
const out=process.spawnSync(backend.path +'/bin/'+ task.exec,[],{
@@ -42,11 +46,13 @@ export class AppService {
4246
result.output=out.stdout.toString()
4347
result.error=out.stderr.toString()
4448
results.push(result);
45-
if (task.onError == 'stop'){
49+
if (task.onError === 'stop' && output.status != 0 ){
50+
this.logger.log('stop on Error ')
4651
break
4752
}
4853
}
4954
}
55+
this.logger.debug('results : ')
5056
this.logger.debug(results)
5157
return {jobId:job.id,status:gStatus,data:results}
5258
},{connection:this.configService.get('redis')});
@@ -59,6 +65,7 @@ export class AppService {
5965
.filter((path, isDirectory) => path.endsWith(".yml"))
6066
const files = crawler.crawl(this.configService.get('backendsPath')).sync().sort();
6167
for await(const element of files) {
68+
this.logger.log('Load ' + element)
6269
const file = fs.readFileSync(element, 'utf8')
6370
const config=YAML.parse(file)
6471
try{
@@ -70,7 +77,7 @@ export class AppService {
7077
}
7178
config.path=path.dirname(element)
7279
this.backendsConfig.push(config)
73-
this.logger.log('Load ' + config.name)
80+
this.logger.log('Loaded ' + config.name)
7481
}
7582
this.logger.debug(this.backendsConfig)
7683

src/dto/Backend-config.dto.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { IsInt, IsString, IsEnum, IsNumber,IsNotEmpty } from 'class-validator';
22
export enum ActionType {
3+
LISTBACKEND = 'LISTBACKEND',
34
CHANGEPWD = 'CHANGEPWD',
5+
RESETPWD = "RESETPWD",
46
ADDIDENT = 'ADDIDENT',
57
UPDATEIDENT ='UPDATEIDENT',
68
DELIDENT = 'DELIDENT'

0 commit comments

Comments
 (0)