Skip to content
Merged

dev #233

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
4 changes: 2 additions & 2 deletions .assets/config/bash_cfg/aliases_git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ function git_resolve_branch {

function gsw {
br=$(git_resolve_branch $1)
git switch $(git_resolve_branch $br)
git switch "$(git_resolve_branch "$br")"
}

function grmb {
br=$(git_resolve_branch $1)
git reset $(git merge-base $(grt)/$br HEAD)
git reset "$(git merge-base "$(grt)"/"$br" HEAD)"
}
#endregion

Expand Down
9 changes: 5 additions & 4 deletions .assets/config/bash_cfg/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function sysinfo {
cpu_name="$(sed -En '/^model name\s*: (.+)/{s//\1/;p;q}' /proc/cpuinfo)"
cpu_cores="$(sed -En '/^cpu cores\s*: ([0-9]+)/{s//\1/;p;q}' /proc/cpuinfo)"
# calculate memory usage
mem_inf=($(awk -F ':|kB' '/MemTotal:|MemAvailable:/ {printf $2, " "}' /proc/meminfo))
mapfile -t mem_inf < <(awk -F ':|kB' '/MemTotal:|MemAvailable:/ {print $2}' /proc/meminfo)
mem_total=${mem_inf[0]}
mem_used=$((mem_total - mem_inf[1]))
mem_perc=$(awk '{printf "%.0f", $1 * $2 / $3}' <<<"$mem_used 100 $mem_total")
Expand Down Expand Up @@ -37,7 +37,7 @@ function sysinfo {
printf "$SYS_PROP\n"
}
# set alias
alias sysinfo='gsi'
alias gsi='sysinfo'

# *Function for fixing Python SSL certificate issues by adding custom certificates to certifi's cacert.pem
function fixcertpy {
Expand Down Expand Up @@ -65,8 +65,9 @@ function fixcertpy {
esac

# get list of installed certificates
cert_paths=($(ls $CERT_PATH/*.crt 2>/dev/null))
if [ -z "$cert_paths" ]; then
mapfile -t cert_paths < <(ls "$CERT_PATH"/*.crt 2>/dev/null || true)
if [ "${#cert_paths[@]}" -eq 0 ]; then
printf '\033[36mno custom certificates found in \033[4m%s\n\033[0m' "$CERT_PATH" >&2
return 0
fi

Expand Down
2 changes: 2 additions & 0 deletions .assets/docker/build_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
: '
.assets/docker/build_docker.sh
'
set -e

# set script working directory to workspace folder
cd "$(readlink -f "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/../../")"

Expand Down
4 changes: 2 additions & 2 deletions .assets/provision/fix_azcli_certs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ debian | ubuntu)
esac

# get list of installed certificates
cert_paths=($(ls $CERT_PATH/*.crt 2>/dev/null))
if [ -z "$cert_paths" ]; then
mapfile -t cert_paths < <(ls "$CERT_PATH"/*.crt 2>/dev/null || true)
if [ "${#cert_paths[@]}" -eq 0 ]; then
printf '\nThere are no certificate(s) to install.\n' >&2
exit 0
fi
Expand Down
6 changes: 3 additions & 3 deletions .assets/provision/fix_certifi_certs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ opensuse)
esac

# get list of installed certificates
cert_paths=($(ls $CERT_PATH/*.crt 2>/dev/null))
if [ -z "$cert_paths" ]; then
mapfile -t cert_paths < <(ls "$CERT_PATH"/*.crt 2>/dev/null || true)
if [ "${#cert_paths[@]}" -eq 0 ]; then
exit 0
fi

Expand Down Expand Up @@ -59,7 +59,7 @@ if [ -n "$SHOW" ]; then
fi

# exit script if no certify cacert.pem found
if [ -z "$certify_paths" ]; then
if [ "${#certify_paths[@]}" -eq 0 ]; then
printf '\e[33mcertifi/cacert.pem not found\e[0m\n' >&2
exit 0
fi
Expand Down
2 changes: 1 addition & 1 deletion .assets/provision/fix_gcloud_certs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ opensuse)
CERT_PATH='/usr/share/pki/trust/anchors'
esac

cert_files=($(find "$CERT_PATH" -maxdepth 1 -name '*.crt' 2>/dev/null || true))
mapfile -t cert_files < <(find "$CERT_PATH" -maxdepth 1 -name '*.crt' 2>/dev/null || true)
if [ "${#cert_files[@]}" -eq 0 ]; then
printf '\nNo custom certificates found in %s\n' "$CERT_PATH" >&2
exit 0
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 @@ -4,7 +4,7 @@ sudo .assets/provision/fix_secure_path.sh
'
set -eu

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

if [ $(id -u) -ne 0 ]; then
if [ "$(id -u)" -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
exit 1
fi
Expand Down Expand Up @@ -64,7 +64,7 @@ alpine)
# update package index
apk update 2>/dev/null || true
# install base packages
pkgs="bash bind-tools build-base ca-certificates curl iputils gawk git jq less lsb-release-minimal mandoc nmap openssh-client shfmt openssl sudo tar tig tree unzip vim which whois"
pkgs="bash bind-tools build-base ca-certificates curl fd gawk git iputils jq less lsb-release-minimal mandoc nmap openssh-client shfmt openssl sudo tar tig tree unzip vim which whois"
install_pkgs apk "$pkgs"
;;
arch)
Expand All @@ -73,7 +73,7 @@ arch)
# refresh package database and install archlinux-keyring
pacman -Sy --needed --noconfirm --color=auto archlinux-keyring
# install base packages
pkgs="base-devel bash-completion curl dnsutils gawk git jq lsb-release man-db nmap openssh shfmt openssl tar tig tree unzip vim wget which whois"
pkgs="base-devel bash-completion curl dnsutils fd gawk git jq lsb-release man-db nmap openssh shfmt openssl tar tig tree unzip vim wget which whois"
install_pkgs pacman "$pkgs"
# install paru
if ! pacman -Qqe paru >/dev/null 2>&1; then
Expand All @@ -96,10 +96,10 @@ fedora)
# install development tools group
rpm -q patch >/dev/null 2>&1 || dnf group install -y development-tools 2>/dev/null || true
# install base packages
if [ "$(readlink $(which dnf))" = 'dnf5' ]; then
pkgs="bash-completion bind-utils curl dnf5-plugins gawk git iputils jq man-db nmap shfmt openssl tar tig tree unzip vim wget which whois"
if [ "$(readlink "$(which dnf)")" = 'dnf5' ]; then
pkgs="bash-completion bind-utils curl dnf5-plugins fd gawk git iputils jq man-db nmap shfmt openssl tar tig tree unzip vim wget which whois"
else
pkgs="bash-completion bind-utils curl dnf-plugins-core gawk git iputils jq man-db nmap shfmt openssl tar tig tree unzip vim wget which whois"
pkgs="bash-completion bind-utils curl dnf-plugins-core fd gawk git iputils jq man-db nmap shfmt openssl tar tig tree unzip vim wget which whois"
fi
install_pkgs dnf "$pkgs"
;;
Expand All @@ -108,7 +108,7 @@ debian | ubuntu)
# refresh package index
apt-get update 2>/dev/null
# install base packages
pkgs="build-essential bash-completion ca-certificates curl gawk gnupg dnsutils git iputils-tracepath jq lsb-release man-db nmap shfmt openssl tar tig tree unzip vim wget which whois"
pkgs="build-essential bash-completion ca-certificates curl fd gawk gnupg dnsutils git iputils-tracepath jq lsb-release man-db nmap shfmt openssl tar tig tree unzip vim wget which whois"
install_pkgs apt "$pkgs"
# autoremove unnecessary packages and clean up apt cache
apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
Expand All @@ -119,7 +119,7 @@ opensuse)
# install development tools pattern
rpm -q patch >/dev/null 2>&1 || zypper --non-interactive --no-refresh in -yt pattern devel_basis 2>/dev/null || true
# install base packages
pkgs="bash-completion bind-utils curl gawk git jq lsb-release nmap shfmt openssl tar tig tree unzip vim wget which whois"
pkgs="bash-completion bind-utils curl fd gawk git jq lsb-release nmap shfmt openssl tar tig tree unzip vim wget which whois"
install_pkgs zypper "$pkgs"
;;
esac
46 changes: 37 additions & 9 deletions .assets/provision/install_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,32 +95,60 @@ case $SYS_ID in
arch)
pacman -Sy --needed --noconfirm docker docker-compose
;;
debian)
export DEBIAN_FRONTEND=noninteractive
if dpkg -s docker &>/dev/null; then
apt-get remove docker docker-engine docker.io containerd runc 2>/dev/null
fi
if [ ! -f /etc/apt/sources.list.d/docker.sources ]; then
# add Docker's official GPG key
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
# add the repository to Apt sources
cat <<EOF > /etc/apt/sources.list.d/docker.sources
Types: deb
URIs: https://download.docker.com/linux/debian
Suites: $(. /etc/os-release && echo "$VERSION_CODENAME")
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
EOF
fi
apt-get update && apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
;;
fedora)
if rpm -q docker &>/dev/null; then
dnf remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine
fi
if [ ! -f /etc/yum.repos.d/docker-ce.repo ]; then
if [ "$(readlink $(which dnf))" = 'dnf5' ]; then
if [ "$(readlink "$(which dnf)")" = 'dnf5' ]; then
dnf config-manager addrepo --from-repofile https://download.docker.com/linux/fedora/docker-ce.repo
else
dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
fi
fi
dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
;;
debian | ubuntu)
ubuntu)
export DEBIAN_FRONTEND=noninteractive
if dpkg -s docker &>/dev/null; then
apt-get remove docker docker-engine docker.io containerd runc 2>/dev/null
fi
if [ ! -f /etc/apt/sources.list.d/docker.list ]; then
mkdir -m 0755 -p /etc/apt/keyrings
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" >/etc/apt/sources.list.d/docker.list
if [ ! -f /etc/apt/sources.list.d/docker.sources ]; then
# add Docker's official GPG key
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
# add the repository to Apt sources
cat <<EOF > /etc/apt/sources.list.d/docker.sources
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
EOF
fi
apt-get update && apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-compose
apt-get update && apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
;;
opensuse)
zypper --non-interactive in -y docker containerd 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 @@ -32,7 +32,7 @@ arch)
fedora)
rpm --import 'https://packages.microsoft.com/keys/microsoft.asc'
if [ ! -f /etc/yum.repos.d/microsoft-edge-stable.repo ]; then
if [ "$(readlink $(which dnf))" = 'dnf5' ]; then
if [ "$(readlink "$(which dnf)")" = 'dnf5' ]; then
dnf config-manager addrepo --from-repofile https://packages.microsoft.com/yumrepos/edge
else
dnf config-manager --add-repo https://packages.microsoft.com/yumrepos/edge
Expand Down
2 changes: 1 addition & 1 deletion .assets/provision/install_gcloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ install_from_tarball() {
fi

tar -zxf "$tmp_dir/$archive_name" -C "$tmp_dir"
rm -rf "$install_dir/$gcloud_dir"
rm -rf "${install_dir:?}/${gcloud_dir:?}"
mkdir -p "$install_dir"
mv "$tmp_dir/$gcloud_dir" "$install_dir" >/dev/null

Expand Down
2 changes: 1 addition & 1 deletion .assets/provision/install_gh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fedora)
if dnf info -y gh >/dev/null 2>&1; then
dnf install -y gh >&2 2>/dev/null
else
if [ "$(readlink $(which dnf))" = 'dnf5' ]; then
if [ "$(readlink "$(which dnf)")" = 'dnf5' ]; then
dnf config-manager addrepo --from-repofile https://cli.github.com/packages/rpm/gh-cli.repo
else
dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
Expand Down
2 changes: 1 addition & 1 deletion .assets/provision/install_k3d.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ retry_count=0
while
curl -sk 'https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh' | bash >&2
((retry_count++)) || true
[[ $(k3d --version 2>/dev/null | sed -En 's/.*v([0-9\.]+)$/\1/p') != $REL && $retry_count -le 10 ]]
[[ $(k3d --version 2>/dev/null | sed -En 's/.*v([0-9\.]+)$/\1/p') != "$REL" && $retry_count -le 10 ]]
do :; done

exit 0
2 changes: 1 addition & 1 deletion .assets/provision/install_kubecolor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fi
printf "\e[92minstalling \e[1m$APP\e[22m v$REL\e[0m\n" >&2
case $SYS_ID in
fedora)
if [ "$(readlink $(which dnf))" = 'dnf5' ]; then
if [ "$(readlink "$(which dnf)")" = 'dnf5' ]; then
dnf config-manager addrepo --from-repofile https://kubecolor.github.io/packages/rpm/kubecolor.repo
else
dnf config-manager --add-repo https://kubecolor.github.io/packages/rpm/kubecolor.repo
Expand Down
4 changes: 2 additions & 2 deletions .assets/provision/install_kubeseal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ elif [ -z "$URL" ]; then
printf "\e[31mError: The download URL is required.\e[0m\n" >&2
exit 1
else
response="{\"version\":\"$REL\",\"download_url\":\"$URL\"}"
response=$(printf '{"version":"%s","download_url":"%s"}' "$REL" "$URL")
fi
# return json response
echo $response
echo "$response"

# exit if the URL is not set
if [ -z "$URL" ]; then
Expand Down
4 changes: 2 additions & 2 deletions .assets/provision/install_omp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ elif [ -z "$URL" ]; then
printf "\e[31mError: The download URL is required.\e[0m\n" >&2
exit 1
else
response="{\"version\":\"$REL\",\"download_url\":\"$URL\"}"
response=$(printf '{"version":"%s","download_url":"%s"}' "$REL" "$URL")
fi
# return json response
echo $response
echo "$response"

if type $APP &>/dev/null; then
VER=$(oh-my-posh version)
Expand Down
2 changes: 1 addition & 1 deletion .assets/provision/install_terraform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ arch)
pacman -Sy --needed --noconfirm terraform >&2 2>/dev/null
;;
fedora)
if [ "$(readlink $(which dnf))" = 'dnf5' ]; then
if [ "$(readlink "$(which dnf)")" = 'dnf5' ]; then
dnf config-manager addrepo --from-repofile https://rpm.releases.hashicorp.com/fedora/hashicorp.repo
else
dnf config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
Expand Down
2 changes: 1 addition & 1 deletion .assets/provision/setup_gh_repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ while [ $# -gt 0 ]; do
done

# *calculate variables
gh_repos=($repos)
read -ra gh_repos <<< "$repos"
# calculate workspace name
if [ -n "$WSL_DISTRO_NAME" ]; then
ID="$WSL_DISTRO_NAME"
Expand Down
2 changes: 1 addition & 1 deletion .assets/provision/setup_profile_allusers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ grep -qw 'completion-ignore-case' /etc/inputrc || echo 'set completion-ignore-ca
[ -f /etc/localtime ] || ln -s /usr/share/zoneinfo/UTC /etc/localtime

# *add reboot/shutdown polkit rule for vagrant group
if grep -qw '^vagrant' <<<$(getent group) && [[ ! -f /usr/share/polkit-1/rules.d/49-nopasswd_shutdown.rules && -d /usr/share/polkit-1/rules.d ]]; then
if grep -qw '^vagrant' <<<"$(getent group)" && [[ ! -f /usr/share/polkit-1/rules.d/49-nopasswd_shutdown.rules && -d /usr/share/polkit-1/rules.d ]]; then
cat <<EOF >/usr/share/polkit-1/rules.d/49-nopasswd_shutdown.rules
/* Allow members of the vagrant group to shutdown or restart
* without password authentication.
Expand Down
4 changes: 2 additions & 2 deletions .assets/provision/source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ download_file() {
[ -z "$target_dir" ] && target_dir='.' || true

# define local variables
local file_name="$(basename $uri)"
local file_name="$(basename "$uri")"
local max_retries=8
local retry_count=0

while [ $retry_count -le $max_retries ]; do
# download file
status_code=$(curl -w %{http_code} -#Lko "$target_dir/$file_name" "$uri" 2>/dev/null)
status_code=$(curl -w '%{http_code}' -#Lko "$target_dir/$file_name" "$uri" 2>/dev/null)

# check the HTTP status code
case $status_code in
Expand Down
2 changes: 1 addition & 1 deletion .assets/provision/upgrade_system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sudo .assets/provision/upgrade_system.sh
'
set -eu

if [ $(id -u) -ne 0 ]; then
if [ "$(id -u)" -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
exit 1
fi
Expand Down
8 changes: 5 additions & 3 deletions .assets/scripts/linux_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ omp_theme="nerd"
# :skip GitHub authentication setup
.assets/scripts/linux_setup.sh --skip_gh_auth true --scope "$scope" --omp_theme "$omp_theme"
'
set -e

if [ $EUID -eq 0 ]; then
printf '\e[31;1mDo not run the script as root.\e[0m\n'
exit 1
Expand Down Expand Up @@ -48,7 +50,7 @@ pushd "$(cd "${SCRIPT_ROOT}/../../" && pwd)" >/dev/null
distro_check=$(.assets/provision/distro_check.sh array)

# initialize the scopes array
array=($scope)
read -ra array <<<"$scope"
# populate the scopes array based on the output of distro_check.sh
while IFS= read -r line; do
array+=("$line")
Expand Down Expand Up @@ -98,7 +100,7 @@ done
# get distro name from os-release
. /etc/os-release
# display distro name and scopes to install
printf "\e[95m$NAME$([ -n "$scope_arr" ] && echo " : \e[3m${scope_arr[*]}" || true)\e[0m\n"
printf "\e[95m$NAME$([ "${#scope_arr[@]}" -gt 0 ] && echo " : \e[3m${scope_arr[*]}" || true)\e[0m\n"

# *Install packages and setup profiles
if [ "$sys_upgrade" = true ]; then
Expand Down Expand Up @@ -249,7 +251,7 @@ printf "\e[96msetting up profile for current user...\e[0m\n"
# install powershell modules
if [ -f /usr/bin/pwsh ]; then
cmnd="Import-Module (Resolve-Path './modules/InstallUtils'); Invoke-GhRepoClone -OrgRepo 'szymonos/ps-modules'"
cloned=$(pwsh -nop -c $cmnd)
cloned=$(pwsh -nop -c "$cmnd")
if [ $cloned -gt 0 ]; then
printf "\e[96minstalling ps-modules...\e[0m\n"
# install do-common module for all users
Expand Down
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[Makefile]
indent_size = 2
indent_style = tab
Loading