Skip to content

Commit

Permalink
Merge pull request #161 from szymonos/dev
Browse files Browse the repository at this point in the history
Merge dev to main
  • Loading branch information
szymonos authored Jun 27, 2024
2 parents c334a8f + 9f0acbb commit 5b89998
Show file tree
Hide file tree
Showing 60 changed files with 708 additions and 547 deletions.
2 changes: 1 addition & 1 deletion .assets/provision/fix_azcli_certs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.assets/provision/fix_azcli_certs.sh
'
if [ $EUID -eq 0 ]; then
printf '\e[31;1mDo not run the script as root.\e[0m\n'
printf '\e[31;1mDo not run the script as root.\e[0m\n' >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion .assets/provision/fix_certifi_certs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.assets/provision/fix_certifi_certs.sh
'
if [ $EUID -eq 0 ]; then
printf '\e[31;1mDo not run the script as root.\e[0m\n'
printf '\e[31;1mDo not run the script as root.\e[0m\n' >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion .assets/provision/fix_secure_path.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
sudo .assets/provision/fix_secure_path.sh
'
if [ $(id -u) -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n'
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
exit 1
fi

Expand Down
39 changes: 21 additions & 18 deletions .assets/provision/install_argorolloutscli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@
sudo .assets/provision/install_argorolloutscli.sh >/dev/null
'
if [ $EUID -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n'
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
exit 1
fi

# dotsource file with common functions
. .assets/provision/source.sh

# define variables
APP='kubectl-argo-rollouts'
REL=$1
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/argoproj/argo-rollouts/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
# get latest release if not provided as a parameter
if [ -z "$REL" ]; then
if REL="$(get_gh_release_latest --owner 'argoproj' --repo 'argo-rollouts')"; then
# return latest release
echo $REL
else
exit 1
fi
[[ "$REL" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]] || echo 'retrying...' >&2
done
# return latest release
echo $REL
fi

if type $APP &>/dev/null; then
VER=$(kubectl-argo-rollouts version --short | sed -En 's/.*v([0-9\.]+).*/\1/p')
Expand All @@ -32,11 +33,13 @@ if type $APP &>/dev/null; then
fi

printf "\e[92minstalling \e[1m$APP\e[22m v$REL\e[0m\n" >&2
# create temporary dir for the downloaded binary
TMP_DIR=$(mktemp -dp "$PWD")
retry_count=0
while [[ ! -f "$TMP_DIR/$APP" && $retry_count -lt 10 ]]; do
curl -#Lko "$TMP_DIR/$APP" "https://github.com/argoproj/argo-rollouts/releases/download/v${REL}/kubectl-argo-rollouts-linux-amd64"
((retry_count++))
done
install -m 0755 "$TMP_DIR/$APP" /usr/local/bin/kubectl-argo-rollouts
# calculate download uri
URL="https://github.com/argoproj/argo-rollouts/releases/download/v${REL}/kubectl-argo-rollouts-linux-amd64"
# download and install file
if download_file --uri $URL --target_dir $TMP_DIR; then
install -m 0755 "$TMP_DIR/$(basename $URL)" /usr/local/bin/kubectl-argo-rollouts
fi
# remove temporary dir
rm -fr "$TMP_DIR"
4 changes: 2 additions & 2 deletions .assets/provision/install_azurecli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.assets/provision/install_azurecli.sh --fix_certify true
'
if [ $EUID -eq 0 ]; then
printf '\e[31;1mDo not run the script as root.\e[0m\n'
printf '\e[31;1mDo not run the script as root.\e[0m\n' >&2
exit 1
fi

Expand Down Expand Up @@ -45,7 +45,7 @@ if ! conda env list | grep -qw '^azurecli'; then
conda create --name azurecli --yes python=3.11 pip
else
# https://github.com/conda/conda/issues/12051
conda create --name azurecli --yes python=3.11 pip numpy-base
conda create --name azurecli --yes python=3.11 pip numpy==1.26.4 fonttools==4.53.0
fi
fi
conda activate azurecli
Expand Down
2 changes: 1 addition & 1 deletion .assets/provision/install_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
sudo .assets/provision/install_base.sh $(id -un)
'
if [ $(id -u) -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n'
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
exit 1
fi

Expand Down
51 changes: 26 additions & 25 deletions .assets/provision/install_bat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
sudo .assets/provision/install_bat.sh >/dev/null
'
if [ $EUID -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n'
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
exit 1
fi

Expand All @@ -26,18 +26,14 @@ debian | ubuntu)
;;
esac

# dotsource file with common functions
. .assets/provision/source.sh

# define variables
REL=$1
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/sharkdp/bat/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
[[ "$REL" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]] || echo 'retrying...' >&2
done
# get latest release if not provided as a parameter
[ -z "$REL" ] && REL="$(get_gh_release_latest --owner 'sharkdp' --repo 'bat')"
# return latest release
echo $REL

Expand All @@ -62,13 +58,15 @@ fedora)
;;
debian | ubuntu)
export DEBIAN_FRONTEND=noninteractive
# create temporary dir for the downloaded binary
TMP_DIR=$(mktemp -dp "$PWD")
retry_count=0
while [[ ! -f "$TMP_DIR/$APP.deb" && $retry_count -lt 10 ]]; do
curl -#Lko "$TMP_DIR/$APP.deb" "https://github.com/sharkdp/bat/releases/download/v${REL}/bat_${REL}_amd64.deb"
((retry_count++))
done
dpkg -i "$TMP_DIR/$APP.deb" >&2 2>/dev/null || binary=true
# calculate download uri
URL="https://github.com/sharkdp/bat/releases/download/v${REL}/bat_${REL}_amd64.deb"
# download and install file
if download_file --uri $URL --target_dir $TMP_DIR; then
dpkg -i "$TMP_DIR/$(basename $URL)" >&2 2>/dev/null || binary=true
fi
# remove temporary dir
rm -fr "$TMP_DIR"
;;
opensuse)
Expand All @@ -81,14 +79,17 @@ esac

if [ "$binary" = true ]; then
echo 'Installing from binary.' >&2
# create temporary dir for the downloaded binary
TMP_DIR=$(mktemp -dp "$PWD")
retry_count=0
while [[ ! -f "$TMP_DIR/bat" && $retry_count -lt 10 ]]; do
curl -Lk "https://github.com/sharkdp/bat/releases/download/v${REL}/bat-v${REL}-x86_64-unknown-linux-gnu.tar.gz" | tar -zx --strip-components=1 -C "$TMP_DIR"
((retry_count++))
done
install -m 0755 "$TMP_DIR/bat" /usr/bin/
install -m 0644 "$TMP_DIR/bat.1" "$(manpath | cut -d : -f 1)/man1/"
install -m 0644 "$TMP_DIR/autocomplete/bat.bash" /etc/bash_completion.d/
# calculate download uri
URL="https://github.com/sharkdp/bat/releases/download/v${REL}/bat-v${REL}-x86_64-unknown-linux-gnu.tar.gz"
# download and install file
if download_file --uri $URL --target_dir $TMP_DIR; then
tar -zxf "$TMP_DIR/$(basename $URL)" --strip-components=1 -C "$TMP_DIR"
install -m 0755 "$TMP_DIR/bat" /usr/bin/
install -m 0644 "$TMP_DIR/bat.1" "$(manpath | cut -d : -f 1)/man1/"
install -m 0644 "$TMP_DIR/autocomplete/bat.bash" /etc/bash_completion.d/
fi
# remove temporary dir
rm -fr "$TMP_DIR"
fi
34 changes: 17 additions & 17 deletions .assets/provision/install_brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,19 @@
.assets/provision/install_brew.sh >/dev/null
'
if [ $EUID -eq 0 ]; then
printf '\e[31;1mDo not run the script as root.\e[0m\n'
printf '\e[31;1mDo not run the script as root.\e[0m\n' >&2
exit 1
fi

# dotsource file with common functions
. .assets/provision/source.sh

# define variables
APP='brew'
REL=$1
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/Homebrew/brew/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
[[ "$REL" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]] || echo 'retrying...' >&2
done
# get latest release if not provided as a parameter
[ -z "$REL" ] && REL="$(get_gh_release_latest --owner 'Homebrew' --repo 'brew')"
# return latest release
echo $REL

