2022-07-27 12:53:36 +00:00
|
|
|
#!/bin/bash
|
2019-10-14 10:27:28 +00:00
|
|
|
# This scripts runs as root
|
2022-10-07 23:11:10 +00:00
|
|
|
### Contants
|
2020-04-28 22:44:56 +00:00
|
|
|
setupVars="/etc/pivpn/openvpn/setupVars.conf"
|
2019-10-14 10:27:28 +00:00
|
|
|
|
2022-10-07 23:11:10 +00:00
|
|
|
# shellcheck disable=SC1090
|
|
|
|
source "${setupVars}"
|
|
|
|
|
|
|
|
### Functions
|
2022-07-27 12:53:36 +00:00
|
|
|
err() {
|
|
|
|
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
|
|
|
|
}
|
|
|
|
|
2022-10-07 23:11:10 +00:00
|
|
|
### Script
|
2022-07-27 12:53:36 +00:00
|
|
|
if [[ ! -f "${setupVars}" ]]; then
|
|
|
|
err "::: Missing setup vars file!"
|
|
|
|
exit 1
|
2019-10-14 10:27:28 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo -e "::::\t\t\e[4mPiVPN debug\e[0m\t\t ::::"
|
|
|
|
printf "=============================================\n"
|
|
|
|
echo -e "::::\t\t\e[4mLatest commit\e[0m\t\t ::::"
|
2021-05-12 16:17:35 +00:00
|
|
|
echo -n "Branch: "
|
2022-07-27 12:53:36 +00:00
|
|
|
|
2021-05-12 16:17:35 +00:00
|
|
|
git --git-dir /usr/local/src/pivpn/.git rev-parse --abbrev-ref HEAD
|
2022-07-27 12:53:36 +00:00
|
|
|
git \
|
2022-08-09 08:09:25 +00:00
|
|
|
--git-dir /usr/local/src/pivpn/.git log -n 1 \
|
2022-07-27 12:53:36 +00:00
|
|
|
--format='Commit: %H%nAuthor: %an%nDate: %ad%nSummary: %s'
|
|
|
|
|
2019-10-14 10:27:28 +00:00
|
|
|
printf "=============================================\n"
|
|
|
|
echo -e "::::\t \e[4mInstallation settings\e[0m \t ::::"
|
2022-07-27 12:53:36 +00:00
|
|
|
|
2021-11-03 12:02:25 +00:00
|
|
|
# shellcheck disable=SC2154
|
2022-07-27 12:53:36 +00:00
|
|
|
sed "s/${pivpnHOST}/REDACTED/" < "${setupVars}"
|
|
|
|
|
2019-10-14 10:27:28 +00:00
|
|
|
printf "=============================================\n"
|
|
|
|
echo -e ":::: \e[4mServer configuration shown below\e[0m ::::"
|
2022-07-27 12:53:36 +00:00
|
|
|
|
2019-10-14 10:27:28 +00:00
|
|
|
cat /etc/openvpn/server.conf
|
2022-07-27 12:53:36 +00:00
|
|
|
|
2019-10-14 10:27:28 +00:00
|
|
|
printf "=============================================\n"
|
|
|
|
echo -e ":::: \e[4mClient template file shown below\e[0m ::::"
|
2022-07-27 12:53:36 +00:00
|
|
|
|
|
|
|
sed "s/${pivpnHOST}/REDACTED/" < /etc/openvpn/easy-rsa/pki/Default.txt
|
|
|
|
|
2019-10-14 10:27:28 +00:00
|
|
|
printf "=============================================\n"
|
2022-07-27 12:53:36 +00:00
|
|
|
echo -e ":::: \t\e[4mRecursive list of files in\e[0m\t ::::\n"
|
|
|
|
echo -e "::: \e[4m/etc/openvpn/easy-rsa/pki shows below\e[0m :::"
|
|
|
|
|
2019-10-14 10:27:28 +00:00
|
|
|
ls -LR /etc/openvpn/easy-rsa/pki/ -Ireqs -Icerts_by_serial
|
2022-07-27 12:53:36 +00:00
|
|
|
|
2019-10-14 10:27:28 +00:00
|
|
|
printf "=============================================\n"
|
|
|
|
echo -e "::::\t\t\e[4mSelf check\e[0m\t\t ::::"
|
2022-07-27 12:53:36 +00:00
|
|
|
|
2021-11-03 12:02:25 +00:00
|
|
|
/opt/pivpn/self_check.sh "${VPN}"
|
2022-07-27 12:53:36 +00:00
|
|
|
|
2019-10-14 10:27:28 +00:00
|
|
|
printf "=============================================\n"
|
2020-02-01 20:04:32 +00:00
|
|
|
echo -e ":::: Having trouble connecting? Take a look at the FAQ:"
|
2021-05-11 13:22:52 +00:00
|
|
|
echo -e ":::: \e[1mhttps://docs.pivpn.io/faq\e[0m"
|
2020-02-01 20:04:32 +00:00
|
|
|
printf "=============================================\n"
|
2019-10-14 10:27:28 +00:00
|
|
|
|
2022-07-27 12:53:36 +00:00
|
|
|
if [[ "${PLAT}" != 'Alpine' ]]; then
|
|
|
|
echo -e ":::: \e[4mSnippet of the server log\e[0m ::::"
|
|
|
|
OVPNLOG="$(tail -n 20 /var/log/openvpn.log)"
|
|
|
|
|
|
|
|
# Regular expession taken from https://superuser.com/a/202835,
|
|
|
|
# it will match invalid IPs like 123.456.789.012 but it's fine
|
|
|
|
# since the log only contains valid ones.
|
2022-08-05 21:11:22 +00:00
|
|
|
declare -a IPS_TO_HIDE=("$(echo "${OVPNLOG}" \
|
|
|
|
| grepcidr -v 10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 \
|
|
|
|
| grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' \
|
|
|
|
| uniq)")
|
2019-10-14 10:27:28 +00:00
|
|
|
|
2022-07-27 12:53:36 +00:00
|
|
|
for IP in "${IPS_TO_HIDE[@]}"; do
|
|
|
|
OVPNLOG="${OVPNLOG//"$IP"/REDACTED}"
|
|
|
|
done
|
2022-07-26 13:20:35 +00:00
|
|
|
|
2022-07-27 12:53:36 +00:00
|
|
|
echo "${OVPNLOG}"
|
|
|
|
printf "=============================================\n"
|
2022-07-26 13:20:35 +00:00
|
|
|
fi
|
2022-07-27 12:53:36 +00:00
|
|
|
|
2019-10-14 10:27:28 +00:00
|
|
|
echo -e "::::\t\t\e[4mDebug complete\e[0m\t\t ::::"
|