-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsshtun.jps
90 lines (75 loc) · 2.2 KB
/
sshtun.jps
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
type: update
name: 'SSHtun'
id: 'sshtun'
homepage: https://github.com/layershift/jps-sshtun
baseUrl: https://raw.githubusercontent.com/layershift/jps-sshtun/master
logo: /images/sshtun.png?_r=${fn.random}
categories:
- apps/others
description:
text: /texts/description.md
short: Enable SSH tunneling for database node
targetNodes:
nodeGroup:
- sqldb
- nosqldb
- proxy
menu:
- caption: Enable SSH tunneling
loadingText: Enabling SSH tunneling...
action: enableTun
- caption: Disable SSH tunneling
loadingText: Disabling SSH tunneling...
confirmText: Are you sure you wish to disable SSH tunneling?
action: disableTun
buttons:
- caption: Status
loadingText: Checking..
action: checkTun
onAfterRedeployContainer:
enableTun
onInstall:
enableTun
onUninstall:
cmd [${targetNodes.nodeGroup}]:
- sed -i -e "s/^AllowTcpForwarding.*/AllowTcpForwarding no/" /etc/ssh/sshd_config
- service sshd restart
sayYes: true
user: root
actions:
enableTun:
- cmd [${targetNodes.nodeGroup}]:
- sed -i -e "s/^AllowTcpForwarding.*/AllowTcpForwarding yes/" /etc/ssh/sshd_config
- service sshd restart
sayYes: true
user: root
- if (response.out.indexOf("Issue") !== -1):
message: ${response.out}
script: |
return {'result': 2308, 'message': message.replace(/\n/g, ' \n')}
disableTun:
- cmd [${targetNodes.nodeGroup}]:
- sed -i -e "s/^AllowTcpForwarding.*/AllowTcpForwarding no/" /etc/ssh/sshd_config
- service sshd restart
user: root
- message: ${response.out}
script: |
return {'result': 2308, 'message': message.replace(/\n/g, ' \n')}
checkTun:
- cmd [${targetNodes.nodeGroup}]:
- cat /etc/ssh/sshd_config | grep ^AllowTcpForwarding | grep -q yes && echo "SSH tunneling enabled" || echo "SSH tunneling disabled"
user: root
- message: ${response.out}
script: |
return {'result': 2307, 'message': message.replace(/\n/g, ' \n')}
responses:
2307:
type: info
message: Custom Success message!
2308:
type: success
message: Custom Success message!
2309:
type: error
message: Custom Success message!
success: /texts/success.md