-
-
Notifications
You must be signed in to change notification settings - Fork 139
standalone-install.sh script improvements #152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
byt3farm
wants to merge
6
commits into
d3vilh:main
Choose a base branch
from
byt3farm:stand-alone-installer-improvements
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dc65653
- added detection and warning when script is running as sudo/root bec…
byt3farm 53053b5
fix wrong version
byt3farm fa06688
fix wrong line indent
byt3farm 2ed2501
fix indent
byt3farm 7a96d21
fix line indent
byt3farm 3630271
fix else
byt3farm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| #!/bin/bash | ||
| # VERSION 0.3 by [email protected] aka Mr. Philipp. | ||
| # VERSION 0.4 by [email protected] | ||
| # | ||
|
|
||
| # All the variables | ||
| GOVERSION="1.22.3" | ||
| GOVERSION="1.21.5" | ||
|
|
||
| # Description | ||
| echo "This script will install OpenVPN-UI and all the dependencies on your local environment. No containers will be used." | ||
|
|
@@ -12,127 +12,151 @@ read -p "Do you want to continue? (y/n)" -n 1 -r | |
| echo # move to a new line | ||
| if [[ ! $REPLY =~ ^[Yy]$ ]] | ||
| then | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Prevent running as root or via sudo (because go might not be found in PATH when done so) | ||
| if [ "$EUID" -eq 0 ]; then | ||
| echo "Warning: You are not running this script with sudo/root. Some steps may fail." | ||
| read -p "Do you want to continue anyway? (y/n): " -n 1 -r | ||
| echo | ||
| if [[ ! $REPLY =~ ^[Yy]$ ]]; then | ||
| echo "Exiting to avoid running as root." | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| # Check if Go is installed and the version is supported | ||
| go_version=$(go version 2>/dev/null | awk '{print $3}' | tr -d "go") | ||
| if [[ -z "$go_version" || "$go_version" < $GOVERSION ]] | ||
| then | ||
| echo "Golang version ${GOVERSION} is not installed." | ||
| read -p "Would you like to install it? (y/n) " -n 1 -r | ||
| echo "Golang version ${GOVERSION} is not installed." | ||
| read -p "Would you like to install it? (y/n) " -n 1 -r | ||
| echo # move to a new line | ||
| if [[ $REPLY =~ ^[Yy]$ ]] | ||
| then | ||
| # Install Go | ||
| arch=$(uname -m) # detect current target system's architecture | ||
| case "$arch" in | ||
| x86_64) | ||
| goarch="amd64" | ||
| ;; | ||
| aarch64 | arm64) | ||
| goarch="arm64" | ||
| ;; | ||
| armv6l | armv7l) | ||
| goarch="armv6l" # Note: Go provides only armv6l binary which works for armv7 too | ||
| ;; | ||
| *) | ||
| echo "Unsupported architecture: $arch" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
||
| gofile="go${GOVERSION}.linux-${goarch}.tar.gz" | ||
| gourl="https://go.dev/dl/${gofile}" | ||
|
|
||
| echo "Detected architecture: $arch → downloading $gourl" | ||
|
|
||
| wget -q --show-progress "$gourl" || { echo "Failed to download $gofile"; exit 1; } | ||
| sudo tar -C /usr/local -xzf "$gofile" | ||
| rm "$gofile" | ||
|
|
||
| export PATH=$PATH:/usr/local/go/bin | ||
| echo "export PATH=$PATH:$(go env GOPATH)/bin" >> ~/.bashrc | ||
| source ~/.bashrc | ||
| else | ||
| read -p "Would you like to continue without Golang ${GOVERSION} installation? (y/n) " -n 1 -r | ||
| echo # move to a new line | ||
| if [[ $REPLY =~ ^[Yy]$ ]] | ||
| if [[ ! $REPLY =~ ^[Yy]$ ]] | ||
| then | ||
| # Check the architecture of the machine | ||
| arch=$(uname -m) | ||
| if [[ "$arch" == "x86_64" ]]; then | ||
| # Install Go for x86_64 | ||
| wget https://golang.org/dl/go${GOVERSION}.linux-amd64.tar.gz | ||
| sudo tar -C /usr/local -xzf go${GOVERSION}.linux-amd64.tar.gz | ||
| elif [[ "$arch" == "aarch64" ]]; then | ||
| # Install Go for arm64 | ||
| wget https://golang.org/dl/go${GOVERSION}.linux-arm64.tar.gz | ||
| sudo tar -C /usr/local -xzf go${GOVERSION}.linux-arm64.tar.gz | ||
| elif [[ "$arch" == "armv7l" ]]; then | ||
| # Install Go for armv7l | ||
| wget https://golang.org/dl/go${GOVERSION}.linux-armv7l.tar.gz | ||
| sudo tar -C /usr/local -xzf go${GOVERSION}.linux-armv7l.tar.gz | ||
| elif [[ "$arch" == "armv6l" ]]; then | ||
| # Install Go for armv6l | ||
| wget https://golang.org/dl/go${GOVERSION}.linux-armv6l.tar.gz | ||
| sudo tar -C /usr/local -xzf go${GOVERSION}.linux-armv6l.tar.gz | ||
| else | ||
| echo "Unsupported architecture." | ||
| exit 1 | ||
| fi | ||
| export PATH=$PATH:/usr/local/go/bin | ||
| echo "export PATH=$PATH:$(go env GOPATH)/bin" >> ~/.bashrc | ||
| source ~/.bashrc | ||
| else | ||
| read -p "Would you like to continue without Golang ${GOVERSION} installation? (y/n) " -n 1 -r | ||
| echo # move to a new line | ||
| if [[ ! $REPLY =~ ^[Yy]$ ]] | ||
| then | ||
| echo "Installation terminated by user." | ||
| exit 1 | ||
| fi | ||
| echo "Installation terminated by user." | ||
| exit 1 | ||
| fi | ||
| fi | ||
| else | ||
| echo "Go version $go_version found: $(which go)" | ||
| fi | ||
|
|
||
| # Update your system | ||
| read -p "Would you like to run apt-get update? (y/n) " -n 1 -r | ||
| echo # move to a new line | ||
| if [[ $REPLY =~ ^[Yy]$ ]] | ||
| then | ||
| # Update your system | ||
| echo "Updating current environment with apt-get update" | ||
| sudo apt-get update -y | ||
| # Update your system | ||
| echo "Updating current environment with apt-get update" | ||
| sudo apt-get update -y | ||
| fi | ||
|
|
||
| # Install necessary tools | ||
| read -p "Would you like to install the dependencies (sed, gcc, git, musl-tools, easy-rsa, curl, jq, oathtool)? (y/n) " -n 1 -r | ||
| echo # move to a new line | ||
| if [[ $REPLY =~ ^[Yy]$ ]] | ||
| then | ||
| # Install necessary tools | ||
| echo "Installing dependencies (sed, gcc, git, musl-tools, easy-rsa, curl, jq, oathtool)" | ||
| sudo apt-get install -y sed gcc git musl-tools easy-rsa curl jq oathtool | ||
| # Install necessary tools | ||
| echo "Installing dependencies (sed, gcc, git, musl-tools, easy-rsa, curl, jq, oathtool)" | ||
| sudo apt-get install -y sed gcc git musl-tools easy-rsa curl jq oathtool | ||
| fi | ||
|
|
||
| # Go Modules download | ||
| read -p "Would you like to download all necessary Go modules? (y/n) " -n 1 -r | ||
| echo # move to a new line | ||
| if [[ $REPLY =~ ^[Yy]$ ]] | ||
| then | ||
| # Download all Go modules | ||
| echo "Downloading all Go modules (go mod download)" | ||
| go mod download | ||
| # Download all Go modules | ||
| echo "Downloading all Go modules (go mod download)" | ||
| go mod download | ||
| fi | ||
|
|
||
| read -p "Would you like to install Beego v2? (y/n) " -n 1 -r | ||
| echo # move to a new line | ||
| if [[ $REPLY =~ ^[Yy]$ ]] | ||
| then | ||
| # Install Beego | ||
| echo "Installing BeeGo v2" | ||
| go install github.com/beego/bee/v2@develop | ||
| # Install Beego | ||
| echo "Installing BeeGo v2" | ||
| go install github.com/beego/bee/v2@develop | ||
| fi | ||
|
|
||
| # Installing OpenVPN-UI and qrencode | ||
| read -p "Would you like to build OpenVPN-UI and qrencode binaries? (y/n) " -n 1 -r | ||
| echo # move to a new line | ||
| if [[ $REPLY =~ ^[Yy]$ ]] | ||
| then | ||
| # Install OpenVPN-UI and qrencode | ||
| echo "Installing OpenVPN-UI and qrencode" | ||
| source ~/.bashrc # reload bashrc to get bee command | ||
| # Install OpenVPN-UI and qrencode | ||
| echo "Installing OpenVPN-UI and qrencode" | ||
| source ~/.bashrc # reload bashrc to get bee command | ||
|
|
||
| if [ -d "qrencode" ]; then | ||
| echo "Directory 'qrencode' already exists. Skipping git clone." | ||
| else | ||
| echo "Cloning qrencode into build directory" | ||
| git clone https://github.com/d3vilh/qrencode | ||
| fi | ||
|
|
||
| # Set environment variables | ||
| export GO111MODULE='auto' | ||
| export CGO_ENABLED=1 | ||
| export CC=musl-gcc | ||
| # Set environment variables | ||
| export GO111MODULE='auto' | ||
| export CGO_ENABLED=1 | ||
| export CC=musl-gcc | ||
|
|
||
| # Packing openvpn-ui | ||
| cd ../ | ||
| echo "Building and packing OpenVPN-UI" | ||
| # Execute bee pack | ||
| export PATH=$PATH:$(go env GOPATH)/bin | ||
| go env -w GOFLAGS="-buildvcs=false" | ||
| source ~/.bashrc | ||
| bee version | ||
| bee pack -exr='^vendor|^ace.tar.bz2|^data.db|^build|^README.md|^docs' | ||
| # Packing openvpn-ui | ||
| CURPATH=$(pwd) | ||
| cd ../ | ||
| echo "Building and packing OpenVPN-UI" | ||
| # Execute bee pack | ||
| export PATH=$PATH:$(go env GOPATH)/bin | ||
| go env -w GOFLAGS="-buildvcs=false" | ||
| source ~/.bashrc | ||
| bee version | ||
| bee pack -exr='^vendor|^ace.tar.bz2|^data.db|^build|^README.md|^docs' | ||
|
|
||
| # Build qrencode | ||
| echo "Building qrencode" | ||
| cd build/qrencode | ||
| go build -o qrencode main.go | ||
| chmod +x qrencode | ||
| echo "Moving qrencode to GOPATH" | ||
| mv qrencode $(go env GOPATH)/bin | ||
| cd ../ | ||
| # Build qrencode | ||
| echo "Building qrencode" | ||
| cd build/qrencode | ||
| go build -o qrencode main.go | ||
| chmod +x qrencode | ||
| echo "Moving qrencode to GOPATH" | ||
| mv -v qrencode $(go env GOPATH)/bin | ||
| cd $CURPATH | ||
| fi | ||
|
|
||
| printf "\033[1;34mAll done.\033[0m\n" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should match the go version from the latest release version, instead of downgrading.