-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from szymonos/dev
Merge dev to main
- Loading branch information
Showing
9 changed files
with
230 additions
and
48 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
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,78 @@ | ||
#!/usr/bin/env bash | ||
: ' | ||
.assets/provision/install_miniforge.sh | ||
.assets/provision/install_miniforge.sh --fix_certify true | ||
' | ||
if [ $EUID -eq 0 ]; then | ||
printf '\e[31;1mDo not run the script as root.\e[0m\n' | ||
exit 1 | ||
fi | ||
|
||
# parse named parameters | ||
fix_certify=${fix_certify:-false} | ||
while [ $# -gt 0 ]; do | ||
if [[ $1 == *"--"* ]]; then | ||
param="${1/--/}" | ||
declare $param="$2" | ||
fi | ||
shift | ||
done | ||
|
||
# set script working directory to workspace folder | ||
SCRIPT_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd) | ||
pushd "$(cd "${SCRIPT_ROOT}/../../" && pwd)" >/dev/null | ||
|
||
# *conda init function. | ||
function conda_init { | ||
__conda_setup="$("$HOME/miniforge3/bin/conda" 'shell.bash' 'hook' 2>/dev/null)" | ||
if [ $? -eq 0 ]; then | ||
eval "$__conda_setup" | ||
else | ||
if [ -f "$HOME/miniforge3/etc/profile.d/conda.sh" ]; then | ||
. "$HOME/miniforge3/etc/profile.d/conda.sh" | ||
else | ||
export PATH="$HOME/miniforge3/bin:$PATH" | ||
fi | ||
fi | ||
unset __conda_setup | ||
} | ||
|
||
# *Install conda. | ||
if [ -d "$HOME/miniforge3" ]; then | ||
conda_init | ||
else | ||
printf "\e[92minstalling \e[1mminiforge\e[0m\n" | ||
TMP_DIR=$(mktemp -dp "$PWD") | ||
retry_count=0 | ||
while [[ ! -f "$TMP_DIR/miniforge.sh" && $retry_count -lt 10 ]]; do | ||
curl -#Lko "$TMP_DIR/miniforge.sh" "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" | ||
((retry_count++)) | ||
done | ||
bash $TMP_DIR/miniforge.sh -b -p "$HOME/miniforge3" >/dev/null | ||
rm -fr "$TMP_DIR" | ||
# disable auto activation of the base conda environment | ||
conda_init | ||
conda config --set auto_activate_base false | ||
fi | ||
# disable conda env prompt if oh-my-posh is installed | ||
if [ -f /usr/bin/oh-my-posh ]; then | ||
conda config --set changeps1 false | ||
fi | ||
|
||
# *Add certificates to conda base certifi. | ||
if $fix_certify; then | ||
conda activate base | ||
.assets/provision/fix_certifi_certs.sh | ||
conda deactivate | ||
fi | ||
|
||
# *Update conda. | ||
conda update --name base --channel defaults conda --yes --update-all | ||
conda clean --yes --all | ||
|
||
# *Fix certificates after update. | ||
if $fix_certify; then | ||
conda activate base | ||
.assets/provision/fix_certifi_certs.sh | ||
conda deactivate | ||
fi |
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,41 @@ | ||
#!/usr/bin/env bash | ||
: ' | ||
sudo .assets/provision/install_terrascan.sh | ||
' | ||
if [ $EUID -ne 0 ]; then | ||
printf '\e[31;1mRun the script as root.\e[0m\n' | ||
exit 1 | ||
fi | ||
|
||
APP='terrascan' | ||
retry_count=0 | ||
# try 10 times to get latest release if not provided as a parameter | ||
while [ -z "$REL" ]; do | ||
REL=$(curl -sk https://api.github.com/repos/tenable/terrascan/releases/latest | sed -En 's/.*"tag_name": "v?([^"]*)".*/\1/p') | ||
((retry_count++)) | ||
if [ $retry_count -eq 10 ]; then | ||
printf "\e[33m$APP version couldn't be retrieved\e[0m\n" >&2 | ||
exit 0 | ||
fi | ||
[[ -n "$REL" || $i -eq 10 ]] || echo 'retrying...' >&2 | ||
done | ||
|
||
if type $APP &>/dev/null; then | ||
VER=$($APP version | sed -En 's/.*\sv([0-9\.]+)/\1/p') | ||
if [ "$REL" = "$VER" ]; then | ||
printf "\e[32m$APP v$VER is already latest\e[0m\n" >&2 | ||
exit 0 | ||
fi | ||
fi | ||
|
||
printf "\e[92minstalling \e[1m$APP\e[22m v$REL\e[0m\n" >&2 | ||
TMP_DIR=$(mktemp -dp "$PWD") | ||
retry_count=0 | ||
while [[ ! -f "$TMP_DIR/terrascan" && $retry_count -lt 10 ]]; do | ||
curl -#Lk "https://github.com/tenable/terrascan/releases/download/v${REL}/terrascan_${REL}_Linux_x86_64.tar.gz" | tar -zx -C "$TMP_DIR" | ||
((retry_count++)) | ||
done | ||
install -m 0755 "$TMP_DIR/terrascan" /usr/bin/ | ||
rm -fr "$TMP_DIR" | ||
|
||
exit 0 |
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,43 @@ | ||
#!/usr/bin/env bash | ||
: ' | ||
sudo .assets/provision/install_tfswitch.sh | ||
' | ||
if [ $EUID -ne 0 ]; then | ||
printf '\e[31;1mRun the script as root.\e[0m\n' | ||
exit 1 | ||
fi | ||
|
||
APP='tfswitch' | ||
retry_count=0 | ||
# try 10 times to get latest release if not provided as a parameter | ||
while [ -z "$REL" ]; do | ||
REL=$(curl -sk https://api.github.com/repos/warrensbox/terraform-switcher/releases/latest | sed -En 's/.*"tag_name": "v?([^"]*)".*/\1/p') | ||
((retry_count++)) | ||
if [ $retry_count -eq 10 ]; then | ||
printf "\e[33m$APP version couldn't be retrieved\e[0m\n" >&2 | ||
exit 0 | ||
fi | ||
[[ -n "$REL" || $i -eq 10 ]] || echo 'retrying...' >&2 | ||
done | ||
|
||
if type $APP &>/dev/null; then | ||
VER=$($APP --version | sed -En 's/.*\s([0-9\.]+)/\1/p') | ||
if [ "$REL" = "$VER" ]; then | ||
printf "\e[32m$APP v$VER is already latest\e[0m\n" >&2 | ||
exit 0 | ||
fi | ||
fi | ||
|
||
printf "\e[92minstalling \e[1m$APP\e[22m v$REL\e[0m\n" >&2 | ||
__install="curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh | bash" | ||
if type $APP &>/dev/null; then | ||
eval $__install | ||
else | ||
retry_count=0 | ||
while ! type $APP &>/dev/null && [ $retry_count -lt 10 ]; do | ||
eval $__install | ||
((retry_count++)) | ||
done | ||
fi | ||
|
||
exit 0 |
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
Oops, something went wrong.