From 1c8ad27a04e3fa9da2ad62ddca6f55f9c777948f Mon Sep 17 00:00:00 2001 From: Szymon Osiecki Date: Sun, 13 Oct 2024 09:17:05 +0200 Subject: [PATCH 1/5] refactor(sh): install_base - install tig --- .assets/provision/install_base.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.assets/provision/install_base.sh b/.assets/provision/install_base.sh index dbb046ca..d8df67cb 100755 --- a/.assets/provision/install_base.sh +++ b/.assets/provision/install_base.sh @@ -12,10 +12,10 @@ SYS_ID="$(sed -En '/^ID.*(alpine|arch|fedora|debian|ubuntu|opensuse).*/{s//\1/;p case $SYS_ID in alpine) - apk add --no-cache bash bind-tools build-base ca-certificates iputils curl git jq less lsb-release-minimal mandoc nmap openssh-client openssl sudo tar tree unzip vim + apk add --no-cache bash bind-tools build-base ca-certificates iputils curl git jq less lsb-release-minimal mandoc nmap openssh-client openssl sudo tar tig tree unzip vim ;; arch) - pacman -Sy --needed --noconfirm --color=auto base-devel bash-completion dnsutils git jq lsb-release man-db nmap openssh openssl tar tree unzip vim wget 2>/dev/null + pacman -Sy --needed --noconfirm --color=auto base-devel bash-completion dnsutils git jq lsb-release man-db nmap openssh openssl tar tig tree unzip vim wget 2>/dev/null # install paru if ! pacman -Qqe paru &>/dev/null; then user=${1:-$(id -un 1000 2>/dev/null)} @@ -33,14 +33,14 @@ arch) ;; fedora) rpm -q patch &>/dev/null || dnf groupinstall -y 'Development Tools' - dnf install -qy bash-completion bind-utils curl dnf-plugins-core git iputils jq redhat-lsb-core man-db nmap openssl tar tree unzip vim wget + dnf install -qy bash-completion bind-utils curl dnf-plugins-core git iputils jq redhat-lsb-core man-db nmap openssl tar tig tree unzip vim wget ;; debian | ubuntu) export DEBIAN_FRONTEND=noninteractive - apt-get update && apt-get install -y build-essential bash-completion ca-certificates gnupg dnsutils curl git iputils-tracepath jq lsb-release man-db nmap openssl tar tree unzip vim wget + apt-get update && apt-get install -y build-essential bash-completion ca-certificates gnupg dnsutils curl git iputils-tracepath jq lsb-release man-db nmap openssl tar tig tree unzip vim wget ;; opensuse) rpm -q patch &>/dev/null || zypper in -yt pattern devel_basis - zypper in -y bash-completion bind-utils git jq lsb-release nmap openssl tar tree unzip vim wget + zypper in -y bash-completion bind-utils git jq lsb-release nmap openssl tar tig tree unzip vim wget ;; esac From 8f2aa783e229e2ed15797074072d6f4095efaeee Mon Sep 17 00:00:00 2001 From: Szymon Osiecki Date: Wed, 16 Oct 2024 23:02:58 +0200 Subject: [PATCH 2/5] feat(sh): crictl, etcdctl, nerdctl install scripts --- .assets/provision/install_crictl.sh | 46 ++++++++++++++++++++++++++ .assets/provision/install_etcdctl.sh | 4 ++- .assets/provision/install_nerdctl.sh | 48 ++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 1 deletion(-) create mode 100755 .assets/provision/install_crictl.sh create mode 100755 .assets/provision/install_nerdctl.sh diff --git a/.assets/provision/install_crictl.sh b/.assets/provision/install_crictl.sh new file mode 100755 index 00000000..88de52e1 --- /dev/null +++ b/.assets/provision/install_crictl.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +: ' +sudo .assets/provision/install_crictl.sh >/dev/null +' +if [ $EUID -ne 0 ]; then + 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='crictl' +REL=$1 +retry_count=0 +# get latest release if not provided as a parameter +if [ -z "$REL" ]; then + if REL="$(get_gh_release_latest --owner 'kubernetes-sigs' --repo 'cri-tools')"; then + # return latest release + echo $REL + else + exit 1 + fi +fi + +if type $APP &>/dev/null; then + VER=$(crictl --version | sed -En 's/crictl version v([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 +# create temporary dir for the downloaded binary +TMP_DIR=$(mktemp -dp "$PWD") +# 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" diff --git a/.assets/provision/install_etcdctl.sh b/.assets/provision/install_etcdctl.sh index 06c30016..381b5a00 100755 --- a/.assets/provision/install_etcdctl.sh +++ b/.assets/provision/install_etcdctl.sh @@ -40,7 +40,9 @@ URL="https://github.com/etcd-io/etcd/releases/download/v${REL}/etcd-v${REL}-linu # 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/ + install -m 0755 "$TMP_DIR/etcd" /usr/local/bin/ + install -m 0755 "$TMP_DIR/etcdctl" /usr/local/bin/ + install -m 0755 "$TMP_DIR/etcdutl" /usr/local/bin/ fi # remove temporary dir rm -fr "$TMP_DIR" diff --git a/.assets/provision/install_nerdctl.sh b/.assets/provision/install_nerdctl.sh new file mode 100755 index 00000000..25d7557c --- /dev/null +++ b/.assets/provision/install_nerdctl.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +: ' +sudo .assets/provision/install_nerdctl.sh >/dev/null +' +if [ $EUID -ne 0 ]; then + 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='nerdctl' +REL=$1 +retry_count=0 +# get latest release if not provided as a parameter +if [ -z "$REL" ]; then + if REL="$(get_gh_release_latest --owner 'containerd' --repo 'nerdctl')"; then + # return latest release + echo $REL + else + exit 1 + fi +fi + +if type $APP &>/dev/null; then + VER=$(nerdctl --version | sed -En 's/nerdctl version ([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 +# create temporary dir for the downloaded binary +TMP_DIR=$(mktemp -dp "$PWD") +# calculate download uri +URL="https://github.com/containerd/nerdctl/releases/download/v${REL}/${APP}-${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/nerdctl" /usr/local/bin/ + install -m 0755 "$TMP_DIR/containerd-rootless-setuptool.sh" /usr/local/bin/ + install -m 0755 "$TMP_DIR/containerd-rootless.sh" /usr/local/bin/ +fi +# remove temporary dir +rm -fr "$TMP_DIR" From 73a0c6905a4ca1093f4e7af0c38b5b1643c1881f Mon Sep 17 00:00:00 2001 From: Szymon Osiecki Date: Wed, 16 Oct 2024 23:03:14 +0200 Subject: [PATCH 3/5] fix(ps): setup_profile_user --- .assets/provision/setup_profile_user.ps1 | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/.assets/provision/setup_profile_user.ps1 b/.assets/provision/setup_profile_user.ps1 index d17bbede..cbc6ea0e 100755 --- a/.assets/provision/setup_profile_user.ps1 +++ b/.assets/provision/setup_profile_user.ps1 @@ -40,16 +40,20 @@ for ($i = 0; ((Get-Module PSReadLine -ListAvailable).Count -eq 1) -and $i -lt 5; } # install kubectl autocompletion -$kubectlSet = try { Select-String '__kubectl_debug' -Path $PROFILE -Quiet } catch { $false } -if ((Test-Path /usr/bin/kubectl) -and -not $kubectlSet) { - Write-Host 'adding kubectl auto-completion...' - # build completer text - $completer = [string]::Join("`n", - (/usr/bin/kubectl completion powershell) -join "`n", - "Register-ArgumentCompleter -CommandName 'k' -ScriptBlock `${__kubectlCompleterBlock}" - ) - # add additional ArgumentCompleter at the end of the profile - [System.IO.File]::WriteAllText($PROFILE, $completer) +if (Test-Path /usr/bin/kubectl) { + $kubectlSet = try { Select-String 'Set-Alias -Name k' -Path $PROFILE.CurrentUserCurrentHost -SimpleMatch -Quiet } catch { $false } + if (-not $kubectlSet) { + Write-Host 'adding kubectl auto-completion...' + # build completer text + $completer = [string]::Join("`n", + (/usr/bin/kubectl completion powershell) -join "`n", + "`n# setup autocompletion for the 'k' alias", + 'Set-Alias -Name k -Value kubectl', + "Register-ArgumentCompleter -CommandName 'k' -ScriptBlock `${__kubectlCompleterBlock}" + ) + # add additional ArgumentCompleter at the end of the profile + [System.IO.File]::WriteAllText($PROFILE, $completer) + } } # setup conda initialization From 6df306657d1e46ea4de08428a97ed245de0925dc Mon Sep 17 00:00:00 2001 From: Szymon Osiecki Date: Thu, 17 Oct 2024 20:27:15 +0200 Subject: [PATCH 4/5] fix(sh): install_terraform --- .assets/provision/install_terraform.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.assets/provision/install_terraform.sh b/.assets/provision/install_terraform.sh index 90e4c35a..d4767e4c 100755 --- a/.assets/provision/install_terraform.sh +++ b/.assets/provision/install_terraform.sh @@ -57,7 +57,7 @@ fedora) debian | ubuntu) export DEBIAN_FRONTEND=noninteractive wget -O- https://apt.releases.hashicorp.com/gpg 2>/dev/null | gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg - gpg --no-default-keyring --keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg --fingerprint 2>/dev/null && rm -fr $HOME/.gnupg + gpg --no-default-keyring --keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg --fingerprint 2>/dev/null echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" >/etc/apt/sources.list.d/hashicorp.list apt-get update && apt-get install terraform ;; From 0a4829d47a8a97c9db49de4e8c99fe8b617ded2e Mon Sep 17 00:00:00 2001 From: Szymon Osiecki Date: Sat, 19 Oct 2024 10:26:31 +0000 Subject: [PATCH 5/5] refactor: nerd omp theme add status icon --- .assets/config/omp_cfg/nerd.omp.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.assets/config/omp_cfg/nerd.omp.json b/.assets/config/omp_cfg/nerd.omp.json index f51e94f9..877ab895 100644 --- a/.assets/config/omp_cfg/nerd.omp.json +++ b/.assets/config/omp_cfg/nerd.omp.json @@ -37,6 +37,18 @@ "template": "<#CCCCCC>[{{ .FormattedMs }}<#CCCCCC>] ", "type": "executiontime" }, + { + "foreground": "#23D18B", + "foreground_templates": [ + "{{ if gt .Code 0 }}#F14C4C{{ end }}" + ], + "properties": { + "always_enabled": true + }, + "style": "plain", + "template": " ", + "type": "status" + }, { "foreground": "#2CC7EE", "style": "plain",