Expand All @@ -38,10 +34,14 @@ else
export NONINTERACTIVE=1
# skip tap cloning
export HOMEBREW_INSTALL_FROM_API=1
# install Homebrew in the loop
retry_count=0
while [[ ! -f /home/linuxbrew/.linuxbrew/bin/brew && $retry_count -lt 10 ]]; do
bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
((retry_count++))
done
# create temporary dir for the downloaded binary
TMP_DIR=$(mktemp -dp "$PWD")
# calculate download uri
URL="https://raw.githubusercontent.com/Homebrew/install/master/install.sh"
# download and install homebrew
if download_file --uri $URL --target_dir $TMP_DIR; then
bash -c "$TMP_DIR/$(basename $URL)"
fi
# remove temporary dir
rm -fr "$TMP_DIR"
fi
2 changes: 1 addition & 1 deletion .assets/provision/install_btop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
sudo .assets/provision/install_btop.sh
'
if [ $EUID -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n'
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion .assets/provision/install_cmatrix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
sudo .assets/provision/install_cmatrix.sh
'
if [ $EUID -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n'
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion .assets/provision/install_cowsay.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
sudo .assets/provision/install_cowsay.sh
'
if [ $EUID -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n'
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion .assets/provision/install_distrobox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
sudo .assets/provision/install_distrobox.sh $(id -un)
'
if [ $EUID -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n'
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
exit 1
fi

Expand Down
4 changes: 2 additions & 2 deletions .assets/provision/install_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
sudo .assets/provision/install_docker.sh $(id -un)
'
if [ $EUID -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n'
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
exit 1
fi

Expand Down Expand Up @@ -52,7 +52,7 @@ debian | ubuntu)
curl -fsSLk "https://download.docker.com/linux/$SYS_ID/gpg" | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/$SYS_ID \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | tee /etc/apt/sources.list.d/docker.list >/dev/null
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" >/etc/apt/sources.list.d/docker.list
fi
apt-get update && apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-compose
;;
Expand Down
2 changes: 1 addition & 1 deletion .assets/provision/install_edge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
sudo .assets/provision/install_edge.sh $(id -un)
'
if [ $EUID -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n'
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
exit 1
fi

Expand Down
42 changes: 23 additions & 19 deletions .assets/provision/install_etcdctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,44 @@
sudo .assets/provision/install_etcdctl.sh >/dev/null
'
if [ $EUID -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n'
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
exit 1
fi

# dotsource file with common functions
. .assets/provision/source.sh

# define variables
APP='etcdctl'
REL=$1
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/etcd-io/etcd/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
# get latest release if not provided as a parameter
if [ -z "$REL" ]; then
if REL="$(get_gh_release_latest --owner 'etcd-io' --repo 'etcd')"; then
# return latest release
echo $REL
else
exit 1
fi
[[ "$REL" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]] || echo 'retrying...' >&2
done
# return latest release
echo $REL
fi

if type $APP &>/dev/null; then
VER=$(etcdctl version | sed -En 's/etcdctl version: ([0-9\.]+).*/\1/p')
if [ "$REL" = "$VER" ]; then
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
# create temporary dir for the downloaded binary
TMP_DIR=$(mktemp -dp "$PWD")
retry_count=0
while [[ ! -f "$TMP_DIR/etcdctl" && $retry_count -lt 10 ]]; do
curl -#Lk "https://github.com/etcd-io/etcd/releases/download/v${REL}/etcd-v${REL}-linux-amd64.tar.gz" | tar -zx --strip-components=1 --no-same-owner -C "$TMP_DIR"
((retry_count++))
done
install -m 0755 "$TMP_DIR/etcdctl" /usr/local/bin/
# calculate download uri
URL="https://github.com/etcd-io/etcd/releases/download/v${REL}/etcd-v${REL}-linux-amd64.tar.gz"
# download and install file
if download_file --uri $URL --target_dir $TMP_DIR; then
tar -zxf "$TMP_DIR/$(basename $URL)" --strip-components=1 --no-same-owner -C "$TMP_DIR"
install -m 0755 "$TMP_DIR/$(basename $URL)" /usr/local/bin/
fi
# remove temporary dir
rm -fr "$TMP_DIR"
Loading

0 comments on commit 5b89998

Please sign in to comment.