Merge branch 'test'

Merge test branch into master,
Check LatestChanges.md for details
This commit is contained in:
4s3ti 2021-01-26 17:24:10 +01:00
commit 7fdbe44df5
12 changed files with 295 additions and 24 deletions

178
.travis.yml Normal file
View file

@ -0,0 +1,178 @@
language: shell
addons:
hosts:
- pivpn.test
apt:
packages:
- shellcheck
services:
- docker
stages:
- lint
- test
branches:
only:
- test
- master
jobs:
allow_failures:
- stage: lint
include:
- stage: lint
name: "Shellcheck lint"
dist: linux
script:
- shellcheck autoinstall/install.sh
- shellcheck scripts/backup.sh
- shellcheck scripts/pivpn
- shellcheck scripts/self_check.sh
- shellcheck scripts/uninstall.sh
- shellcheck scripts/update.sh
- shellcheck scripts/openvpn/clientstat.sh
- shellcheck scripts/openvpn/listOVPN.sh
- shellcheck scripts/openvpn/makeOVPN.sh
- shellcheck scripts/openvpn/pivpnDebug.sh
- shellcheck scripts/openvpn/pivpn.sh
- shellcheck scripts/openvpn/removeOVPN.sh
- shellcheck scripts/wireguard/clientSTAT.sh
- shellcheck scripts/wireguard/disableCONF.sh
- shellcheck scripts/wireguard/enableCONF.sh
- shellcheck scripts/wireguard/listCONF.sh
- shellcheck scripts/wireguard/makeCONF.sh
- shellcheck scripts/wireguard/pivpnDEBUG.sh
- shellcheck scripts/wireguard/pivpn.sh
- shellcheck scripts/wireguard/qrcodeCONF.sh
- shellcheck scripts/wireguard/removeCONF.sh
- stage: test
name: "OpenVPN Xenial & Commands"
dist: xenial
before_script:
- cat /etc/os-release
- uname -a
- sudo chmod +x ciscripts/startup.sh
- ./ciscripts/startup.sh -o
script:
- sudo ./auto_install/install.sh --unattended ciscripts/ci_openvpn.conf
- systemctl status openvpn
- pivpn add -n foo nopass -d 180
- pivpn add -p "$RANDOM$RANDOM" -n bar -d 180
- pivpn add -o -n foo
- pivpn -bk
- ls ~pi/pivpnbackup/ | grep backup
- pivpn -r foo -y
- pivpn -l
- pivpn -c
after_fail:
- sudo journalctl -xe
- stage: test
name: "Wireguard Xenial & Commands"
dist: xenial
before_script:
- cat /etc/os-release
- uname -a
- sudo chmod +x ciscripts/startup.sh
- ./ciscripts/startup.sh -w
script:
- sudo ./auto_install/install.sh --unattended ciscripts/ci_wireguard.conf
- pivpn add -n foo
- pivpn -qr foo
- pivpn -bk
- pivpn -l
- pivpn -c
- pivpn -r foo -y
after_script:
- systemctl status wg-quick@wg0
after_fail:
- sudo journalctl -xe
- stage: test
name: "OpenVPN Bionic & Commands"
dist: bionic
before_script:
- cat /etc/os-release
- uname -a
- sudo chmod +x ciscripts/startup.sh
- ./ciscripts/startup.sh -o
script:
- sudo ./auto_install/install.sh --unattended ciscripts/ci_openvpn.conf
- systemctl status openvpn
- pivpn add -n foo nopass -d 180
- pivpn add -p "$RANDOM$RANDOM" -n bar -d 180
- pivpn add -o -n foo
- pivpn -bk
- ls ~pi/pivpnbackup/ | grep backup
- pivpn -r foo -y
- pivpn -l
- pivpn -c
after_fail:
- sudo journalctl -xe
- stage: test
name: "Wireguard Bionic & Commands"
dist: bionic
before_script:
- cat /etc/os-release
- uname -a
- sudo apt update -y
- sudo chmod +x ciscripts/startup.sh
- ./ciscripts/startup.sh -w
script:
- sudo ./auto_install/install.sh --unattended ciscripts/ci_wireguard.conf
- systemctl status wg-quick@wg0
- pivpn add -n foo
- pivpn -qr foo
- pivpn -bk
- pivpn -l
- pivpn -c
- pivpn -r foo -y
after_fail:
- sudo journalctl -xe
- stage: test
name: "OpenVPN Focal & Commands"
dist: focal
before_script:
- cat /etc/os-release
- uname -a
- sudo chmod +x ciscripts/startup.sh
- ./ciscripts/startup.sh -o
script:
- sudo ./auto_install/install.sh --unattended ciscripts/ci_openvpn.conf
- systemctl status openvpn
- pivpn add -n foo nopass -d 180
- pivpn add -p "$RANDOM$RANDOM" -n bar -d 180
- pivpn add -o -n foo
- pivpn -bk
- ls ~pi/pivpnbackup/ | grep backup
- pivpn -r foo -y
- pivpn -l
- pivpn -c
after_fail:
- sudo journalctl -xe
- stage: test
name: "Wireguard Focal & Commands"
dist: focal
before_script:
- cat /etc/os-release
- uname -a
- sudo chmod +x ciscripts/startup.sh
- ./ciscripts/startup.sh -w
script:
- sudo ./auto_install/install.sh --unattended ciscripts/ci_wireguard.conf
- systemctl status wg-quick@wg0
- pivpn add -n foo
- pivpn -qr foo
- pivpn -bk
- pivpn -l
- pivpn -c
- pivpn -r foo -y
after_fail:
- sudo journalctl -xe

