From fa60d29aa3ceb0ed6c92cbb88cc3c7e6c22c5cdd Mon Sep 17 00:00:00 2001 From: Kaladin Light <0.kaladin@gmail.com> Date: Fri, 22 Apr 2016 15:16:48 -0400 Subject: [PATCH] Get install working on ubuntu --- auto_install/install.sh | 43 +++++++++++++++++++++++++++++++++++------ scripts/listOVPN.sh | 2 +- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/auto_install/install.sh b/auto_install/install.sh index 47e5c86..8b49288 100644 --- a/auto_install/install.sh +++ b/auto_install/install.sh @@ -56,6 +56,13 @@ else fi fi +# Next rough check for platform +if [ "$(cat /etc/os-release | grep ubuntu)" ]; then + PLAT="ubuntu" +else + PLAT="raspbian" +fi + ####### FUNCTIONS ########## spinner() { @@ -167,6 +174,12 @@ chooseInterface() { fi } +avoidStaticIPv4Ubuntu() { + # If we are in Ubuntu then they need to have previously set their network, so just use what you have. + whiptail --msgbox --backtitle "IP Information" --title "IP Information" "Since we think you are using Ubuntu, and not Raspbian, we will not configure a static IP for you +If you are in Amazon then you can not configure a static IP anyway. Just ensure before this installer started you had set an elastic IP on your instance." $r $c +} + getStaticIPv4Settings() { # Ask if the user wants to use DHCP settings as their static IP if (whiptail --backtitle "Calibrating network interface" --title "Static IP Address" --yesno "Do you want to use your current network settings as a static address? @@ -288,7 +301,11 @@ stopServices() { # Stop openvpn $SUDO echo ":::" $SUDO echo -n "::: Stopping openvpn service..." - $SUDO systemctl openvpn.service stop || true + if [[ $PLAT == "ubuntu" ]]; then + $SUDO service openvpn stop || true + else + $SUDO systemctl stop openvpn.service || true + fi $SUDO echo " done." } @@ -521,7 +538,11 @@ confNetwork() { # Write script to run openvpn and allow it through firewall on boot using the template .txt file $SUDO iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o $IPv4dev -j MASQUERADE - $SUDO netfilter-persistent save + if [[ $PLAT == "ubuntu" ]]; then + $SUDO iptables-save + else + $SUDO netfilter-persistent save + fi } confOVPN() { @@ -594,8 +615,13 @@ installPiVPN() { displayFinalMessage() { # Final completion message to user - $SUDO systemctl enable openvpn.service - $SUDO systemctl start openvpn.service + if [[ $PLAT == "ubuntu" ]]; then + $SUDO service openvpn start + else + $SUDO systemctl enable openvpn.service + $SUDO systemctl start openvpn.service + fi + whiptail --msgbox --backtitle "Make it so." --title "Installation Complete!" "Now run 'pivpn add' to create the ovpn profiles. Run 'pivpn help' to see what else you can do! The install log is in /etc/pivpn." $r $c @@ -616,8 +642,13 @@ verifyFreeDiskSpace # Find interfaces and let the user choose one chooseInterface -getStaticIPv4Settings -setStaticIPv4 + +if [[ $PLAT == "ubuntu" ]]; then + avoidStaticIPv4Ubuntu +else + getStaticIPv4Settings + setStaticIPv4 +fi # Choose the user for the ovpns chooseUser diff --git a/scripts/listOVPN.sh b/scripts/listOVPN.sh index fe1cc6a..cc9903f 100644 --- a/scripts/listOVPN.sh +++ b/scripts/listOVPN.sh @@ -9,7 +9,7 @@ if [ ! -f $INDEX ]; then exit 1 fi -printf ": NOTE : You should always have a valid server entry below!\n" +printf ": NOTE : The first entry should always be your valid server!\n" printf "\n" printf "\e[1m::: Certificate Status List :::\e[0m\n" printf " ::\e[4m Status \e[0m||\e[4m Name \e[0m:: \n"