mirror of
https://github.com/pivpn/pivpn.git
synced 2024-12-24 05:40:16 +00:00
Rework things
This commit is contained in:
parent
8a0f31b7ca
commit
371f339fed
1 changed files with 92 additions and 16 deletions
|
@ -13,6 +13,18 @@
|
||||||
|
|
||||||
######## VARIABLES #########
|
######## VARIABLES #########
|
||||||
|
|
||||||
|
tmpLog="/tmp/pivpn-install.log"
|
||||||
|
instalLogLoc="/etc/pivpn/install.log"
|
||||||
|
|
||||||
|
### PKG Vars ###
|
||||||
|
PKG_MANAGER="apt-get"
|
||||||
|
PKG_CACHE="/var/lib/apt/lists/"
|
||||||
|
UPDATE_PKG_CACHE="${PKG_MANAGER} update"
|
||||||
|
PKG_INSTALL="${PKG_MANAGER} --yes --no-install-recommends install"
|
||||||
|
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 )
|
||||||
|
### ###
|
||||||
|
|
||||||
pivpnGitUrl="https://github.com/pivpn/pivpn.git"
|
pivpnGitUrl="https://github.com/pivpn/pivpn.git"
|
||||||
pivpnFilesDir="/etc/.pivpn"
|
pivpnFilesDir="/etc/.pivpn"
|
||||||
easyrsaVer="3.0.1-pivpn1"
|
easyrsaVer="3.0.1-pivpn1"
|
||||||
|
@ -394,17 +406,73 @@ installScripts() {
|
||||||
$SUDO echo " done."
|
$SUDO echo " done."
|
||||||
}
|
}
|
||||||
|
|
||||||
fixApt() {
|
package_check_install() {
|
||||||
if [[ ${APTFAIL} == 1 ]]; then
|
dpkg-query -W -f='${Status}' "${1}" 2>/dev/null | grep -c "ok installed" || ${PKG_INSTALL} "${1}"
|
||||||
printf "\n::: There seem to be fatal apt errors. Try rebooting and running the install again.\n"
|
}
|
||||||
exit 1
|
|
||||||
|
update_package_cache() {
|
||||||
|
#Running apt-get update/upgrade with minimal output can cause some issues with
|
||||||
|
#requiring user input
|
||||||
|
|
||||||
|
#Check to see if apt-get update has already been run today
|
||||||
|
#it needs to have been run at least once on new installs!
|
||||||
|
timestamp=$(stat -c %Y ${PKG_CACHE})
|
||||||
|
timestampAsDate=$(date -d @"${timestamp}" "+%b %e")
|
||||||
|
today=$(date "+%b %e")
|
||||||
|
|
||||||
|
if [[ $PLAT == "Ubuntu" || $PLAT == "Debian" ]]; then
|
||||||
|
if [[ $OSCN == "trusty" || $OSCN == "jessie" || $OSCN == "wheezy" ]]; then
|
||||||
|
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 -n "::: Adding OpenVPN repo for $PLAT $OSCN ..."
|
||||||
|
$SUDO apt-get -qq update & spinner $!
|
||||||
|
echo " done!"
|
||||||
fi
|
fi
|
||||||
printf "\n::: Installation of some packages seems to have failed, attempting to fix...\n"
|
fi
|
||||||
$SUDO apt-get -qy update > /dev/null & spinner $!
|
|
||||||
$SUDO apt-get -qy upgrade > /dev/null & spinner $!
|
if [ ! "${today}" == "${timestampAsDate}" ]; then
|
||||||
$SUDO dpkg --configure -a > /dev/null & spinner $!
|
#update package lists
|
||||||
APTFAIL=1
|
echo ":::"
|
||||||
checkForDependencies
|
echo -n "::: ${PKG_MANAGER} update has not been run today. Running now..."
|
||||||
|
${UPDATE_PKG_CACHE} &> /dev/null
|
||||||
|
echo " done!"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
notify_package_updates_available() {
|
||||||
|
# Let user know if they have outdated packages on their system and
|
||||||
|
# advise them to run a package update at soonest possible.
|
||||||
|
echo ":::"
|
||||||
|
echo -n "::: Checking ${PKG_MANAGER} for upgraded packages...."
|
||||||
|
updatesToInstall=$(eval "${PKG_COUNT}")
|
||||||
|
echo " done!"
|
||||||
|
echo ":::"
|
||||||
|
if [[ ${updatesToInstall} -eq "0" ]]; then
|
||||||
|
echo "::: Your system is up to date! Continuing with PiVPN installation..."
|
||||||
|
else
|
||||||
|
echo "::: There are ${updatesToInstall} updates available for your system!"
|
||||||
|
echo "::: We recommend you update your OS after installing PiVPN! "
|
||||||
|
echo ":::"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
install_dependent_packages() {
|
||||||
|
# Install packages passed in via argument array
|
||||||
|
# No spinner - conflicts with set -e
|
||||||
|
declare -a argArray1=("${!1}")
|
||||||
|
|
||||||
|
echo iptables-persistent iptables-persistent/autosave_v4 boolean true | $SUDO debconf-set-selections
|
||||||
|
echo iptables-persistent iptables-persistent/autosave_v6 boolean false | $SUDO debconf-set-selections
|
||||||
|
|
||||||
|
if command -v debconf-apt-progress &> /dev/null; then
|
||||||
|
debconf-apt-progress -- ${PKG_INSTALL} "${argArray1[@]}"
|
||||||
|
else
|
||||||
|
for i in "${argArray1[@]}"; do
|
||||||
|
echo -n "::: Checking for $i..."
|
||||||
|
package_check_install "${i}" &> /dev/null
|
||||||
|
echo " installed!"
|
||||||
|
done
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
unattendedUpgrades() {
|
unattendedUpgrades() {
|
||||||
|
@ -966,14 +1034,20 @@ The install log is in /etc/pivpn." ${r} ${c}
|
||||||
}
|
}
|
||||||
|
|
||||||
######## SCRIPT ############
|
######## SCRIPT ############
|
||||||
# Install the packages (we do this first because we need whiptail)
|
|
||||||
checkForDependencies
|
|
||||||
# Start the installer
|
|
||||||
welcomeDialogs
|
|
||||||
|
|
||||||
# Verify there is enough disk space for the install
|
# Verify there is enough disk space for the install
|
||||||
verifyFreeDiskSpace
|
verifyFreeDiskSpace
|
||||||
|
|
||||||
|
# Install the packages (we do this first because we need whiptail)
|
||||||
|
#checkForDependencies
|
||||||
|
update_package_cache
|
||||||
|
|
||||||
|
notify_package_updates_available
|
||||||
|
|
||||||
|
install_dependent_packages PIVPN_DEPS[@]
|
||||||
|
|
||||||
|
# Start the installer
|
||||||
|
welcomeDialogs
|
||||||
|
|
||||||
# Find interfaces and let the user choose one
|
# Find interfaces and let the user choose one
|
||||||
chooseInterface
|
chooseInterface
|
||||||
|
|
||||||
|
@ -994,8 +1068,10 @@ chooseUser
|
||||||
unattendedUpgrades
|
unattendedUpgrades
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
installPiVPN
|
installPiVPN | tee ${tmpLog}
|
||||||
|
|
||||||
|
#Move the install log into /etc/pivpn for storage
|
||||||
|
$SUDO mv ${tmpLog} ${instalLogLoc}
|
||||||
|
|
||||||
displayFinalMessage
|
displayFinalMessage
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue