-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature:makefile - add install-beta and install-rc
Signed-off-by: Ian Cardoso <ian.cardoso@zup.com.br>
- Loading branch information
1 parent
a461416
commit 624c7a8
Showing
2 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/bin/sh | ||
# Copyright 2020 ZUP IT SERVICOS EM TECNOLOGIA E INOVACAO SA | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
URL_DOWNLOAD="" | ||
VERSION_DOWNLOAD=$1 | ||
LATEST_RC=$(git ls-remote --exit-code --sort='v:refname' --tags https://github.com/ZupIT/horusec.git --ref 'v*.*.*-rc.*' | cut --delimiter='/' --fields=3 | tail --lines=1 | sed 's/.*\///; s/\^{}//') | ||
LATEST_BETA=$(git ls-remote --exit-code --sort='v:refname' --tags https://github.com/ZupIT/horusec.git --ref 'v*.*.*-beta.*' | cut --delimiter='/' --fields=3 | tail --lines=1 | sed 's/.*\///; s/\^{}//') | ||
|
||
horusecSetVersion () { | ||
if [ -z "$LATEST_RC" ] || [ -z "$LATEST_BETA" ]; then | ||
echo "horusec still don't have rc and beta versions" | ||
exit 1 | ||
fi | ||
if [ -z "$VERSION_DOWNLOAD" ]; then | ||
echo "invalid input, empty string" | ||
exit 1 | ||
elif [ "$VERSION_DOWNLOAD" != "rc" ] && [ "$VERSION_DOWNLOAD" != "beta" ]; then | ||
echo "invalid input, use 'rc' or 'beta'" | ||
exit 1 | ||
fi | ||
if [ "$VERSION_DOWNLOAD" = "rc" ] ; then | ||
echo "Version set to $LATEST_RC" | ||
VERSION_DOWNLOAD=$LATEST_RC | ||
fi | ||
if [ "$VERSION_DOWNLOAD" = "beta" ] ; then | ||
echo "Version set to $LATEST_BETA" | ||
VERSION_DOWNLOAD=$LATEST_BETA | ||
fi | ||
echo "Download version: $VERSION_DOWNLOAD" | ||
} | ||
|
||
horusecIdentifyOSWithVersion () { | ||
if [ "$(uname)" = "Linux" ]; then | ||
if [ "$(uname -m)" = "x86_64" ]; then | ||
echo "Installing Horusec for Linux x64" | ||
URL_DOWNLOAD="https://github.com/ZupIT/horusec/releases/download/${VERSION_DOWNLOAD}/horusec_linux_x64" | ||
elif [ "$(uname -m)" = "aarch64" ]; then | ||
echo "Installing Horusec for Linux x64" | ||
URL_DOWNLOAD="https://github.com/ZupIT/horusec/releases/download/${VERSION_DOWNLOAD}/horusec_linux_arm64" | ||
else | ||
echo "Installing Horusec for Linux x86" | ||
URL_DOWNLOAD="https://github.com/ZupIT/horusec/releases/download/${VERSION_DOWNLOAD}/horusec_linux_x64" | ||
fi | ||
elif [ "$(uname)" = "Darwin" ]; then | ||
if [ "$(uname -m)" = "x86_64" ]; then | ||
echo "Installing Horusec for Mac x64" | ||
URL_DOWNLOAD="https://github.com/ZupIT/horusec/releases/download/${VERSION_DOWNLOAD}/horusec_mac_x64" | ||
elif [ "$(uname -m)" = "x86_64" ]; then | ||
echo "Installing Horusec for Mac M1" | ||
URL_DOWNLOAD="https://github.com/ZupIT/horusec/releases/download/${VERSION_DOWNLOAD}/horusec_mac_arm64" | ||
else | ||
echo "Not enable Horusec to Mac x86" | ||
exit 1 | ||
fi | ||
else | ||
echo "Unable to identify which OS you're using" | ||
exit 1 | ||
fi | ||
} | ||
|
||
horusecDownloadAndInstall () { | ||
INSTALL_PATH="/usr/local/bin" | ||
|
||
if [ ! -d "$INSTALL_PATH" ]; then | ||
mkdir -p $INSTALL_PATH | ||
fi | ||
|
||
rm -r $INSTALL_PATH/horusec >/dev/null 2>&1 | ||
|
||
echo "Downloading horusec..." | ||
echo $URL_DOWNLOAD | ||
|
||
curl -fsSL "$URL_DOWNLOAD" -o ./horusec | ||
|
||
chmod +x ./horusec | ||
|
||
sudo mv ./horusec "$INSTALL_PATH" | ||
|
||
echo "Horusec was downloaded and moved to $INSTALL_PATH/horusec" | ||
|
||
$INSTALL_PATH/horusec version | ||
} | ||
|
||
|
||
horusecSetVersion | ||
|
||
horusecIdentifyOSWithVersion | ||
|
||
horusecDownloadAndInstall |