View file

@ -4,6 +4,14 @@ This file has the objective of describing the major changes for each merge from
Everytime Test branch is merged into master, a new entry should be created with the date and changes being merged.
## Jan 26th 2021
Fixed:
- #1231 Return proper exit codes
Improvements
- First implementation of Automated testing with travisCI
## Jan 17th 2021
- Issues Fixed:

View file

@ -1,6 +1,8 @@
![WireGuard + OpenVPN logo](logos.jpg)
**[Is pivpn.io down?](https://status.pivpn.io)**
**[Is pivpn.io down?](https://status.pivpn.io)** |
**Test:** [![Build Status](https://travis-ci.com/pivpn/pivpn.svg?branch=test)](https://travis-ci.com/pivpn/pivpn) |
**Master:** [![Build Status](https://travis-ci.com/pivpn/pivpn.svg?branch=master)](https://travis-ci.com/pivpn/pivpn)
About
-----

View file

@ -143,7 +143,7 @@ main(){
:
elif [ "$UpdateCmd" = "Update" ]; then
$SUDO ${pivpnScriptDir}/update.sh "$@"
exit 0
exit "$?"
elif [ "$UpdateCmd" = "Repair" ]; then
# shellcheck disable=SC1090
source "$setupVars"

16
ciscripts/ci_openvpn.conf Normal file
View file

@ -0,0 +1,16 @@
IPv4dev=INTERFACE
IPv4addr=IPADDRESS
IPv4gw=GATEWAY
dhcpReserv=0
install_user=pi
VPN=openvpn
pivpnPROTO=udp
pivpnPORT=1194
pivpnDNS1=9.9.9.9
pivpnDNS2=149.112.112.112
pivpnHOST=pivpn.test
pivpnENCRYPT=256
pivpnSEARCHDOMAIN=pivpn.test
TWO_POINT_FOUR=2POINT4
USE_PREDEFINED_DH_PARAM=1
UNATTUPG=1

View file

@ -0,0 +1,11 @@
IPv4dev=INTERFACE
IPv4addr=IPADDRESS
IPv4gw=GATEWAY
dhcpReserv=0
install_user=pi
VPN=wireguard
pivpnPORT=51820
pivpnDNS1=9.9.9.9
pivpnDNS2=149.112.112.112
pivpnHOST=pivpn.test
UNATTUPG=1

47
ciscripts/startup.sh Normal file
View file

@ -0,0 +1,47 @@
#!/bin/sh
interface=$(ip -o link | awk '{print $2}' | cut -d':' -f1 | cut -d'@' -f1 | grep -v -w 'lo' | head -1)
ipaddress=$(ip addr show "$interface" | grep -o -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}/[0-9]{2}")
gateway=$(ip route show | awk '/default/ {print $3}')
hostname="pivpn.test"
common(){
sed -i "s/INTERFACE/$interface/g" "$vpnconfig"
sed -i "s|IPADDRESS|$ipaddress|g" "$vpnconfig"
sed -i "s/GATEWAY/$gateway/g" "$vpnconfig"
}
openvpn(){
vpnconfig="ciscripts/ci_openvpn.conf"
twofour=1
common
sed -i "s/2POINT4/$twofour/g" "$vpnconfig"
cat $vpnconfig
exit 0
}
wireguard(){
vpnconfig="ciscripts/ci_wireguard.conf"
common
cat $vpnconfig
exit 0
}
if [ $# -lt 1 ]; then
echo "specifiy a VPN protocol to prepare"
exit 1
else
chmod +x auto_install/install.sh
sudo hostnamectl set-hostname $hostname
cat /etc/os-release
while true; do
case "$1" in
-o | --openvpn ) openvpn
;;
-w | --wireguard ) wireguard
;;
* ) echo "unknown vpn protocol"; exit 1
;;
esac
done
fi

9
ciscripts/test.sh Normal file
View file

@ -0,0 +1,9 @@
#!/bin/bash
systemctl status openvpn
pivpn add -n foo
pivpn -qr foo
pivpn -bk
pivpn -l
pivpn -c
pivpn -r foo -y

View file

@ -93,7 +93,7 @@ if [[ ! $EUID -eq 0 ]];then
export SUDO="sudo"
else
echo "::: Please install sudo or run this as root."
exit 0
exit 1
fi
fi

View file

@ -16,18 +16,18 @@ vpn="openvpn"
function makeOVPNFunc {
shift
$SUDO ${scriptDir}/${vpn}/makeOVPN.sh "$@"
exit 0
exit "$?"
}
function listClientsFunc {
shift
$SUDO ${scriptDir}/${vpn}/clientStat.sh "$@"
exit 0
exit "$?"
}
function listOVPNFunc {
$SUDO ${scriptDir}/${vpn}/listOVPN.sh
exit 0
exit "$?"
}
function debugFunc {
@ -37,29 +37,29 @@ function debugFunc {
echo "::: Debug output completed above."
echo "::: Copy saved to /tmp/debug.log"
echo "::: "
exit 0
exit "$?"
}
function removeOVPNFunc {
shift
$SUDO ${scriptDir}/${vpn}/removeOVPN.sh "$@"
exit 0
exit "$?"
}
function uninstallFunc {
$SUDO ${scriptDir}/uninstall.sh "${vpn}"
exit 0
exit "$?"
}
function update {
shift
$SUDO ${scriptDir}/update.sh "$@"
exit 0
exit "$?"
}
function backup {
$SUDO ${scriptDir}/backup.sh "${vpn}"
exit 0
exit "$?"
}

View file

@ -14,12 +14,12 @@ scriptDir="/opt/pivpn"
uninstallServer(){
$SUDO ${scriptDir}/uninstall.sh
exit 0
exit "$?"
}
backup(){
$SUDO ${scriptDir}/backup.sh
exit 0
exit "$?"
}
showHelp(){

View file

@ -16,13 +16,13 @@ vpn="wireguard"
makeConf(){
shift
$SUDO ${scriptdir}/${vpn}/makeCONF.sh "$@"
exit 0
exit "$?"
}
listConnected(){
shift
$SUDO ${scriptdir}/${vpn}/clientSTAT.sh "$@"
exit 0
exit "$?"
}
debug(){
@ -32,52 +32,52 @@ debug(){
echo "::: Debug output completed above."
echo "::: Copy saved to /tmp/debug.log"
echo "::: "
exit 0
exit "$?"
}
listClients(){
$SUDO ${scriptdir}/${vpn}/listCONF.sh
exit 0
exit "$?"
}
showQrcode(){
shift
$SUDO ${scriptdir}/${vpn}/qrcodeCONF.sh "$@"
exit 0
exit "$?"
}
removeClient(){
shift
$SUDO ${scriptdir}/${vpn}/removeCONF.sh "$@"
exit 0
exit "$?"
}
disableClient(){
shift
$SUDO ${scriptdir}/${vpn}/disableCONF.sh "$@"
exit 0
exit "$?"
}
enableClient(){
shift
$SUDO ${scriptdir}/${vpn}/enableCONF.sh "$@"
exit 0
exit "$?"
}
uninstallServer(){
$SUDO ${scriptdir}/uninstall.sh "${vpn}"
exit 0
exit "$?"
}
updateScripts(){
shift
$SUDO ${scriptdir}/update.sh "$@"
exit 0
exit "$?"
}
backup(){
$SUDO ${scriptdir}/backup.sh "${vpn}"
exit 0
exit "$?"
}
showHelp(){