mirror of
https://github.com/pivpn/pivpn.git
synced 2025-04-26 17:20:12 +00:00
Merge pull request #1054 from shelleycat485/test
Tidy dual VPN protocol install
This commit is contained in:
commit
1dc10e7d54
7 changed files with 76 additions and 56 deletions
|
@ -16,7 +16,7 @@ echo -e "::::\t\t\e[4mLatest commit\e[0m\t\t ::::"
|
|||
git --git-dir /etc/.pivpn/.git log -n 1
|
||||
printf "=============================================\n"
|
||||
echo -e "::::\t \e[4mInstallation settings\e[0m \t ::::"
|
||||
sed "s/$pivpnHOST/REDACTED/" < /etc/pivpn/setupVars.conf
|
||||
sed "s/$pivpnHOST/REDACTED/" < ${setupVars}
|
||||
printf "=============================================\n"
|
||||
echo -e ":::: \e[4mServer configuration shown below\e[0m ::::"
|
||||
cat /etc/openvpn/server.conf
|
||||
|
@ -28,7 +28,7 @@ echo -e ":::: \t\e[4mRecursive list of files in\e[0m\t ::::\n::: \e[4m/etc/openv
|
|||
ls -LR /etc/openvpn/easy-rsa/pki/ -Ireqs -Icerts_by_serial
|
||||
printf "=============================================\n"
|
||||
echo -e "::::\t\t\e[4mSelf check\e[0m\t\t ::::"
|
||||
/opt/pivpn/self_check.sh
|
||||
/opt/pivpn/self_check.sh ${VPN}
|
||||
printf "=============================================\n"
|
||||
echo -e ":::: Having trouble connecting? Take a look at the FAQ:"
|
||||
echo -e ":::: \e[1mhttps://github.com/pivpn/pivpn/wiki/FAQ\e[0m"
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
# Must be root to use this tool
|
||||
if [ $EUID -ne 0 ];then
|
||||
if dpkg-query -s sudo &> /dev/null; then
|
||||
export SUDO="sudo"
|
||||
export SUDO="sudo"
|
||||
else
|
||||
echo "::: Please install sudo or run this as root."
|
||||
exit 1
|
||||
fi
|
||||
echo "::: Please install sudo or run this as root."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
scriptDir="/opt/pivpn"
|
||||
|
@ -17,7 +17,7 @@ showHelp(){
|
|||
echo "::: To pass off to the pivpn command for each protocol"
|
||||
echo ":::"
|
||||
echo "::: Usage: pivpn wg <command> [option]"
|
||||
echo "::: Usage: pivpn opv <command> [option]"
|
||||
echo "::: Usage: pivpn ovpn <command> [option]"
|
||||
echo ":::"
|
||||
echo "::: -h, help Show this help dialog"
|
||||
exit 0
|
||||
|
@ -30,7 +30,7 @@ fi
|
|||
# Handle redirecting to specific functions based on arguments
|
||||
case "$1" in
|
||||
wg ) "${scriptDir}/wireguard/pivpn.sh" "${@:2}";;
|
||||
opv ) "${scriptDir}/openvpn/pivpn.sh" "${@:2}";;
|
||||
ovpn ) "${scriptDir}/openvpn/pivpn.sh" "${@:2}";;
|
||||
"-h" | "help" ) showHelp;;
|
||||
* ) showHelp;;
|
||||
esac
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
setupVars="/etc/pivpn/setupVars.conf"
|
||||
# dual protocol, VPN type supplied as $1
|
||||
VPN=$1
|
||||
setupVars="/etc/pivpn/${VPN}/setupVars.conf"
|
||||
ERR=0
|
||||
|
||||
if [ ! -f "${setupVars}" ]; then
|
||||
|
|
|
@ -4,6 +4,24 @@
|
|||
### FIXME: global: config storage, refactor all scripts to adhere to the storage
|
||||
### FIXME: use variables where appropriate, reduce magic numbers by 99.9%, at least.
|
||||
|
||||
# what is already installed?
|
||||
setupVars="/etc/pivpn/openvpn/setupVars.conf"
|
||||
foundins=''
|
||||
if [ -f "${setupVars}" ]; then
|
||||
foundins="openvpn"
|
||||
fi
|
||||
|
||||
setupVars="/etc/pivpn/wireguard/setupVars.conf"
|
||||
if [ -f "${setupVars}" ]; then
|
||||
foundins="${foundins} wireguard"
|
||||
fi
|
||||
|
||||
if [ -z ${foundins} ]; then
|
||||
foundins="nothing found"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# Find the rows and columns. Will default to 80x24 if it can not be detected.
|
||||
screen_size=$(stty size 2>/dev/null || echo 24 80)
|
||||
rows=$(echo "$screen_size" | awk '{print $1}')
|
||||
|
@ -16,7 +34,7 @@ c=$(( columns / 2 ))
|
|||
r=$(( r < 20 ? 20 : r ))
|
||||
c=$(( c < 70 ? 70 : c ))
|
||||
|
||||
chooseVPNCmd=(whiptail --backtitle "Setup PiVPN" --title "Installation mode" --separate-output --radiolist "WireGuard is a new kind of VPN that provides near-instantaneous connection speed, high performance, and modern cryptography.\\n\\nIt's the recommended choice especially if you use mobile devices where WireGuard is easier on battery than OpenVPN.\\n\\nOpenVPN is still available if you need the traditional, flexible, trusted VPN protocol or if you need features like TCP and custom search domain.\\n\\nChoose a VPN to uninstall (press space to select):" "${r}" "${c}" 2)
|
||||
chooseVPNCmd=(whiptail --backtitle "Setup PiVPN" --title "Installation mode" --separate-output --radiolist "WireGuard is a new kind of VPN that provides near-instantaneous connection speed, high performance, and modern cryptography.\\n\\nIt's the recommended choice especially if you use mobile devices where WireGuard is easier on battery than OpenVPN.\\n\\nOpenVPN is still available if you need the traditional, flexible, trusted VPN protocol or if you need features like TCP and custom search domain.\\n\\nChoose a VPN (${foundins}) to uninstall (press space to select):" "${r}" "${c}" 2)
|
||||
VPNChooseOptions=(WireGuard "" on
|
||||
OpenVPN "" off)
|
||||
|
||||
|
@ -108,21 +126,21 @@ removeAll(){
|
|||
vpnStillExists='no'
|
||||
|
||||
if [ -r "${setupConfigDir}/${othervpn}/${setupVarsFile}" ]; then
|
||||
vpnStillExists='yes'
|
||||
$SUDO rm -f /usr/local/bin/pivpn
|
||||
$SUDO ln -s -T /opt/pivpn/${othervpn}/pivpn.sh /usr/local/bin/pivpn
|
||||
echo ":::"
|
||||
echo "::: Two VPN protocols exist, you should remove ${othervpn} too"
|
||||
echo ":::"
|
||||
vpnStillExists='yes'
|
||||
$SUDO rm -f /usr/local/bin/pivpn
|
||||
$SUDO ln -s -T /opt/pivpn/${othervpn}/pivpn.sh /usr/local/bin/pivpn
|
||||
echo ":::"
|
||||
echo "::: Two VPN protocols exist, you should remove ${othervpn} too"
|
||||
echo ":::"
|
||||
|
||||
else
|
||||
rm -f /etc/bash_completion.d/pivpn
|
||||
rm -f /etc/bash_completion.d/pivpn
|
||||
fi
|
||||
|
||||
# Disable IPv4 forwarding
|
||||
if [ ${vpnStillExists} == 'no' ]; then
|
||||
sed -i '/net.ipv4.ip_forward=1/c\#net.ipv4.ip_forward=1' /etc/sysctl.conf
|
||||
sysctl -p
|
||||
sed -i '/net.ipv4.ip_forward=1/c\#net.ipv4.ip_forward=1' /etc/sysctl.conf
|
||||
sysctl -p
|
||||
fi
|
||||
|
||||
# Purge dependencies
|
||||
|
@ -204,18 +222,18 @@ removeAll(){
|
|||
fi
|
||||
|
||||
if [ ${vpnStillExists} == 'no' ]; then
|
||||
echo ":::"
|
||||
echo "::: Removing pivpn system files..."
|
||||
rm -rf /etc/.pivpn
|
||||
rm -rf /etc/pivpn
|
||||
rm -f /var/log/*pivpn*
|
||||
rm -rf /opt/pivpn
|
||||
rm -f /usr/local/bin/pivpn
|
||||
echo ":::"
|
||||
echo "::: Removing pivpn system files..."
|
||||
rm -rf /etc/.pivpn
|
||||
rm -rf /etc/pivpn
|
||||
rm -f /var/log/*pivpn*
|
||||
rm -rf /opt/pivpn
|
||||
rm -f /usr/local/bin/pivpn
|
||||
else
|
||||
echo ":::"
|
||||
echo "::: Other protocol still present, so not"
|
||||
echo "::: removing pivpn system files"
|
||||
rm -f "${setupConfigDir}/${VPN}/${setupVarsFile}"
|
||||
echo ":::"
|
||||
echo "::: Other protocol still present, so not"
|
||||
echo "::: removing pivpn system files"
|
||||
rm -f "${setupConfigDir}/${VPN}/${setupVarsFile}"
|
||||
fi
|
||||
|
||||
echo ":::"
|
||||
|
|
|
@ -16,7 +16,7 @@ echo -e "::::\t\t\e[4mLatest commit\e[0m\t\t ::::"
|
|||
git --git-dir /etc/.pivpn/.git log -n 1
|
||||
printf "=============================================\n"
|
||||
echo -e "::::\t \e[4mInstallation settings\e[0m \t ::::"
|
||||
sed "s/$pivpnHOST/REDACTED/" < /etc/pivpn/setupVars.conf
|
||||
sed "s/$pivpnHOST/REDACTED/" < ${setupVars}
|
||||
printf "=============================================\n"
|
||||
echo -e ":::: \e[4mServer configuration shown below\e[0m ::::"
|
||||
cd /etc/wireguard/keys
|
||||
|
@ -46,7 +46,7 @@ echo -e ":::: \t\e[4mRecursive list of files in\e[0m\t ::::\n::::\e\t[4m/etc/wir
|
|||
ls -LR /etc/wireguard
|
||||
printf "=============================================\n"
|
||||
echo -e "::::\t\t\e[4mSelf check\e[0m\t\t ::::"
|
||||
/opt/pivpn/self_check.sh
|
||||
/opt/pivpn/self_check.sh ${VPN}
|
||||
printf "=============================================\n"
|
||||
echo -e ":::: Having trouble connecting? Take a look at the FAQ:"
|
||||
echo -e ":::: \e[1mhttps://github.com/pivpn/pivpn/wiki/FAQ\e[0m"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue