Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .assets/config/bash_cfg/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function sysinfo {

# print user@host header
printf "\e[1;34m$(id -un)\e[0m@\e[1;34m$([ -n "$HOSTNAME" ] && printf "$HOSTNAME" || printf "$NAME")\e[0m\n"
USER_HOST="$(id -un)@$([ -n "HOSTNAME" ] && printf "$HOSTNAME" || printf "$NAME")"
USER_HOST="$(id -un)@$([ -n "$HOSTNAME" ] && printf "$HOSTNAME" || printf "$NAME")"
printf '%0.s-' $(seq 1 ${#USER_HOST})
# print system properties
printf "$SYS_PROP\n"
Expand Down
1 change: 1 addition & 0 deletions .assets/provision/autoexec.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/usr/bin/env sh
set -eu
# :script executed on WSL startup via [boot] command defined in wsl.conf
4 changes: 3 additions & 1 deletion .assets/provision/distro_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
.assets/provision/distro_check.sh | jq
.assets/provision/distro_check.sh array
'
set -euo pipefail


# store the state in an associative array
declare -A state=(
Expand Down Expand Up @@ -43,7 +45,7 @@ is_excluded() {
}

# check if array parameter is provided
if [ "$1" = 'array' ]; then
if [ "${1:-}" = 'array' ]; then
# keys to exclude
exclude_keys=('git_user' 'git_email' 'ssh_key' 'systemd' 'wslg' 'wsl_boot' 'gtkd')
# print only the keys with true values, excluding specified keys
Expand Down
4 changes: 3 additions & 1 deletion .assets/provision/fix_azcli_certs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
: '
.assets/provision/fix_azcli_certs.sh
'
set -euo pipefail

if [ $EUID -eq 0 ]; then
printf '\e[31;1mDo not run the script as root.\e[0m\n' >&2
exit 1
Expand Down Expand Up @@ -50,7 +52,7 @@ cert_count=0
# track unique serials that have been added across all certify files
declare -A added_serials=()
# iterate over certify files
for path in ${cert_paths[@]}; do
for path in "${cert_paths[@]}"; do
serial=$(openssl x509 -in "$path" -noout -serial -nameopt RFC2253 | cut -d= -f2)
if ! grep -qw "$serial" "$CERTIFY_CRT"; then
echo "$(openssl x509 -in $path -noout -subject -nameopt RFC2253 | sed 's/\\//g')" >&2
Expand Down
6 changes: 4 additions & 2 deletions .assets/provision/fix_certifi_certs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
: '
.assets/provision/fix_certifi_certs.sh
'
set -euo pipefail

if [ $EUID -eq 0 ]; then
printf '\e[31;1mDo not run the script as root.\e[0m\n' >&2
exit 1
Expand Down Expand Up @@ -63,10 +65,10 @@ if [ -z "$certify_paths" ]; then
fi

# iterate over certify files
for certify in ${certify_paths[@]}; do
for certify in "${certify_paths[@]}"; do
echo "${certify//$HOME/\~}" >&2
# iterate over installed certificates
for path in ${cert_paths[@]}; do
for path in "${cert_paths[@]}"; do
serial=$(openssl x509 -in "$path" -noout -serial -nameopt RFC2253 | cut -d= -f2)
if ! grep -qw "$serial" "$certify"; then
# add certificate to array
Expand Down
2 changes: 2 additions & 0 deletions .assets/provision/fix_nodejs_certs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
: '
sudo .assets/provision/fix_nodejs_certs.sh
'
set -euo pipefail

if [ $EUID -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
exit 1
Expand Down
2 changes: 2 additions & 0 deletions .assets/provision/fix_secure_path.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
: '
sudo .assets/provision/fix_secure_path.sh
'
set -eu

if [ $(id -u) -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
exit 1
Expand Down
9 changes: 5 additions & 4 deletions .assets/provision/install_argorolloutscli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
: '
sudo .assets/provision/install_argorolloutscli.sh >/dev/null
'
set -euo pipefail

if [ $EUID -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
exit 1
Expand All @@ -12,7 +14,7 @@ fi

# define variables
APP='kubectl-argo-rollouts'
REL=$1
REL=${1:-}
# get latest release if not provided as a parameter
if [ -z "$REL" ]; then
REL="$(get_gh_release_latest --owner 'argoproj' --repo 'argo-rollouts')"
Expand All @@ -34,12 +36,11 @@ 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 "$HOME")
TMP_DIR=$(mktemp -d -p "$HOME")
trap 'rm -fr "$TMP_DIR"' EXIT
# 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"
14 changes: 7 additions & 7 deletions .assets/provision/install_azcopy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
: '
sudo .assets/provision/install_azcopy.sh >/dev/null
'
set -euo pipefail

if [ $EUID -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
exit 1
Expand All @@ -13,7 +15,7 @@ fi
# define variables
SYS_ID="$(sed -En '/^ID.*(alpine|arch|fedora|debian|ubuntu|opensuse).*/{s//\1/;p;q}' /etc/os-release)"
APP='azcopy'
REL=$1
REL=${1:-}
# get latest release if not provided as a parameter
if [ -z "$REL" ]; then
REL="$(get_gh_release_latest --owner 'Azure' --repo 'azure-storage-azcopy')"
Expand Down Expand Up @@ -44,27 +46,25 @@ fedora)
debian | ubuntu)
export DEBIAN_FRONTEND=noninteractive
# create temporary dir for the downloaded binary
TMP_DIR=$(mktemp -dp "$HOME")
TMP_DIR=$(mktemp -d -p "$HOME")
trap 'rm -fr "$TMP_DIR"' EXIT
# calculate download uri
URL="https://github.com/Azure/azure-storage-azcopy/releases/download/v${REL}/azcopy-${REL}.x86_64.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
fi
# remove temporary dir
rm -fr "$TMP_DIR"
;;
*)
# create temporary dir for the downloaded binary
TMP_DIR=$(mktemp -dp "$HOME")
TMP_DIR=$(mktemp -d -p "$HOME")
trap 'rm -fr "$TMP_DIR"' EXIT
# calculate download uri
URL="https://github.com/Azure/azure-storage-azcopy/releases/download/v${REL}/azcopy_linux_amd64_${REL}.tar.gz"
# download and install file
if download_file --uri "$URL" --target_dir "$TMP_DIR"; then
tar -zxf "$TMP_DIR/$(basename $URL)" -C "$TMP_DIR"
install -m 0755 "$TMP_DIR/azcopy_linux_amd64_${REL}/azcopy" /usr/bin/
fi
# remove temporary dir
rm -fr "$TMP_DIR"
;;
esac
7 changes: 4 additions & 3 deletions .assets/provision/install_azurecli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
.assets/provision/install_azurecli.sh
.assets/provision/install_azurecli.sh --fix_certify true
'
set -euo pipefail

if [ $EUID -eq 0 ]; then
printf '\e[31;1mDo not run the script as root.\e[0m\n' >&2
exit 1
Expand All @@ -13,7 +15,7 @@ fix_certify=${fix_certify:-false}
while [ $# -gt 0 ]; do
if [[ $1 == *"--"* ]]; then
param="${1/--/}"
declare $param="$2"
declare $param="${2:-}"
fi
shift
done
Expand All @@ -22,8 +24,7 @@ done
[ -f "$HOME/miniforge3/bin/conda" ] || exit 0

# >>> conda initialize >>>
__conda_setup="$("$HOME/miniforge3/bin/conda" 'shell.bash' 'hook' 2>/dev/null)"
if [ $? -eq 0 ]; then
if __conda_setup="$("$HOME/miniforge3/bin/conda" 'shell.bash' 'hook' 2>/dev/null)"; then
eval "$__conda_setup"
else
if [ -f "$HOME/miniforge3/etc/profile.d/conda.sh" ]; then
Expand Down
2 changes: 2 additions & 0 deletions .assets/provision/install_azurecli_uv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
.assets/provision/install_azurecli_uv.sh
.assets/provision/install_azurecli_uv.sh --fix_certify true
'
set -euo pipefail

if [ $EUID -eq 0 ]; then
printf '\e[31;1mDo not run the script as root.\e[0m\n' >&2
exit 1
Expand Down
4 changes: 3 additions & 1 deletion .assets/provision/install_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
: '
sudo .assets/provision/install_base.sh $(id -un)
'
set -eu

if [ $(id -u) -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
exit 1
Expand Down Expand Up @@ -75,7 +77,7 @@ arch)
install_pkgs pacman "$pkgs"
# install paru
if ! pacman -Qqe paru >/dev/null 2>&1; then
user=${1:-$(id -un 1000 2>/dev/null)}
user=${1:-$(id -un 1000 2>/dev/null || true)}
if ! sudo -u $user true 2>/dev/null; then
if [ -n "$user" ]; then
printf "\e[31;1mUser does not exist ($user).\e[0m\n"
Expand Down
9 changes: 5 additions & 4 deletions .assets/provision/install_bat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
: '
sudo .assets/provision/install_bat.sh >/dev/null
'
set -euo pipefail

if [ $EUID -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
exit 1
Expand Down Expand Up @@ -30,7 +32,7 @@ esac
. .assets/provision/source.sh

# define variables
REL=$1
REL=${1:-}
# get latest release if not provided as a parameter
if [ -z "$REL" ]; then
REL="$(get_gh_release_latest --owner 'sharkdp' --repo 'bat')"
Expand Down Expand Up @@ -80,7 +82,8 @@ esac
if [ "$binary" = true ]; then
echo 'Installing from binary.' >&2
# create temporary dir for the downloaded binary
TMP_DIR=$(mktemp -dp "$HOME")
TMP_DIR=$(mktemp -d -p "$HOME")
trap 'rm -fr "$TMP_DIR"' EXIT
# 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
Expand All @@ -90,6 +93,4 @@ if [ "$binary" = true ]; then
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
11 changes: 6 additions & 5 deletions .assets/provision/install_brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# https://docs.brew.sh/Installation
.assets/provision/install_brew.sh >/dev/null
'
set -euo pipefail

if [ $EUID -eq 0 ]; then
printf '\e[31;1mDo not run the script as root.\e[0m\n' >&2
exit 1
Expand All @@ -13,7 +15,7 @@ fi

# define variables
APP='brew'
REL=$1
REL=${1:-}
# get latest release if not provided as a parameter
if [ -z "$REL" ]; then
REL="$(get_gh_release_latest --owner 'Homebrew' --repo 'brew')"
Expand All @@ -26,7 +28,7 @@ fi
echo $REL

if type brew &>/dev/null; then
VER=$(brew --version | grep -Eo '[0-9\.]+\.[0-9]+\.[0-9]+')
VER=$(brew --version | grep -Eo '[0-9\.]+\.[0-9]+\.[0-9]+' || true)
if [ "$REL" = "$VER" ]; then
printf "\e[32m$APP v$VER is already latest\e[0m\n" >&2
exit 0
Expand All @@ -40,13 +42,12 @@ else
# skip tap cloning
export HOMEBREW_INSTALL_FROM_API=1
# create temporary dir for the downloaded binary
TMP_DIR=$(mktemp -dp "$HOME")
TMP_DIR=$(mktemp -d -p "$HOME")
trap 'rm -fr "$TMP_DIR"' EXIT
# 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: 2 additions & 0 deletions .assets/provision/install_btop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
: '
sudo .assets/provision/install_btop.sh
'
set -euo pipefail

if [ $EUID -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
exit 1
Expand Down
9 changes: 5 additions & 4 deletions .assets/provision/install_cilium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
: '
sudo .assets/provision/install_cilium.sh >/dev/null
'
set -euo pipefail

if [ $EUID -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
exit 1
Expand All @@ -12,7 +14,7 @@ fi

# define variables
APP='cilium'
REL=$1
REL=${1:-}
# get latest release if not provided as a parameter
if [ -z "$REL" ]; then
REL="$(get_gh_release_latest --owner 'cilium' --repo 'cilium-cli')"
Expand All @@ -34,7 +36,8 @@ 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 "$HOME")
TMP_DIR=$(mktemp -d -p "$HOME")
trap 'rm -fr "$TMP_DIR"' EXIT
# calculate download uri
URL="https://github.com/cilium/cilium-cli/releases/download/v${REL}/cilium-linux-amd64.tar.gz"
# download and install file
Expand All @@ -44,5 +47,3 @@ if download_file --uri "$URL" --target_dir "$TMP_DIR"; then
install -m 0755 "$TMP_DIR/cilium" /opt/cilium/
[ -f /usr/bin/cilium ] || ln -s /opt/cilium/cilium /usr/bin/cilium
fi
# remove temporary dir
rm -fr "$TMP_DIR"
2 changes: 2 additions & 0 deletions .assets/provision/install_cmatrix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
: '
sudo .assets/provision/install_cmatrix.sh
'
set -euo pipefail

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

if [ $EUID -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
exit 1
Expand Down
9 changes: 5 additions & 4 deletions .assets/provision/install_crictl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
: '
sudo .assets/provision/install_crictl.sh >/dev/null
'
set -euo pipefail

if [ $EUID -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
exit 1
Expand All @@ -12,7 +14,7 @@ fi

# define variables
APP='crictl'
REL=$1
REL=${1:-}
# get latest release if not provided as a parameter
if [ -z "$REL" ]; then
REL="$(get_gh_release_latest --owner 'kubernetes-sigs' --repo 'cri-tools')"
Expand All @@ -34,13 +36,12 @@ 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 "$HOME")
TMP_DIR=$(mktemp -d -p "$HOME")
trap 'rm -fr "$TMP_DIR"' EXIT
# calculate download uri
URL="https://github.com/kubernetes-sigs/cri-tools/releases/download/v${REL}/${APP}-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)" --no-same-owner -C "$TMP_DIR"
install -m 0755 "$TMP_DIR/crictl" /usr/local/bin/
fi
# remove temporary dir
rm -fr "$TMP_DIR"
Loading