mirror of
https://github.com/pivpn/pivpn.git
synced 2024-12-20 03:40:17 +00:00
commit
e7def9f81c
1 changed files with 123 additions and 88 deletions
|
@ -24,7 +24,7 @@ PKG_CACHE="/var/lib/apt/lists/"
|
||||||
UPDATE_PKG_CACHE="${PKG_MANAGER} update"
|
UPDATE_PKG_CACHE="${PKG_MANAGER} update"
|
||||||
PKG_INSTALL="${PKG_MANAGER} --yes --no-install-recommends install"
|
PKG_INSTALL="${PKG_MANAGER} --yes --no-install-recommends install"
|
||||||
PKG_COUNT="${PKG_MANAGER} -s -o Debug::NoLocking=true upgrade | grep -c ^Inst || true"
|
PKG_COUNT="${PKG_MANAGER} -s -o Debug::NoLocking=true upgrade | grep -c ^Inst || true"
|
||||||
PIVPN_DEPS=( openvpn git dhcpcd5 tar wget grep iptables-persistent dnsutils expect whiptail )
|
PIVPN_DEPS=( openvpn git dhcpcd5 tar wget grep iptables-persistent dnsutils expect whiptail net-tools)
|
||||||
### ###
|
### ###
|
||||||
|
|
||||||
pivpnGitUrl="https://github.com/pivpn/pivpn.git"
|
pivpnGitUrl="https://github.com/pivpn/pivpn.git"
|
||||||
|
@ -61,14 +61,14 @@ dhcpcdFile=/etc/dhcpcd.conf
|
||||||
# Next see if we are on a tested and supported OS
|
# Next see if we are on a tested and supported OS
|
||||||
function noOS_Support() {
|
function noOS_Support() {
|
||||||
whiptail --msgbox --backtitle "INVALID OS DETECTED" --title "Invalid OS" "We have not been able to detect a supported OS.
|
whiptail --msgbox --backtitle "INVALID OS DETECTED" --title "Invalid OS" "We have not been able to detect a supported OS.
|
||||||
Currently this installer supports Raspbian jessie, Ubuntu 14.04 (trusty), and Ubuntu 16.04 (xenial).
|
Currently this installer supports Raspbian (or Devuan) jessie, Ubuntu 14.04 (trusty), and Ubuntu 16.04 (xenial).
|
||||||
If you think you received this message in error, you can post an issue on the GitHub at https://github.com/pivpn/pivpn/issues." ${r} ${c}
|
If you think you received this message in error, you can post an issue on the GitHub at https://github.com/pivpn/pivpn/issues." ${r} ${c}
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function maybeOS_Support() {
|
function maybeOS_Support() {
|
||||||
if (whiptail --backtitle "Not Supported OS" --title "Not Supported OS" --yesno "You are on an OS that we have not tested but MAY work.
|
if (whiptail --backtitle "Not Supported OS" --title "Not Supported OS" --yesno "You are on an OS that we have not tested but MAY work.
|
||||||
Currently this installer supports Raspbian jessie, Ubuntu 14.04 (trusty), and Ubuntu 16.04 (xenial).
|
Currently this installer supports Raspbian (or Devuan) jessie, Ubuntu 14.04 (trusty), and Ubuntu 16.04 (xenial).
|
||||||
Would you like to continue anyway?" ${r} ${c}) then
|
Would you like to continue anyway?" ${r} ${c}) then
|
||||||
echo "::: Did not detect perfectly supported OS but,"
|
echo "::: Did not detect perfectly supported OS but,"
|
||||||
echo "::: Continuing installation at user's own risk..."
|
echo "::: Continuing installation at user's own risk..."
|
||||||
|
@ -85,14 +85,28 @@ distro_check() {
|
||||||
PLAT=$(lsb_release -si)
|
PLAT=$(lsb_release -si)
|
||||||
OSCN=$(lsb_release -sc) # We want this to be trusty xenial or jessie
|
OSCN=$(lsb_release -sc) # We want this to be trusty xenial or jessie
|
||||||
|
|
||||||
if [[ $PLAT == "Ubuntu" || $PLAT == "Raspbian" || $PLAT == "Debian" ]]; then
|
case ${PLAT} in
|
||||||
if [[ $OSCN != "trusty" && $OSCN != "xenial" && $OSCN != "jessie" ]]; then
|
Ubuntu|Raspbian|Debian|Devuan)
|
||||||
|
case ${OSCN} in
|
||||||
|
trusty|xenial|jessie)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
maybeOS_Support
|
maybeOS_Support
|
||||||
fi
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
noOS_Support
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
# else get info from os-release
|
||||||
|
elif grep -q devuan /etc/os-release; then
|
||||||
|
if grep -q jessie /etc/os-release; then
|
||||||
|
PLAT="Raspvuan"
|
||||||
|
OSCN="jessie"
|
||||||
else
|
else
|
||||||
noOS_Support
|
noOS_Support
|
||||||
fi
|
fi
|
||||||
# else get info from os-release
|
|
||||||
elif grep -q debian /etc/os-release; then
|
elif grep -q debian /etc/os-release; then
|
||||||
if grep -q jessie /etc/os-release; then
|
if grep -q jessie /etc/os-release; then
|
||||||
PLAT="Raspbian"
|
PLAT="Raspbian"
|
||||||
|
@ -355,6 +369,7 @@ setStaticIPv4() {
|
||||||
|
|
||||||
setNetwork() {
|
setNetwork() {
|
||||||
# Sets the Network IP and Mask correctly
|
# Sets the Network IP and Mask correctly
|
||||||
|
export PATH=${PATH}:/sbin:/usr/sbin
|
||||||
LOCALMASK=$(ifconfig "${pivpnInterface}" | awk '/Mask:/{ print $4;} ' | cut -c6-)
|
LOCALMASK=$(ifconfig "${pivpnInterface}" | awk '/Mask:/{ print $4;} ' | cut -c6-)
|
||||||
LOCALIP=$(ifconfig "${pivpnInterface}" | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*')
|
LOCALIP=$(ifconfig "${pivpnInterface}" | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*')
|
||||||
IFS=. read -r i1 i2 i3 i4 <<< "$LOCALIP"
|
IFS=. read -r i1 i2 i3 i4 <<< "$LOCALIP"
|
||||||
|
@ -420,15 +435,19 @@ update_package_cache() {
|
||||||
timestampAsDate=$(date -d @"${timestamp}" "+%b %e")
|
timestampAsDate=$(date -d @"${timestamp}" "+%b %e")
|
||||||
today=$(date "+%b %e")
|
today=$(date "+%b %e")
|
||||||
|
|
||||||
if [[ ${PLAT} == "Ubuntu" || ${PLAT} == "Debian" ]]; then
|
case ${PLAT} in
|
||||||
if [[ ${OSCN} == "trusty" || ${OSCN} == "jessie" || ${OSCN} == "wheezy" ]]; then
|
Ubuntu|Debian|Devuan)
|
||||||
|
case ${OSCN} in
|
||||||
|
trusty|jessie|wheezy)
|
||||||
wget -O - https://swupdate.openvpn.net/repos/repo-public.gpg| $SUDO apt-key add -
|
wget -O - https://swupdate.openvpn.net/repos/repo-public.gpg| $SUDO apt-key add -
|
||||||
echo "deb http://swupdate.openvpn.net/apt $OSCN main" | $SUDO tee /etc/apt/sources.list.d/swupdate.openvpn.net.list > /dev/null
|
echo "deb http://swupdate.openvpn.net/apt $OSCN main" | $SUDO tee /etc/apt/sources.list.d/swupdate.openvpn.net.list > /dev/null
|
||||||
echo -n "::: Adding OpenVPN repo for $PLAT $OSCN ..."
|
echo -n "::: Adding OpenVPN repo for $PLAT $OSCN ..."
|
||||||
$SUDO apt-get -qq update & spinner $!
|
$SUDO apt-get -qq update & spinner $!
|
||||||
echo " done!"
|
echo " done!"
|
||||||
fi
|
;;
|
||||||
fi
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
if [ ! "${today}" == "${timestampAsDate}" ]; then
|
if [ ! "${today}" == "${timestampAsDate}" ]; then
|
||||||
#update package lists
|
#update package lists
|
||||||
|
@ -489,11 +508,14 @@ stopServices() {
|
||||||
# Stop openvpn
|
# Stop openvpn
|
||||||
$SUDO echo ":::"
|
$SUDO echo ":::"
|
||||||
$SUDO echo -n "::: Stopping OpenVPN service..."
|
$SUDO echo -n "::: Stopping OpenVPN service..."
|
||||||
if [[ $PLAT == "Ubuntu" || $PLAT == "Debian" ]]; then
|
case ${PLAT} in
|
||||||
|
Ubuntu|Debian|*vuan)
|
||||||
$SUDO service openvpn stop || true
|
$SUDO service openvpn stop || true
|
||||||
else
|
;;
|
||||||
|
*)
|
||||||
$SUDO systemctl stop openvpn.service || true
|
$SUDO systemctl stop openvpn.service || true
|
||||||
fi
|
;;
|
||||||
|
esac
|
||||||
$SUDO echo " done."
|
$SUDO echo " done."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -509,15 +531,19 @@ checkForDependencies() {
|
||||||
timestampAsDate=$(date -d @"$timestamp" "+%b %e")
|
timestampAsDate=$(date -d @"$timestamp" "+%b %e")
|
||||||
today=$(date "+%b %e")
|
today=$(date "+%b %e")
|
||||||
|
|
||||||
if [[ $PLAT == "Ubuntu" || $PLAT == "Debian" ]]; then
|
case ${PLAT} in
|
||||||
if [[ $OSCN == "trusty" || $OSCN == "jessie" || $OSCN == "wheezy" ]]; then
|
Ubuntu|Debian|Devuan)
|
||||||
|
case ${OSCN} in
|
||||||
|
trusty|jessie|wheezy)
|
||||||
wget -O - https://swupdate.openvpn.net/repos/repo-public.gpg| $SUDO apt-key add -
|
wget -O - https://swupdate.openvpn.net/repos/repo-public.gpg| $SUDO apt-key add -
|
||||||
echo "deb http://swupdate.openvpn.net/apt $OSCN main" | $SUDO tee /etc/apt/sources.list.d/swupdate.openvpn.net.list > /dev/null
|
echo "deb http://swupdate.openvpn.net/apt $OSCN main" | $SUDO tee /etc/apt/sources.list.d/swupdate.openvpn.net.list > /dev/null
|
||||||
echo -n "::: Adding OpenVPN repo for $PLAT $OSCN ..."
|
echo -n "::: Adding OpenVPN repo for $PLAT $OSCN ..."
|
||||||
$SUDO apt-get -qq update & spinner $!
|
$SUDO apt-get -qq update & spinner $!
|
||||||
echo " done!"
|
echo " done!"
|
||||||
fi
|
;;
|
||||||
fi
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
if [ ! "$today" == "$timestampAsDate" ]; then
|
if [ ! "$today" == "$timestampAsDate" ]; then
|
||||||
#update package lists
|
#update package lists
|
||||||
|
@ -541,7 +567,7 @@ checkForDependencies() {
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Checking dependencies:"
|
echo "::: Checking dependencies:"
|
||||||
|
|
||||||
dependencies=( openvpn git dhcpcd5 tar wget grep iptables-persistent dnsutils expect whiptail )
|
dependencies=( openvpn git dhcpcd5 tar wget grep iptables-persistent dnsutils expect whiptail net-tools)
|
||||||
for i in "${dependencies[@]}"; do
|
for i in "${dependencies[@]}"; do
|
||||||
echo -n "::: Checking for $i..."
|
echo -n "::: Checking for $i..."
|
||||||
if [ "$(dpkg-query -W -f='${Status}' "$i" 2>/dev/null | grep -c "ok installed")" -eq 0 ]; then
|
if [ "$(dpkg-query -W -f='${Status}' "$i" 2>/dev/null | grep -c "ok installed")" -eq 0 ]; then
|
||||||
|
@ -938,11 +964,14 @@ confNetwork() {
|
||||||
if [[ $noUFW -eq 1 ]]; then
|
if [[ $noUFW -eq 1 ]]; then
|
||||||
echo 1 > /tmp/noUFW
|
echo 1 > /tmp/noUFW
|
||||||
$SUDO iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o "$IPv4dev" -j MASQUERADE
|
$SUDO iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o "$IPv4dev" -j MASQUERADE
|
||||||
if [[ $PLAT == "Ubuntu" || $PLAT == "Debian" ]]; then
|
case ${PLAT} in
|
||||||
|
Ubuntu|Debian|Devuan)
|
||||||
$SUDO iptables-save | $SUDO tee /etc/iptables/rules.v4 > /dev/null
|
$SUDO iptables-save | $SUDO tee /etc/iptables/rules.v4 > /dev/null
|
||||||
else
|
;;
|
||||||
|
*)
|
||||||
$SUDO netfilter-persistent save
|
$SUDO netfilter-persistent save
|
||||||
fi
|
;;
|
||||||
|
esac
|
||||||
else
|
else
|
||||||
echo 0 > /tmp/noUFW
|
echo 0 > /tmp/noUFW
|
||||||
fi
|
fi
|
||||||
|
@ -1272,14 +1301,17 @@ main() {
|
||||||
echo ":::"
|
echo ":::"
|
||||||
|
|
||||||
# Only try to set static on Raspbian
|
# Only try to set static on Raspbian
|
||||||
if [[ $PLAT != "Raspbian" ]]; then
|
case ${PLAT} in
|
||||||
|
Rasp*)
|
||||||
|
setStaticIPv4 # This might be a problem if a user tries to modify the ip in the config file and then runs an update because of the way we check for previous configuration in /etc/dhcpcd.conf
|
||||||
|
;;
|
||||||
|
*)
|
||||||
echo "::: IP Information"
|
echo "::: IP Information"
|
||||||
echo "::: Since we think you are not using Raspbian, we will not configure a static IP for you."
|
echo "::: Since we think you are not using Raspbian, we will not configure a static IP for you."
|
||||||
echo "::: If you are in Amazon then you can not configure a static IP anyway."
|
echo "::: If you are in Amazon then you can not configure a static IP anyway."
|
||||||
echo "::: Just ensure before this installer started you had set an elastic IP on your instance."
|
echo "::: Just ensure before this installer started you had set an elastic IP on your instance."
|
||||||
else
|
;;
|
||||||
setStaticIPv4 # This might be a problem if a user tries to modify the ip in the config file and then runs an update because of the way we check for previous configuration in /etc/dhcpcd.conf
|
esac
|
||||||
fi
|
|
||||||
|
|
||||||
# Clone/Update the repos
|
# Clone/Update the repos
|
||||||
clone_or_update_repos
|
clone_or_update_repos
|
||||||
|
@ -1293,12 +1325,15 @@ main() {
|
||||||
|
|
||||||
echo "::: Restarting services..."
|
echo "::: Restarting services..."
|
||||||
# Start services
|
# Start services
|
||||||
if [[ $PLAT == "Ubuntu" || $PLAT == "Debian" ]]; then
|
case ${PLAT} in
|
||||||
|
Ubuntu|Debian|*vuan)
|
||||||
$SUDO service openvpn start
|
$SUDO service openvpn start
|
||||||
else
|
;;
|
||||||
|
*)
|
||||||
$SUDO systemctl enable openvpn.service
|
$SUDO systemctl enable openvpn.service
|
||||||
$SUDO systemctl start openvpn.service
|
$SUDO systemctl start openvpn.service
|
||||||
fi
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
echo "::: done."
|
echo "::: done."
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue