From bd334f03a98f628da656d310895cb053c41e106a Mon Sep 17 00:00:00 2001 From: DerDanilo Date: Wed, 9 Mar 2022 20:06:14 +0100 Subject: [PATCH 1/4] fix readme headings --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ba9f076..672cd0c 100644 --- a/README.md +++ b/README.md @@ -62,32 +62,32 @@ even more conveniently. ## Installation -**Method 1** +### Method 1 (standard) ```Shell curl -L https://install.pivpn.io | bash ``` -**Method 2 (direct link)** +### Method 2 (direct link) ```Shell curl https://raw.githubusercontent.com/pivpn/pivpn/master/auto_install/install.sh | bash ``` -**Method 3 (clone repo)** +### Method 3 (clone repo) ```Shell git clone https://github.com/pivpn/pivpn.git bash pivpn/auto_install/install.sh ``` -**To install from Test/Development branch** +### To install from Test/Development branch ```shell curl -L https://test.pivpn.io | TESTING= bash ``` -### How it works +## How it works The script will first update your APT repositories, upgrade packages, and install WireGuard (default) or OpenVPN, which will take some time. From aeb3eef884eb62e3bd709a7e061a25aecdfc0749 Mon Sep 17 00:00:00 2001 From: DerDanilo Date: Wed, 9 Mar 2022 20:06:29 +0100 Subject: [PATCH 2/4] add custom git url and branch readme instructions --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index 672cd0c..b647cf6 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,33 @@ bash pivpn/auto_install/install.sh curl -L https://test.pivpn.io | TESTING= bash ``` +### To install from custom git url and branch (for DEV) + +This is inteded to be used when testing changes during +development and **not** for standard installations. +Without this the script will always checkout the master branch. + +- Git repo can be pivpn or any other git repo (e.g. a fork). +- Git branch can be specified as required + +```shell +# Syntax +git clone < customgitrepourl > +bash pivpn/auto_install/install.sh --giturl < customgitrepourl > --gitbranch < customgitbranch > + +# Example +git clone https://github.com/userthatforked/pivpn.git +bash pivpn/auto_install/install.sh --giturl https://github.com/userthatforked/pivpn.git --gitbranch myfeaturebranch +``` + +The unattended setup config also supports a custom giturl and branch. + +```shell +pivpnGitUrl="https://github.com/userthatforked/pivpn.git" +pivpnGitBranch="myfeaturebranch" +``` + + ## How it works The script will first update your APT repositories, upgrade packages, and install WireGuard (default) or OpenVPN, which will take some time. From 75cebe13a5c9fa87658502786ba82b99427ab60f Mon Sep 17 00:00:00 2001 From: DerDanilo Date: Wed, 9 Mar 2022 20:06:39 +0100 Subject: [PATCH 3/4] add custom git url and branch options --- auto_install/install.sh | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/auto_install/install.sh b/auto_install/install.sh index debdf78..e42372a 100755 --- a/auto_install/install.sh +++ b/auto_install/install.sh @@ -13,7 +13,8 @@ ######## VARIABLES ######### pivpnGitUrl="https://github.com/pivpn/pivpn.git" -#pivpnGitUrl="/home/pi/repos/pivpn" +# Uncomment to checkout a custom branch for local pivpn files +#pivpnGitBranch="custombranchtocheckout" setupVarsFile="setupVars.conf" setupConfigDir="/etc/pivpn" tempsetupVarsFile="/tmp/setupVars.conf" @@ -150,6 +151,8 @@ flagsCheck(){ "--unattended" ) runUnattended=true; unattendedConfig="${!j}";; "--reconfigure" ) reconfigure=true;; "--show-unsupported-nics" ) showUnsupportedNICs=true;; + "--giturl" ) pivpnGitUrl="${!j}";; + "--gitbranch" ) pivpnGitBranch="${!j}";; esac done @@ -978,7 +981,7 @@ updateRepo(){ echo "::: Repairing an existing installation, not downloading/updating local repos" else # Pull the latest commits - echo -n "::: Updating repo in $1..." + echo -n "::: Updating repo in ${1} from ${2} ..." ### FIXME: Never call rm -rf with a plain variable. Never again as SU! #$SUDO rm -rf "${1}" if test -n "$1"; then @@ -989,18 +992,24 @@ updateRepo(){ cd /usr/local/src && \ $SUDO git clone -q --depth 1 --no-single-branch "${2}" "${1}" > /dev/null & spinner $! cd "${1}" || exit 1 - if [ -z "${TESTING+x}" ]; then + echo " done!" + if [ ! -z "${pivpnGitBranch}" ]; then + echo "::: Checkout branch '${pivpnGitBranch}' from ${2} in ${1}..." + ${SUDOE} git checkout -q ${pivpnGitBranch} + echo "::: Custom branch checkout done!" + elif [ -z "${TESTING+x}" ]; then : else - ${SUDOE} git checkout test + echo "::: Checkout branch 'test' from ${2} in ${1}..." + ${SUDOE} git checkout -q test + echo "::: 'test' branch checkout done!" fi - echo " done!" fi } makeRepo(){ # Remove the non-repos interface and clone the interface - echo -n "::: Cloning $2 into $1..." + echo -n "::: Cloning ${2} into ${1} ..." ### FIXME: Never call rm -rf with a plain variable. Never again as SU! #$SUDO rm -rf "${1}" if test -n "$1"; then @@ -1011,12 +1020,18 @@ makeRepo(){ cd /usr/local/src && \ $SUDO git clone -q --depth 1 --no-single-branch "${2}" "${1}" > /dev/null & spinner $! cd "${1}" || exit 1 - if [ -z "${TESTING+x}" ]; then + echo " done!" + if [ ! -z "${pivpnGitBranch}" ]; then + echo "::: Checkout branch '${pivpnGitBranch}' from ${2} in ${1}..." + ${SUDOE} git checkout -q ${pivpnGitBranch} + echo "::: Custom branch checkout done!" + elif [ -z "${TESTING+x}" ]; then : else - ${SUDOE} git checkout test + echo "::: Checkout branch 'test' from ${2} in ${1}..." + ${SUDOE} git checkout -q test + echo "::: 'test' branch checkout done!" fi - echo " done!" } getGitFiles(){ From f9ef8c3881d67371d74396ed03f6f1125ec82c92 Mon Sep 17 00:00:00 2001 From: DerDanilo Date: Wed, 9 Mar 2022 20:16:30 +0100 Subject: [PATCH 4/4] fix lint SC2236 --- auto_install/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auto_install/install.sh b/auto_install/install.sh index e42372a..c39bec5 100755 --- a/auto_install/install.sh +++ b/auto_install/install.sh @@ -993,7 +993,7 @@ updateRepo(){ $SUDO git clone -q --depth 1 --no-single-branch "${2}" "${1}" > /dev/null & spinner $! cd "${1}" || exit 1 echo " done!" - if [ ! -z "${pivpnGitBranch}" ]; then + if [ -n "${pivpnGitBranch}" ]; then echo "::: Checkout branch '${pivpnGitBranch}' from ${2} in ${1}..." ${SUDOE} git checkout -q ${pivpnGitBranch} echo "::: Custom branch checkout done!" @@ -1021,7 +1021,7 @@ makeRepo(){ $SUDO git clone -q --depth 1 --no-single-branch "${2}" "${1}" > /dev/null & spinner $! cd "${1}" || exit 1 echo " done!" - if [ ! -z "${pivpnGitBranch}" ]; then + if [ -n "${pivpnGitBranch}" ]; then echo "::: Checkout branch '${pivpnGitBranch}' from ${2} in ${1}..." ${SUDOE} git checkout -q ${pivpnGitBranch} echo "::: Custom branch checkout done!"