summaryrefslogtreecommitdiff
path: root/src/op_mode/generate_ipsec_debug_archive.sh
blob: 53d0a6eaaa7d09db275d6a39f9959ff64bd833ab (plain)
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
#!/usr/bin/env bash

# Collecting IPSec Debug Information

DATE=`date +%d-%m-%Y`

a_CMD=(
       "sudo ipsec status"
       "sudo swanctl -L"
       "sudo swanctl -l"
       "sudo swanctl -P"
       "sudo ip x sa show"
       "sudo ip x policy show"
       "sudo ip tunnel show"
       "sudo ip address"
       "sudo ip rule show"
       "sudo ip route"
       "sudo ip route show table 220"
      )


echo "DEBUG: ${DATE} on host \"$(hostname)\"" > /tmp/ipsec-status-${DATE}.txt
date >> /tmp/ipsec-status-${DATE}.txt

# Execute all DEBUG commands and save it to file
for cmd in "${a_CMD[@]}"; do
    echo -e "\n### ${cmd} ###" >> /tmp/ipsec-status-${DATE}.txt
    ${cmd} >> /tmp/ipsec-status-${DATE}.txt 2>/dev/null
done

# Collect charon logs, build .tgz archive
sudo journalctl /usr/lib/ipsec/charon > /tmp/journalctl-charon-${DATE}.txt && \
sudo tar -zcvf /tmp/ipsec-debug-${DATE}.tgz /tmp/journalctl-charon-${DATE}.txt /tmp/ipsec-status-${DATE}.txt >& /dev/null
sudo rm -f /tmp/journalctl-charon-${DATE}.txt /tmp/ipsec-status-${DATE}.txt

echo "Debug file is generated and located in /tmp/ipsec-debug-${DATE}.tgz"