@@ -10,9 +10,60 @@ write_files:
1010 content: |
1111 net. ipv4 . ip_forward = 1
1212
13+ - path : / etc/ systemd/ system/ check- gcve- connectivity. service
14+ permissions: " 0755"
15+ content: |
16+ [Unit ]
17+ Description = GCVE Connectivity Test
18+ # This ensures it doesn't run until the network is ready, remove if not needed
19+ Wants = network- online. target
20+ After = network- online. target
21+
22+ [Service ]
23+ Type = oneshot
24+ # Replace this with your actual command or script
25+ ExecStart = / usr/ local / bin/ check- gcve- connectivity. sh
26+
27+ - path : / etc/ systemd/ system/ check- gcve- connectivity. timer
28+ permissions: " 0644"
29+ content: |
30+ [Unit ]
31+ Description = Run check- gcve- connectivity every two minutes
32+
33+ [Timer ]
34+ # Run every two minutes
35+ OnCalendar = * : 0 / 2
36+ Persistent = true
37+
38+ [Install ]
39+ WantedBy = timers. target
40+
41+ - path : / usr/ local / bin/ check- gcve- connectivity. sh
42+ permissions: " 0644"
43+ content: |
44+ # !/bin/bash
45+
46+ function log () {
47+ echo " $(date '+%Y-%m-%d %H:%M:%S') ${ 1 } "
48+ }
49+
50+ function test_connectivity() {
51+ curl - s " ${ 2 } " -- connect- timeout 2 - k && RET= $? || RET= $?
52+ if [[ " $RET" - eq 0 ]]; then
53+ log " Successfully reached ${ 1 } / ${ 2 } "
54+ else
55+ log " Failed to reach ${ 1 } / ${ 2 } "
56+ fi
57+ }
58+
59+ test_connectivity VSphere " https://192.168.31.2/sdk"
60+ test_connectivity NSX " https://192.168.31.18/sdk"
61+
1362runcmd:
1463- apt- get update
1564- apt install wireguard - q - y
1665- sysctl - p / etc/ sysctl. d / 10 - wireguard. conf
1766- systemctl enable wg- quick@wg0
1867- systemctl start wg- quick@wg0
68+ - systemctl enable check- gcve- connectivity. timer
69+ - systemctl start check- gcve- connectivity. timer
0 commit comments