Removing bash specific commands in install script
Some checks failed
continuous-integration/drone/pr Build is failing
Some checks failed
continuous-integration/drone/pr Build is failing
This commit is contained in:
parent
1227584bb2
commit
e855ec9c0d
66
install
66
install
@ -6,7 +6,7 @@ LOCATION=/usr/local/bin
|
|||||||
# exit top level program from subshell
|
# exit top level program from subshell
|
||||||
trap "exit 1" TERM
|
trap "exit 1" TERM
|
||||||
export TOP_PID=$$
|
export TOP_PID=$$
|
||||||
function fail() {
|
fail() {
|
||||||
kill -s TERM $TOP_PID
|
kill -s TERM $TOP_PID
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ X64=x64
|
|||||||
AARCH64=aarch64
|
AARCH64=aarch64
|
||||||
|
|
||||||
# returns this platform ID
|
# returns this platform ID
|
||||||
function get_this_platform() {
|
get_this_platform() {
|
||||||
local this_platform="$(uname -s)"
|
local this_platform="$(uname -s)"
|
||||||
case $this_platform in
|
case $this_platform in
|
||||||
Linux*) echo $LIN ;;
|
Linux*) echo $LIN ;;
|
||||||
@ -37,7 +37,7 @@ function get_this_platform() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# returns this platform architecture
|
# returns this platform architecture
|
||||||
function get_this_architecture() {
|
get_this_architecture() {
|
||||||
local this_machine="$(uname -m)"
|
local this_machine="$(uname -m)"
|
||||||
case $this_machine in
|
case $this_machine in
|
||||||
x86_64) echo $X64 ;;
|
x86_64) echo $X64 ;;
|
||||||
@ -55,7 +55,7 @@ THIS_PLATFORM=$(get_this_platform)
|
|||||||
THIS_ARCHITECTURE=$(get_this_architecture)
|
THIS_ARCHITECTURE=$(get_this_architecture)
|
||||||
|
|
||||||
# fetches latest release download link for the platform
|
# fetches latest release download link for the platform
|
||||||
function get_warp_link() {
|
get_warp_link() {
|
||||||
local this_platform=$1
|
local this_platform=$1
|
||||||
local this_architecture=$2
|
local this_architecture=$2
|
||||||
|
|
||||||
@ -72,13 +72,13 @@ function get_warp_link() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# downloads and installs single binary
|
# downloads and installs single binary
|
||||||
function install() {
|
install() {
|
||||||
local name=$1
|
local name=$1
|
||||||
local link=$2
|
local link=$2
|
||||||
local temp_location="/tmp/$name"
|
local temp_location="/tmp/$name"
|
||||||
echo "Downloading $name..."
|
echo "Downloading $name..."
|
||||||
curl -fsSL -o $temp_location $link
|
curl -fsSL -o $temp_location $link
|
||||||
if [[ $? != 0 ]]; then
|
if [ $? != 0 ]; then
|
||||||
echo "Error: Failed to download $name" >&2
|
echo "Error: Failed to download $name" >&2
|
||||||
fail
|
fail
|
||||||
fi
|
fi
|
||||||
@ -88,7 +88,7 @@ function install() {
|
|||||||
--owner=root \
|
--owner=root \
|
||||||
--group=root \
|
--group=root \
|
||||||
"$temp_location" "$LOCATION"
|
"$temp_location" "$LOCATION"
|
||||||
if [[ $? != 0 ]]; then
|
if [ $? != 0 ]; then
|
||||||
echo "Error: Failed to install $name" >&2
|
echo "Error: Failed to install $name" >&2
|
||||||
fail
|
fail
|
||||||
fi
|
fi
|
||||||
@ -96,23 +96,34 @@ function install() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# returns missing dependencies
|
# returns missing dependencies
|
||||||
function get_missing_deps() {
|
get_missing_deps() {
|
||||||
local deps=(
|
if ! command -v awk > /dev/null 2<&1; then
|
||||||
"awk" \
|
echo -n "awk "
|
||||||
"curl" \
|
fi
|
||||||
"file" \
|
if ! command -v curl > /dev/null 2<&1; then
|
||||||
"grep" \
|
echo -n "curl "
|
||||||
"sed" \
|
fi
|
||||||
"sort" \
|
if ! command -v file > /dev/null 2<&1; then
|
||||||
"tar" \
|
echo -n "file "
|
||||||
"unzip" \
|
fi
|
||||||
"zip" \
|
if ! command -v grep > /dev/null 2<&1; then
|
||||||
)
|
echo -n "grep "
|
||||||
for d in ${deps[@]}; do
|
fi
|
||||||
if ! command -v $d &> /dev/null ; then
|
if ! command -v sed > /dev/null 2<&1; then
|
||||||
echo -n "$d "
|
echo -n "sed "
|
||||||
fi
|
fi
|
||||||
done
|
if ! command -v sort > /dev/null 2<&1; then
|
||||||
|
echo -n "sort "
|
||||||
|
fi
|
||||||
|
if ! command -v tar > /dev/null 2<&1; then
|
||||||
|
echo -n "tar "
|
||||||
|
fi
|
||||||
|
if ! command -v unzip > /dev/null 2<&1; then
|
||||||
|
echo -n "unzip "
|
||||||
|
fi
|
||||||
|
if ! command -v zip > /dev/null 2<&1; then
|
||||||
|
echo -n "zip"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
WARP4J_LINK="https://git.phoenix.ipv64.de/public/warp4j/raw/branch/master/warp4j"
|
WARP4J_LINK="https://git.phoenix.ipv64.de/public/warp4j/raw/branch/master/warp4j"
|
||||||
@ -125,14 +136,11 @@ MISSING_DEPS=$(get_missing_deps)
|
|||||||
install "warp-packer" "$WARP_LINK" && \
|
install "warp-packer" "$WARP_LINK" && \
|
||||||
install "warp4j" "$WARP4J_LINK"
|
install "warp4j" "$WARP4J_LINK"
|
||||||
|
|
||||||
if [[ -z $MISSING_DEPS ]]; then
|
if [ -z "$MISSING_DEPS" ]; then
|
||||||
echo "Successfully installed"
|
echo "Successfully installed"
|
||||||
else
|
else
|
||||||
echo "Main tools successfully installed"
|
echo "Main tools successfully installed"
|
||||||
echo "Please install following with your package manager:"
|
echo "Please install following with your package manager:"
|
||||||
for d in ${MISSING_DEPS[@]}; do
|
echo $MISSING_DEPS
|
||||||
echo -n "$d "
|
|
||||||
done
|
|
||||||
echo
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user