forked from altairwei/wireguard-server-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathINSTALL.sh
More file actions
executable file
·41 lines (34 loc) · 1.02 KB
/
INSTALL.sh
File metadata and controls
executable file
·41 lines (34 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
set -eu -o pipefail
shopt -s failglob
# check argbash existence
command -v argbash >/dev/null 2>&1 || \
{ echo >&2 "$0 requires argbash but it's not installed. Please visit
https://argbash.readthedocs.io/en/latest/install.html"; exit 1; }
DESTDIR=${1:-}
if [[ -z "${DESTDIR}" ]]; then
mkdir -p "build"
DESTDIR="$(pwd)/build"
fi
build_script() {
local target_name=$1
local target_script="$1.sh"
local target_parsing="$1-parsing.m4"
local excutable_name="$(basename -s ".sh" ${target_name})"
local excutable_path="${DESTDIR}/${excutable_name}"
# build mode
if [[ -r "${target_parsing}" ]]; then
argbash "${target_parsing}" -o "${excutable_path}"
cat "${target_script}" >> "${excutable_path}"
else
argbash "${target_script}" -o "${excutable_path}"
fi
echo "${excutable_name} is generated as ${excutable_path}"
}
# target list
build_script "wgserver"
build_script "wgserver-install"
build_script "wgserver-set"
build_script "wgserver-show"
cp "wgserver-lib.sh" "${DESTDIR}/"
echo "Install Successfully."