1
0
mirror of synced 2024-11-24 05:46:09 +03:00
setup-ipsec-vpn/.github/workflows/test_set_1.yml

625 lines
20 KiB
YAML
Raw Normal View History

2022-02-07 01:41:39 +03:00
#
2024-02-04 00:31:58 +03:00
# Copyright (C) 2020-2024 Lin Song <linsongui@gmail.com>
2022-02-07 01:41:39 +03:00
#
# This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
# Unported License: http://creativecommons.org/licenses/by-sa/3.0/
#
# Attribution required: please include my name in any derivative and let me
# know how you have improved it!
name: test_set_1
on: workflow_call
jobs:
test_set_1:
runs-on: ubuntu-20.04
if: github.repository_owner == 'hwdsl2'
strategy:
matrix:
2023-01-05 06:25:16 +03:00
os_version: ["centos:9s", "centos:8s", "centos:7", "rockylinux:8", "almalinux:9", "almalinux:8", "amazonlinux:2", "oraclelinux:9", "oraclelinux:8", "oraclelinux:7"]
2022-02-07 01:41:39 +03:00
fail-fast: false
env:
OS_VERSION: ${{ matrix.os_version }}
steps:
2024-02-04 08:48:34 +03:00
- uses: actions/checkout@v4
2022-02-11 08:10:39 +03:00
with:
persist-credentials: false
2022-02-07 01:41:39 +03:00
- name: Build
run: |
mkdir -p "$GITHUB_WORKSPACE/testing/${OS_VERSION//:}"
cd "$GITHUB_WORKSPACE/testing/${OS_VERSION//:}"
2022-02-11 08:10:39 +03:00
mkdir -p scripts/extras
ls -ld "$GITHUB_WORKSPACE/vpnsetup.sh"
cp -f "$GITHUB_WORKSPACE"/*.sh scripts/
cp -f "$GITHUB_WORKSPACE"/extras/*.sh scripts/extras/
2022-02-07 01:41:39 +03:00
cat > run.sh <<'EOF'
#!/bin/bash
set -eEx
log1=/var/log/secure
log2=/var/log/messages
trap 'catch $? $LINENO' ERR
catch() {
echo "Error $1 occurred on line $2."
cat -n -- "$0" | tail -n+"$(($2 - 3))" | head -n7
exit 1
}
restart_ipsec() {
2023-11-19 05:12:40 +03:00
if [ -f /etc/oracle-release ]; then
2022-03-27 06:33:45 +03:00
sleep 3
2022-03-21 07:21:23 +03:00
fi
2022-02-07 01:41:39 +03:00
if ! command -v amazon-linux-extras; then
systemctl restart ipsec
fi
2023-01-05 06:25:16 +03:00
if grep -qs -i stream /etc/redhat-release \
&& grep -qs 'release 9' /etc/redhat-release; then
sleep 5
return 0
fi
2022-02-07 01:41:39 +03:00
echo "Waiting for IPsec to restart."
count=0
while ! grep -q "pluto\[$(cat /var/run/pluto/pluto.pid)\]: listening for IKE messages" "$log1"; do
[ "$count" -ge "30" ] && { echo "IPsec failed to start."; exit 1; }
count=$((count+1))
printf '%s' '.'
sleep 0.5
done
echo
}
restart_fail2ban() {
rm -f /var/log/fail2ban.log
systemctl restart fail2ban
echo "Waiting for Fail2ban to restart."
count=0
while ! grep -qs -E "Jail '(sshd?|ssh-iptables)' started" /var/log/fail2ban.log; do
[ "$count" -ge "30" ] && { echo "Fail2ban failed to start."; exit 1; }
count=$((count+1))
printf '%s' '.'
sleep 0.5
done
echo
}
2022-02-11 08:10:39 +03:00
cd /opt/src
2022-02-07 01:41:39 +03:00
yum -y -q update
yum -y -q install wget rsyslog
2022-07-31 07:17:53 +03:00
if grep -qs 'release 9' /etc/redhat-release; then
2022-08-10 03:35:32 +03:00
if grep -qs -i rocky /etc/redhat-release \
|| grep -qs -i alma /etc/redhat-release; then
2022-07-31 07:17:53 +03:00
yum -y -q install diffutils
fi
fi
2023-01-05 06:25:16 +03:00
if ! grep -qs -i stream /etc/redhat-release \
|| ! grep -qs 'release 9' /etc/redhat-release; then
systemctl start rsyslog
fi
2022-02-07 01:41:39 +03:00
2022-02-11 08:10:39 +03:00
cp -f /opt/src/scripts/vpnsetup.sh .
2022-03-03 07:58:54 +03:00
cp -f /opt/src/scripts/extras/vpnuninstall.sh ./vpnunst.sh
2022-02-07 01:41:39 +03:00
sed -i -e '/curl /a sed -i "/swan_ver_latest=/s/^/#/" "$tmpdir/vpn.sh"' \
2022-03-04 07:07:25 +03:00
-e '/curl /a sed -i \x27/status=0/a sed -i "/swan_ver_latest=/s/^/#/" /opt/src/ikev2.sh\x27 "$tmpdir/vpn.sh"' \
2022-07-31 07:17:53 +03:00
vpnsetup.sh
2022-03-03 07:58:54 +03:00
2022-07-31 07:17:53 +03:00
sh vpnsetup.sh
2022-03-03 07:58:54 +03:00
2022-07-31 07:17:53 +03:00
systemctl restart xl2tpd
restart_ipsec
if ! grep -qs 'release 9' /etc/oracle-release; then
2023-01-05 06:25:16 +03:00
if ! grep -qs -i stream /etc/redhat-release \
|| ! grep -qs 'release 9' /etc/redhat-release; then
restart_fail2ban
cat /var/log/fail2ban.log
fi
2022-07-31 07:17:53 +03:00
fi
2022-03-03 07:58:54 +03:00
2022-07-31 07:17:53 +03:00
netstat -anpu | grep pluto
netstat -anpu | grep xl2tpd
if grep -qs 'release 9' /etc/redhat-release; then
nft list ruleset
nft list ruleset | grep -q '192\.168\.42\.0/24'
nft list ruleset | grep -q '192\.168\.43\.0/24'
else
2022-03-03 07:58:54 +03:00
iptables -nvL
iptables -nvL | grep -q 'ppp+'
iptables -nvL | grep -q '192\.168\.43\.0/24'
iptables -nvL -t nat
iptables -nvL -t nat | grep -q '192\.168\.42\.0/24'
iptables -nvL -t nat | grep -q '192\.168\.43\.0/24'
2022-07-31 07:17:53 +03:00
fi
2023-01-05 06:25:16 +03:00
if ! grep -qs -i stream /etc/redhat-release \
|| ! grep -qs 'release 9' /etc/redhat-release; then
grep pluto "$log1"
grep xl2tpd "$log2"
fi
2022-07-31 07:17:53 +03:00
ipsec status
ipsec status | grep -q l2tp-psk
ipsec status | grep -q xauth-psk
ipsec status | grep -q ikev2-cp
ls -ld /etc/ipsec.d/vpnclient.mobileconfig
ls -ld /etc/ipsec.d/vpnclient.sswan
ls -ld /etc/ipsec.d/vpnclient.p12
ls -l /usr/bin/ikev2.sh
ls -l /usr/bin/addvpnuser.sh
ls -l /usr/bin/delvpnuser.sh
ls -l /opt/src/ikev2.sh
ls -l /opt/src/addvpnuser.sh
ls -l /opt/src/delvpnuser.sh
2022-02-07 01:41:39 +03:00
bash vpnunst.sh <<ANSWERS
y
ANSWERS
2022-07-31 07:17:53 +03:00
rm -f /etc/ipsec.d/vpnclient*
2022-08-10 03:35:32 +03:00
if grep -qs -i stream /etc/redhat-release \
2022-07-31 07:17:53 +03:00
|| grep -qs -E 'release (8|9)' /etc/oracle-release; then
mkdir /etc/xl2tpd
fi
if grep -qs 'release 9' /etc/redhat-release; then
2022-08-10 03:35:32 +03:00
if grep -qs -i rocky /etc/redhat-release \
|| grep -qs -i alma /etc/redhat-release; then
2022-03-03 07:58:54 +03:00
mkdir /etc/xl2tpd
fi
2022-07-31 07:17:53 +03:00
fi
2022-02-07 01:41:39 +03:00
if [ "$1" != "amazon" ]; then
2022-02-11 08:10:39 +03:00
cp -f /opt/src/scripts/vpnsetup_centos.sh ./vpnsetup.sh
2022-02-07 01:41:39 +03:00
else
2022-02-11 08:10:39 +03:00
cp -f /opt/src/scripts/vpnsetup_amzn.sh ./vpnsetup.sh
2022-02-07 01:41:39 +03:00
fi
2022-03-04 07:07:25 +03:00
sed -i -e '/swan_ver_latest=/s/^/#/' \
-e '/status=0/a sed -i "/swan_ver_latest=/s/^/#/" /opt/src/ikev2.sh' \
vpnsetup.sh
2022-02-07 01:41:39 +03:00
2022-03-08 06:38:01 +03:00
bash vpnsetup.sh
2022-02-07 01:41:39 +03:00
VPN_IPSEC_PSK='your_ipsec_pre_shared_key' \
VPN_USER='your_vpn_username' \
VPN_PASSWORD='your_vpn_password' \
VPN_DNS_SRV1='1.1.1.1' \
VPN_DNS_SRV2='1.0.0.1' \
bash vpnsetup.sh
systemctl restart xl2tpd
restart_ipsec
netstat -anpu | grep pluto
netstat -anpu | grep xl2tpd
2022-07-31 07:17:53 +03:00
if grep -qs 'release 9' /etc/redhat-release; then
nft list ruleset
nft list ruleset | grep -q '192\.168\.42\.0/24'
nft list ruleset | grep -q '192\.168\.43\.0/24'
else
iptables -nvL
iptables -nvL | grep -q 'ppp+'
iptables -nvL | grep -q '192\.168\.43\.0/24'
iptables -nvL -t nat
iptables -nvL -t nat | grep -q '192\.168\.42\.0/24'
iptables -nvL -t nat | grep -q '192\.168\.43\.0/24'
fi
2022-02-07 01:41:39 +03:00
ipsec status
ipsec status | grep -q l2tp-psk
ipsec status | grep -q xauth-psk
2022-03-04 07:07:25 +03:00
ipsec status | grep -q ikev2-cp
2022-02-07 01:41:39 +03:00
grep -q "your_ipsec_pre_shared_key" /etc/ipsec.secrets
grep -q "your_vpn_username" /etc/ppp/chap-secrets
grep -q "your_vpn_password" /etc/ppp/chap-secrets
grep -q "your_vpn_username" /etc/ipsec.d/passwd
grep -q 'modecfgdns="1.1.1.1 1.0.0.1"' /etc/ipsec.conf
grep -q 'ms-dns 1.1.1.1' /etc/ppp/options.xl2tpd
grep -q 'ms-dns 1.0.0.1' /etc/ppp/options.xl2tpd
2022-03-04 07:07:25 +03:00
ls -ld /etc/ipsec.d/vpnclient.mobileconfig
ls -ld /etc/ipsec.d/vpnclient.sswan
ls -ld /etc/ipsec.d/vpnclient.p12
2022-02-07 01:41:39 +03:00
ls -l /usr/bin/ikev2.sh
2022-04-12 06:48:44 +03:00
ls -l /usr/bin/addvpnuser.sh
ls -l /usr/bin/delvpnuser.sh
2022-02-07 01:41:39 +03:00
ls -l /opt/src/ikev2.sh
2022-04-12 06:48:44 +03:00
ls -l /opt/src/addvpnuser.sh
ls -l /opt/src/delvpnuser.sh
2022-02-07 01:41:39 +03:00
2022-03-04 07:07:25 +03:00
rm -f /usr/bin/ikev2.sh /opt/src/ikev2.sh
rm -f /etc/ipsec.d/vpnclient*
2022-02-11 08:10:39 +03:00
cp -f /opt/src/scripts/extras/ikev2setup.sh ./ikev2.sh # hwdsl2
2022-02-07 01:41:39 +03:00
sed -i '/swan_ver_latest=/s/^/#/' ikev2.sh
2022-03-04 07:07:25 +03:00
bash ikev2.sh --removeikev2 <<ANSWERS
y
ANSWERS
restart_ipsec
2022-02-07 01:41:39 +03:00
bash ikev2.sh <<ANSWERS
2022-02-12 21:27:26 +03:00
2022-02-07 01:41:39 +03:00
ANSWERS
grep -q 'modecfgdns="8.8.8.8 8.8.4.4"' /etc/ipsec.d/ikev2.conf
ls -ld /etc/ipsec.d/vpnclient.mobileconfig
ls -ld /etc/ipsec.d/vpnclient.sswan
ls -ld /etc/ipsec.d/vpnclient.p12
2022-02-15 08:55:13 +03:00
pk12util -W "" -l /etc/ipsec.d/vpnclient.p12
2022-09-11 18:04:46 +03:00
pk12util -W "" -l /etc/ipsec.d/vpnclient.p12 | grep AES-256 && exit 1
2022-02-07 01:41:39 +03:00
restart_ipsec
2023-01-05 06:25:16 +03:00
if ! grep -qs -i stream /etc/redhat-release \
|| ! grep -qs 'release 9' /etc/redhat-release; then
grep pluto "$log1" | tail -n 20
fi
2022-02-07 01:41:39 +03:00
ipsec status | grep -q ikev2-cp
bash ikev2.sh <<ANSWERS
1
invalidclient:
vpnclient
vpnclient2
ANSWERS
ls -ld /etc/ipsec.d/vpnclient2.mobileconfig
ls -ld /etc/ipsec.d/vpnclient2.sswan
ls -ld /etc/ipsec.d/vpnclient2.p12
2022-02-15 08:55:13 +03:00
pk12util -W "" -l /etc/ipsec.d/vpnclient2.p12
2022-09-11 18:04:46 +03:00
pk12util -W "" -l /etc/ipsec.d/vpnclient2.p12 | grep AES-256 && exit 1
2022-02-07 01:41:39 +03:00
rm -f /etc/ipsec.d/vpnclient2*
bash ikev2.sh <<ANSWERS
2
nonexistclient
vpnclient2
ANSWERS
ls -ld /etc/ipsec.d/vpnclient2.mobileconfig
ls -ld /etc/ipsec.d/vpnclient2.sswan
ls -ld /etc/ipsec.d/vpnclient2.p12
2022-02-15 08:55:13 +03:00
pk12util -W "" -l /etc/ipsec.d/vpnclient2.p12
2022-09-11 18:04:46 +03:00
pk12util -W "" -l /etc/ipsec.d/vpnclient2.p12 | grep AES-256 && exit 1
2022-02-07 01:41:39 +03:00
bash ikev2.sh <<ANSWERS
3
ANSWERS
2022-04-07 07:26:29 +03:00
bash ikev2.sh <<ANSWERS | grep -i "2 clients"
3
ANSWERS
2022-02-07 01:41:39 +03:00
bash ikev2.sh <<ANSWERS
4
nonexistclient
vpnclient2
y
ANSWERS
bash ikev2.sh <<ANSWERS 2>&1 | grep -i "abort"
4
vpnclient2
ANSWERS
2022-04-07 07:26:29 +03:00
bash ikev2.sh <<ANSWERS
5
vpnclient2
y
ANSWERS
bash ikev2.sh <<ANSWERS | grep -i "1 client"
3
ANSWERS
2022-02-07 01:41:39 +03:00
bash ikev2.sh <<ANSWERS 2>&1 | grep -i "abort"
2
vpnclient2
ANSWERS
bash ikev2.sh <<ANSWERS
100
2022-04-07 06:52:43 +03:00
7
2022-02-07 01:41:39 +03:00
ANSWERS
bash ikev2.sh <<ANSWERS 2>&1 | grep -i "abort"
2022-04-07 06:52:43 +03:00
6
2022-02-07 01:41:39 +03:00
ANSWERS
bash ikev2.sh <<ANSWERS
2022-04-07 06:52:43 +03:00
6
2022-02-07 01:41:39 +03:00
y
ANSWERS
restart_ipsec
ls -ld /etc/ipsec.d/ikev2.conf && exit 1
ipsec status | grep -q l2tp-psk
ipsec status | grep -q xauth-psk
ipsec status | grep -q ikev2-cp && exit 1
certutil -L -d sql:/etc/ipsec.d
rm -f /etc/ipsec.d/vpnclient*
VPN_DNS_SRV1=invaliddns \
bash ikev2.sh --auto 2>&1 | grep -i "invalid"
sed -i '/^include /d' /etc/ipsec.conf
VPN_CLIENT_NAME=vpnclient1 \
VPN_DNS_NAME=vpn.example.com \
VPN_DNS_SRV1=1.1.1.1 \
VPN_DNS_SRV2=1.0.0.1 \
bash ikev2.sh --auto
grep -q 'leftid=@vpn.example.com' /etc/ipsec.d/ikev2.conf
grep -q 'modecfgdns="1.1.1.1 1.0.0.1"' /etc/ipsec.d/ikev2.conf
ls -ld /etc/ipsec.d/vpnclient1.mobileconfig
ls -ld /etc/ipsec.d/vpnclient1.sswan
ls -ld /etc/ipsec.d/vpnclient1.p12
grep -q 'vpn.example.com' /etc/ipsec.d/vpnclient1.mobileconfig
grep -q 'vpn.example.com' /etc/ipsec.d/vpnclient1.sswan
restart_ipsec
ipsec status | grep -q ikev2-cp
bash ikev2.sh --addclient invalidclient: 2>&1 | grep -i "invalid"
bash ikev2.sh --addclient vpnclient1 2>&1 | grep -i "already exists"
bash ikev2.sh --addclient vpnclient2
ls -ld /etc/ipsec.d/vpnclient2.mobileconfig
ls -ld /etc/ipsec.d/vpnclient2.sswan
ls -ld /etc/ipsec.d/vpnclient2.p12
bash ikev2.sh --exportclient nonexistclient 2>&1 | grep -i "does not exist"
rm -f /etc/ipsec.d/vpnclient2*
bash ikev2.sh --exportclient vpnclient2
ls -ld /etc/ipsec.d/vpnclient2.mobileconfig
ls -ld /etc/ipsec.d/vpnclient2.sswan
ls -ld /etc/ipsec.d/vpnclient2.p12
bash ikev2.sh --addclient vpnclient2 --exportclient vpnclient2 2>&1 | grep -i "invalid"
bash ikev2.sh --listclients | grep "vpnclient1 \+valid"
bash ikev2.sh --listclients | grep "vpnclient2 \+valid"
2022-04-07 07:26:29 +03:00
bash ikev2.sh --listclients | grep "2 clients"
2022-02-07 01:41:39 +03:00
bash ikev2.sh --revokeclient nonexistclient 2>&1 | grep -i "does not exist"
bash ikev2.sh --revokeclient vpnclient2 <<ANSWERS
y
ANSWERS
bash ikev2.sh --listclients | grep "vpnclient2 \+revoked"
2022-09-10 17:53:40 +03:00
ls -ld /etc/ipsec.d/vpnclient2.mobileconfig && exit 1
ls -ld /etc/ipsec.d/vpnclient2.sswan && exit 1
ls -ld /etc/ipsec.d/vpnclient2.p12 && exit 1
2022-02-07 01:41:39 +03:00
bash ikev2.sh --revokeclient vpnclient2 2>&1 | grep -i "already been revoked"
bash ikev2.sh --exportclient vpnclient2 2>&1 | grep -i "revoked"
2022-04-07 07:26:29 +03:00
bash ikev2.sh --deleteclient nonexistclient 2>&1 | grep -i "does not exist"
2022-09-10 17:53:40 +03:00
bash ikev2.sh --deleteclient vpnclient1 <<ANSWERS
2022-04-07 07:26:29 +03:00
y
ANSWERS
2022-09-10 17:53:40 +03:00
2022-04-07 07:26:29 +03:00
bash ikev2.sh --listclients | grep "1 client"
2022-09-10 17:53:40 +03:00
ls -ld /etc/ipsec.d/vpnclient1.mobileconfig && exit 1
ls -ld /etc/ipsec.d/vpnclient1.sswan && exit 1
ls -ld /etc/ipsec.d/vpnclient1.p12 && exit 1
2022-04-07 07:26:29 +03:00
2022-02-07 01:41:39 +03:00
bash ikev2.sh -h 2>&1 | grep -i "usage:"
bash ikev2.sh --invalidoption 2>&1 | grep -i "usage:"
bash ikev2.sh --removeikev2 --exportclient vpnclient1 2>&1 | grep -i "invalid"
bash ikev2.sh --removeikev2 <<ANSWERS
y
ANSWERS
restart_ipsec
2022-02-15 08:55:13 +03:00
rm -f /etc/ipsec.d/vpnclient*
2022-02-07 01:41:39 +03:00
bash ikev2.sh <<ANSWERS
y
invalidfqdn
vpn.example.com
y
invaliddns
1.1.1.1
invaliddns
1.0.0.1
y
2022-02-12 21:27:26 +03:00
2022-02-07 01:41:39 +03:00
ANSWERS
grep -q 'leftid=@vpn.example.com' /etc/ipsec.d/ikev2.conf
grep -q 'modecfgdns="1.1.1.1 1.0.0.1"' /etc/ipsec.d/ikev2.conf
restart_ipsec
ipsec status | grep -q ikev2-cp
2022-02-15 08:55:13 +03:00
config_file="/etc/ipsec.d/.vpnconfig"
p12_pw=$(grep -s '^IKEV2_CONFIG_PASSWORD=.\+' "$config_file" | tail -n 1 | cut -f2- -d= | sed -e "s/^'//" -e "s/'$//")
pk12util -W "$p12_pw" -l /etc/ipsec.d/vpnclient.p12
2022-09-11 18:04:46 +03:00
pk12util -W "$p12_pw" -l /etc/ipsec.d/vpnclient.p12 | grep AES-256 && exit 1
2022-02-15 08:55:13 +03:00
bash ikev2.sh --addclient vpnclient2
pk12util -W "$p12_pw" -l /etc/ipsec.d/vpnclient2.p12
2022-09-11 18:04:46 +03:00
pk12util -W "$p12_pw" -l /etc/ipsec.d/vpnclient2.p12 | grep AES-256 && exit 1
2022-02-15 08:55:13 +03:00
bash ikev2.sh --exportclient vpnclient2
pk12util -W "$p12_pw" -l /etc/ipsec.d/vpnclient2.p12
2022-09-11 18:04:46 +03:00
pk12util -W "$p12_pw" -l /etc/ipsec.d/vpnclient2.p12 | grep AES-256 && exit 1
2022-02-15 08:55:13 +03:00
2022-02-07 01:41:39 +03:00
bash ikev2.sh --removeikev2 <<ANSWERS
y
ANSWERS
2022-02-15 08:55:13 +03:00
grep -qs '^IKEV2_CONFIG_PASSWORD=.\+' "$config_file" && exit 1
2022-02-07 01:41:39 +03:00
restart_ipsec
bash ikev2.sh <<ANSWERS
invalidip
1.2.3.4
invalidclient:
vpnclient1
1000
12
y
1.1.1.1
2022-02-12 21:27:26 +03:00
2022-02-07 01:41:39 +03:00
ANSWERS
grep -q 'leftid=1.2.3.4' /etc/ipsec.d/ikev2.conf
grep -q 'modecfgdns=1.1.1.1' /etc/ipsec.d/ikev2.conf
restart_ipsec
ipsec status | grep -q ikev2-cp
bash ikev2.sh --removeikev2 <<ANSWERS
y
ANSWERS
restart_ipsec
VPN_DNS_SRV1=1.1.1.1 \
bash ikev2.sh --auto
grep -q 'modecfgdns=1.1.1.1' /etc/ipsec.d/ikev2.conf
restart_ipsec
ipsec status | grep -q ikev2-cp
bash ikev2.sh --removeikev2 <<ANSWERS
y
ANSWERS
restart_ipsec
bash ikev2.sh --auto
2022-02-15 08:55:13 +03:00
grep -qs '^IKEV2_CONFIG_PASSWORD=.\+' "$config_file" && exit 1
2022-02-07 01:41:39 +03:00
grep -q 'modecfgdns="8.8.8.8 8.8.4.4"' /etc/ipsec.d/ikev2.conf
restart_ipsec
ipsec status | grep -q ikev2-cp
2022-02-11 08:10:39 +03:00
cp -f /opt/src/scripts/extras/vpnupgrade.sh ./vpnup.sh
2022-02-07 01:41:39 +03:00
sed -i '/curl /a sed -i "/swan_ver_latest=/s/^/#/" "$tmpdir/vpnup.sh"' vpnup.sh
2024-04-18 04:43:41 +03:00
for ver in 4.12 ""; do
2022-02-07 01:41:39 +03:00
sed -i "s/^SWAN_VER=.*/SWAN_VER=$ver/" vpnup.sh
bash vpnup.sh <<ANSWERS
2022-02-12 21:27:26 +03:00
2022-02-07 01:41:39 +03:00
ANSWERS
restart_ipsec
2024-04-18 04:43:41 +03:00
[ -z "$ver" ] && ver=4.15
2022-02-07 01:41:39 +03:00
ipsec --version | grep "$ver"
ipsec status | grep -q l2tp-psk
ipsec status | grep -q xauth-psk
ipsec status | grep -q ikev2-cp
done
if [ "$1" != "amazon" ]; then
2022-02-11 08:10:39 +03:00
cp -f /opt/src/scripts/extras/vpnupgrade_centos.sh ./vpnup.sh
2022-02-07 01:41:39 +03:00
else
2022-02-11 08:10:39 +03:00
cp -f /opt/src/scripts/extras/vpnupgrade_amzn.sh ./vpnup.sh
2022-02-07 01:41:39 +03:00
fi
sed -i '/swan_ver_latest=/s/^/#/' vpnup.sh
2024-04-18 04:43:41 +03:00
for ver in 4.14 ""; do
2022-02-07 01:41:39 +03:00
sed -i "s/^SWAN_VER=.*/SWAN_VER=$ver/" vpnup.sh
bash vpnup.sh <<ANSWERS
2022-02-12 21:27:26 +03:00
2022-02-07 01:41:39 +03:00
ANSWERS
restart_ipsec
2024-04-18 04:43:41 +03:00
[ -z "$ver" ] && ver=4.15
2022-02-07 01:41:39 +03:00
ipsec --version | grep "$ver"
ipsec status | grep -q l2tp-psk
ipsec status | grep -q xauth-psk
ipsec status | grep -q ikev2-cp
done
bash ikev2.sh --removeikev2 <<ANSWERS
y
ANSWERS
restart_ipsec
ls -ld /etc/ipsec.d/ikev2.conf && exit 1
ipsec status | grep -q l2tp-psk
ipsec status | grep -q xauth-psk
ipsec status | grep -q ikev2-cp && exit 1
certutil -L -d sql:/etc/ipsec.d
exit 0
EOF
2022-07-31 08:05:10 +03:00
if [ "$OS_VERSION" = "centos:9s" ]; then
echo "FROM quay.io/centos/centos:stream9" > Dockerfile
elif [ "$OS_VERSION" = "centos:8s" ]; then
2022-02-07 01:41:39 +03:00
echo "FROM quay.io/centos/centos:stream8" > Dockerfile
else
echo "FROM $OS_VERSION" > Dockerfile
fi
cat >> Dockerfile <<'EOF'
ENV container docker
WORKDIR /opt/src
RUN if command -v amazon-linux-extras; then amazon-linux-extras install -y kernel-ng; fi
2022-07-31 08:05:10 +03:00
EOF
if [ "$OS_VERSION" = "centos:9s" ]; then
echo "RUN yum -y -q install systemd" >> Dockerfile
fi
cat >> Dockerfile <<'EOF'
2022-02-07 01:41:39 +03:00
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ "$i" = \
systemd-tmpfiles-setup.service ] || rm -f "$i"; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*; \
rm -f /etc/systemd/system/*.wants/*; \
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*; \
rm -f /lib/systemd/system/anaconda.target.wants/*;
2022-02-11 08:10:39 +03:00
COPY scripts/ /opt/src/scripts/
2022-02-07 01:41:39 +03:00
COPY ./run.sh /opt/src/run.sh
RUN chmod 755 /opt/src/run.sh
VOLUME [ "/sys/fs/cgroup" ]
CMD ["/sbin/init"]
EOF
cat Dockerfile
cat run.sh
docker build -t "${OS_VERSION//:}-test" .
- name: Test
run: |
docker run -d --name "${OS_VERSION//:}-test-1" -v /sys/fs/cgroup:/sys/fs/cgroup:ro \
--privileged "${OS_VERSION//:}-test"
sleep 5
docker exec "${OS_VERSION//:}-test-1" /opt/src/run.sh "${OS_VERSION::6}"
- name: Clear
if: always()
run: |
rm -rf "$GITHUB_WORKSPACE/testing/${OS_VERSION//:}"
docker rm -f "${OS_VERSION//:}-test-1" || true
docker rmi "${OS_VERSION//:}-test" || true