Skip to content

Commit

Permalink
Merge pull request pivpn#1464 from DerDanilo/customgitrepoandbranch
Browse files Browse the repository at this point in the history
Customgitrepoandbranch
  • Loading branch information
coolapso committed Mar 10, 2022
2 parents c03f156 + f9ef8c3 commit 8833815
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 14 deletions.
37 changes: 32 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,32 +62,59 @@ 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
### 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.

Expand Down
33 changes: 24 additions & 9 deletions auto_install/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -159,6 +160,8 @@ flagsCheck(){
"--unattended" ) runUnattended=true; unattendedConfig="${!j}";;
"--reconfigure" ) reconfigure=true;;
"--show-unsupported-nics" ) showUnsupportedNICs=true;;
"--giturl" ) pivpnGitUrl="${!j}";;
"--gitbranch" ) pivpnGitBranch="${!j}";;
esac
done

Expand Down Expand Up @@ -1040,7 +1043,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
Expand All @@ -1051,18 +1054,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 [ -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
${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
Expand All @@ -1073,12 +1082,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 [ -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
${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(){
Expand Down

0 comments on commit 8833815

Please sign in to comment.