Merge pull request #1464 from DerDanilo/customgitrepoandbranch

Customgitrepoandbranch
This commit is contained in:
4s3ti 2022-03-10 11:01:16 +01:00 committed by GitHub
commit 8833815983
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 56 additions and 14 deletions

View file

@ -62,32 +62,59 @@ even more conveniently.
## Installation ## Installation
**Method 1** ### Method 1 (standard)
```Shell ```Shell
curl -L https://install.pivpn.io | bash curl -L https://install.pivpn.io | bash
``` ```
**Method 2 (direct link)** ### Method 2 (direct link)
```Shell ```Shell
curl https://raw.githubusercontent.com/pivpn/pivpn/master/auto_install/install.sh | bash curl https://raw.githubusercontent.com/pivpn/pivpn/master/auto_install/install.sh | bash
``` ```
**Method 3 (clone repo)** ### Method 3 (clone repo)
```Shell ```Shell
git clone https://github.com/pivpn/pivpn.git git clone https://github.com/pivpn/pivpn.git
bash pivpn/auto_install/install.sh bash pivpn/auto_install/install.sh
``` ```
**To install from Test/Development branch** ### To install from Test/Development branch
```shell ```shell
curl -L https://test.pivpn.io | TESTING= bash curl -L https://test.pivpn.io | TESTING= bash
``` ```
### How it works ### 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. The script will first update your APT repositories, upgrade packages, and install WireGuard (default) or OpenVPN, which will take some time.

View file

@ -13,7 +13,8 @@
######## VARIABLES ######### ######## VARIABLES #########
pivpnGitUrl="https://github.com/pivpn/pivpn.git" 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" setupVarsFile="setupVars.conf"
setupConfigDir="/etc/pivpn" setupConfigDir="/etc/pivpn"
tempsetupVarsFile="/tmp/setupVars.conf" tempsetupVarsFile="/tmp/setupVars.conf"
@ -159,6 +160,8 @@ flagsCheck(){
"--unattended" ) runUnattended=true; unattendedConfig="${!j}";; "--unattended" ) runUnattended=true; unattendedConfig="${!j}";;
"--reconfigure" ) reconfigure=true;; "--reconfigure" ) reconfigure=true;;
"--show-unsupported-nics" ) showUnsupportedNICs=true;; "--show-unsupported-nics" ) showUnsupportedNICs=true;;
"--giturl" ) pivpnGitUrl="${!j}";;
"--gitbranch" ) pivpnGitBranch="${!j}";;
esac esac
done done
@ -1040,7 +1043,7 @@ updateRepo(){
echo "::: Repairing an existing installation, not downloading/updating local repos" echo "::: Repairing an existing installation, not downloading/updating local repos"
else else
# Pull the latest commits # 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! ### FIXME: Never call rm -rf with a plain variable. Never again as SU!
#$SUDO rm -rf "${1}" #$SUDO rm -rf "${1}"
if test -n "$1"; then if test -n "$1"; then
@ -1051,18 +1054,24 @@ updateRepo(){
cd /usr/local/src && \ cd /usr/local/src && \
$SUDO git clone -q --depth 1 --no-single-branch "${2}" "${1}" > /dev/null & spinner $! $SUDO git clone -q --depth 1 --no-single-branch "${2}" "${1}" > /dev/null & spinner $!
cd "${1}" || exit 1 cd "${1}" || exit 1
if [ -z "${TESTING+x}" ]; then echo " done!"
if [ -n "${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 else
${SUDOE} git checkout test echo "::: Checkout branch 'test' from ${2} in ${1}..."
${SUDOE} git checkout -q test
echo "::: 'test' branch checkout done!"
fi fi
echo " done!"
fi fi
} }
makeRepo(){ makeRepo(){
# Remove the non-repos interface and clone the interface # 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! ### FIXME: Never call rm -rf with a plain variable. Never again as SU!
#$SUDO rm -rf "${1}" #$SUDO rm -rf "${1}"
if test -n "$1"; then if test -n "$1"; then
@ -1073,12 +1082,18 @@ makeRepo(){
cd /usr/local/src && \ cd /usr/local/src && \
$SUDO git clone -q --depth 1 --no-single-branch "${2}" "${1}" > /dev/null & spinner $! $SUDO git clone -q --depth 1 --no-single-branch "${2}" "${1}" > /dev/null & spinner $!
cd "${1}" || exit 1 cd "${1}" || exit 1
if [ -z "${TESTING+x}" ]; then echo " done!"
if [ -n "${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 else
${SUDOE} git checkout test echo "::: Checkout branch 'test' from ${2} in ${1}..."
${SUDOE} git checkout -q test
echo "::: 'test' branch checkout done!"
fi fi
echo " done!"
} }
getGitFiles(){ getGitFiles(){