-
Notifications
You must be signed in to change notification settings - Fork 1
/
strongswan.jps
318 lines (295 loc) · 9.56 KB
/
strongswan.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
_info : 'https://docs.cloudscripting.com/1.6.2/'
version: 1.6.2
build: 20190910
type: update
name: 'strongswan'
id: 'strongswan'
homepage: https://github.com/layershift/jps-strongswan
baseUrl: https://raw.githubusercontent.com/layershift/jps-strongswan/master
logo: /images/strongswan_square_large_white.png?_r=${fn.random}
categories:
- apps/others
description:
text: /texts/description.md
short: the OpenSource IPsec-based VPN Solution
targetNodes:
nodeGroup:
- cp
requiredFeatures: extip
settings:
main:
fields:
- type: string
name: right
caption: Peer public IP (right)
hideLabel: false
required: true
default: 127.0.0.1
- type: string
name: rightSubnet
caption: Peer sunbnet (rightsubnet)
hideLabel: false
required: true
default: 127.0.0.1/32
- type: string
name: psk
caption: PSK
required: true
hideLabel: false
- type: list
name: keyexchange
caption: keyexchange
values:
ikev1: ikev1
ikev2: ikev2
hideLabel: false
editable: false
required: true
default: ikev2
- type: displayfield
caption: Ciphers
- type: list
name: ike
caption: ike
values:
aes128-sha256-modp3072: aes128-sha256-modp3072
aes128-sha1-modp2048: aes128-sha1-modp2048 (before 5.4.0)
aes128-sha1-modp1536 : aes128-sha1-modp1536 (For Cisco endpoint)
hideLabel: false
editable: yes
required: true
default: aes128-sha256-modp3072
- type: list
name: esp
caption: esp
values:
aes128-sha256: aes128-sha256
aes128-sha1: aes128-sha1 (For Cisco endpoint)
hideLabel: false
editable: yes
required: true
default: aes128-sha256
- type: text
name: hosts
caption: Custom /etc/hosts
default: "#127.0.0.1 localhost"
menu:
- caption: Check hosts file
loadingText: Checking..
action: checkHostsFile
- caption: Configure
loadingText: Updating..
settings: main
confirmText: Are you sure you wish to configure Strongswan?
action: install
successText: /text/success_configured.md
- caption: Rebuild Config
loadingText: Reconfiguring..
confirmText: Are you sure you wish to reconfigure Strongswan?
action: install
buttons:
- caption: SA Status
loadingText: Checking..
action: checkStrongswanStatus
- menu:
- caption: Strongswan Status
loadingText: Checking..
confirmText: Are you sure you wish to check Strongswan service status?
action: statusStrongswan
- caption: Start Strongswan
loadingText: Starting..
confirmText: Are you sure you wish to start Strongswan?
action: restartStrongswan
- caption: Restart Strongswan
loadingText: Restarting..
confirmText: Are you sure you wish to restart Strongswan?
action: restartStrongswan
- caption: Stop Strongswan
loadingText: Stopping..
confirmText: Are you sure you wish to stop Strongswan?
action: stopStrongswan
onBeforeInit: |
return {
"result": 0,
"settings": {
"fields": [{
"type": "string",
"name": "right",
"caption": "Peer public IP (right)",
"hideLabel": false,
"required": true,
"default": "127.0.0.1"
}, {
"type": "string",
"name": "rightSubnet",
"caption": "Peer sunbnet (rightsubnet)",
"hideLabel": false,
"required": true,
"default": "127.0.0.1/32"
}, {
"type": "string",
"name": "psk",
"caption": "PSK",
"required": true,
"hideLabel": false,
"default": com.hivext.api.utils.Random.getPswd(10)
}, {
"type": "list",
"name": "keyexchange",
"caption": "keyexchange",
"required": true,
"hideLabel": false,
"values": {
"ikev1": "ikev1",
"ikev2": "ikev2"
},
"default": "ikev2"
}, {
"type": "displayfield",
"caption": "Ciphers"
}, {
"type": "list",
"name": "ike",
"caption": "ike",
"required": true,
"hideLabel": false,
"editable": true,
"values": {
"aes128-sha256-modp3072": "aes128-sha256-modp3072",
"aes128-sha1-modp2048": "aes128-sha1-modp2048 (before 5.4.0)",
"aes128-sha1-modp1536": "aes128-sha1-modp1536 (For Cisco endpoint)"
},
"default": "aes128-sha256-modp3072"
}, {
"type": "list",
"name": "esp",
"caption": "esp",
"required": true,
"hideLabel": false,
"editable": true,
"values": {
"aes128-sha256": "aes128-sha256",
"aes128-sha1": "aes128-sha1 (For Cisco endpoint)"
},
"default": "aes128-sha256"
}, {
"type": "text",
"name": "hosts",
"caption": "Custom /etc/hosts",
"default": "#127.0.0.1 localhost"
}]
}
};
globals:
targetNodeId: ${nodes.cp.first.id}
targetNodeExtIp: ${nodes.cp.first.extIPs[0]}
targetNodeIntIp: ${nodes.cp.first.intIP}/32
onAfterRedeployContainer:
install:
name: Install Action
onInstall:
install:
name: Install Action
onUninstall:
cmd [${globals.targetNodeId}]:
- systemctl disable strongswan;
- systemctl stop strongswan;
- yum remove strongswan strongswan-libipsec
- sh /root/strongswan_configure_firewall-custom.sh uninstall
- sh /root/strongswan_configure.sh "uninstall"
- rm -f /root/strongswan_configure_firewall-custom.sh
- rm -f /root/strongswan_configure.sh;
- rm -f /etc/sudoers.d/strongswan;
- rm -f /etc/profile.d/strongswan.sh;
- rm -f /usr/local/bin/strongswan_monit.sh;
- rm -f /etc/cron.d/strongswan_monit;
sayYes: true
user: root
actions:
install:
- cmd [${globals.targetNodeId}]:
- which rpm 2>/dev/null >/dev/null; if [ $? -gt 0 ]; then echo -e "Issue:\nrpm not found"; exit 0; fi;
- which systemctl 2>/dev/null >/dev/null; if [ $? -gt 0 ]; then echo -e "Issue:\nsystemctl not found"; exit 0; fi;
- yum install epel-release && yum install strongswan strongswan-libipsec; if [ $? -gt 0 ]; then echo -e "Issue:\nCan't install strongswan"; exit 0; fi;
- curl -fsSL '${baseUrl}/scripts/strongswan_configure_firewall-custom.sh' -o /root/strongswan_configure_firewall-custom.sh;
- sh /root/strongswan_configure_firewall-custom.sh;
- curl -fsSL '${baseUrl}/scripts/strongswan_configure.sh' -o /root/strongswan_configure.sh;
- sh /root/strongswan_configure.sh "install" "${baseUrl}" "${settings.keyexchange}" "${settings.right}" "${settings.rightSubnet}" '${settings.psk}' "${settings.ike}" "${settings.esp}" "${settings.hosts}";
- curl -fsSL '${baseUrl}/scripts/sudo_strongswan' -o /etc/sudoers.d/strongswan;
- curl -fsSL '${baseUrl}/scripts/profile_strongswan' -o /etc/profile.d/strongswan.sh;
- curl -fsSL '${baseUrl}/scripts/strongswan_monit.sh' -o /usr/local/bin/strongswan_monit.sh;
- curl -fsSL '${baseUrl}/scripts/strongswan_monit.cron' -o /etc/cron.d/strongswan_monit;
- chmod +x /usr/local/bin/strongswan_monit.sh;
- chown -R jelastic /etc/strongswan
- systemctl enable strongswan;
- systemctl restart strongswan;
sayYes: true
user: root
- if (response.out.indexOf("Issue") !== -1):
message: ${response.out}
script: |
return {result: 2309, message: message.replace(/\n/g, ' \n')}
restartStrongswan:
- cmd [${globals.targetNodeId}]:
- systemctl enable strongswan -q 2>&1 1>/dev/null;
- systemctl restart strongswan 2>&1 1>/dev/null;
- sleep 5;
- systemctl status strongswan 2>&1 1>/dev/null;
- if [ $? -gt 0 ]; then systemctl status strongswan --lines=0; fi;
- echo "";
user: root
- if (response.out.length > 0):
return:
type: error
message: '${response.out}'
- return:
type: success
message: 'Strongswan restart complete'
stopStrongswan:
- cmd [${globals.targetNodeId}]:
- systemctl disable strongswan -q 2>&1 1>/dev/null;
- systemctl stop strongswan 2>&1 1>/dev/null;
- sleep 5;
- systemctl status strongswan 2>&1 1>/dev/null;
- if [ $? -eq 0 ]; then systemctl status strongswan --lines=0; fi;
- echo "";
user: root
- if (response.out.length > 0):
return:
type: error
message: '${response.out}'
- return:
type: success
message: 'Strongswan stop complete'
statusStrongswan:
- cmd [${globals.targetNodeId}]:
- systemctl status strongswan --lines=0;
- echo "";
user: root
- return:
type: info
message: '${response.out}'
checkStrongswanStatus:
- cmd [${globals.targetNodeId}]:
- strongswan statusall 2>&1 1>/dev/null
- if [ $? -eq 0 ]; then strongswan statusall | grep "Security Associations" -A 10; else echo "Strongswan offline!"; fi;
- echo ""
user: root
- message: ${response.out}
script: |
return {result: 2308, message: message.replace(/\n/g, ' \n')}
checkHostsFile:
- cmd [${globals.targetNodeId}]:
- grep -q "#strongswan mark" /etc/hosts
- if [ $? -eq 0 ]; then from=$(grep "#strongswan mark" /etc/hosts -m1 -n | awk -F ":" '{print $1}'); else from=1; fi;
- sed -ne $from,999p /etc/hosts;
user: root
- message: ${response.out}
script: |
return {result: 2308, message: message.replace(/\n/g, ' \n')}
responses:
2308:
type: success
2309:
type: error
success: /texts/success.md