From 750b42f7cf53d8810d156cb8a3096d3168da66d6 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Tue, 7 Nov 2023 10:58:02 +0100 Subject: [PATCH] bin: new script versions --- .config/bash/aliases.bash | 2 ++ .config/bash/iridion.bash | 18 ++++++++++++++---- .config/shell/functions | 7 ++++--- .config/topgrade.d/topgrade.toml | 4 ++-- .local/bin/scripts/clean | 2 +- .local/bin/scripts/git-origin | 4 ++-- .local/bin/scripts/s | 4 ++-- 7 files changed, 27 insertions(+), 14 deletions(-) diff --git a/.config/bash/aliases.bash b/.config/bash/aliases.bash index 8b400f6..5d8424a 100644 --- a/.config/bash/aliases.bash +++ b/.config/bash/aliases.bash @@ -1,5 +1,7 @@ test -n "$PS1" || return 0 +which pfetch >/dev/null 2>&1 && pfetch + test $(id -u) -eq 0 || sudo=sudo alias jc="$sudo journalctl --boot --unit" diff --git a/.config/bash/iridion.bash b/.config/bash/iridion.bash index 99e012f..0b4c810 100644 --- a/.config/bash/iridion.bash +++ b/.config/bash/iridion.bash @@ -13,11 +13,18 @@ letsencrypt() { ip=$(localip) IFS=$'\n' for user - do for domain in $(hestia v-list-web-domains $user | grep $ip | awk '{print $1}') - do #echo commented out due to command echoing in hestia alias + do + for domain in $(hestia v-list-dns-domains $user | tail +3 | awk '{print $1}') + do hestia v-add-remote-dns-domain $user $domain + done + for domain in $(hestia v-list-mail-domains $user | tail +3 | awk '{print $1}') + do hestia v-list-mail-domain-ssl $user $domain | grep -q . || hestia v-add-letsencrypt-domain $user $domain '' yes + done + for domain in $(hestia v-list-web-domains $user | grep $ip | awk '{print $1}') + do #echo commented out due to command echoing in hestia alias #echo "Checking $user $domain" >&2 hestia v-list-web-domain $user $domain | grep -q REDIRECT && continue - hestia v-list-mail-domain-ssl $user $domain | grep -q . || hestia v-add-letsencrypt-domain $user $domain '' yes + #hestia v-list-mail-domain-ssl $user $domain | grep -q . || hestia v-add-letsencrypt-domain $user $domain '' yes hestia v-list-web-domain-ssl $user $domain | grep -q . && continue #echo "Generating Certificate" >&2 hestia v-add-letsencrypt-domain $user $domain $(hestia v-list-web-domain $user $domain | grep ALIAS | tr -s ' ' | cut -d' ' -f2- | tr ' ' ',') @@ -46,10 +53,13 @@ list() { hestia() { test $# -eq 0 && cd "$HESTIA" && return 0 + test "$1" = "-x" && shift && set -x command=$1 shift echo '>' sudo $(which $command) "$@" >&2 - sudo timeout 30s $(which $command) "$@" + export SHELLOPTS + sudo --preserve-env=SHELLOPTS timeout 30s $(which $command) "$@" + set +x } accessible() { diff --git a/.config/shell/functions b/.config/shell/functions index 5b3c060..578f092 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -329,9 +329,9 @@ sshl() { ssh -G "$1" | grep --silent "^user root$" && ! [[ "$1" =~ "pve.*" ]] && ! [[ "$1" =~ "encee.*" ]] && - ! [[ "$1" =~ ".*ofc.*" ]] && - ! [[ "$1" =~ "delta*" ]] && ! [[ "$1" =~ "tmtgw" ]] && + ! [[ "$1" =~ "delta*" ]] && + ! [[ "$1" =~ "nc-*" ]] && local pass=pass test "$all" && find $XDG_CONFIG_HOME/bash/ \( -name aliases.bash -o -name "${1%[0-9a-z]}*.bash" \) -exec cat {} + | $pass ssh "$1" 'cat > .bash_aliases && grep -q .bash_aliases .bashrc || echo "source ~/.bash_aliases" | tee -a .bashrc' && @@ -644,12 +644,13 @@ stopswap() { } extrac() { + test "$#" -lt 1 && echo "$0 ..." && return 2 for var; do arg=${var%.lzo} out=$(basename ${arg%.vma}) lzop -x $arg.lzo vma.py $arg $out || vma.py $(basename $arg) $out && - ( cd $out && find *.raw -exec qemu-img convert {} -O qcow2 $out-{}.qcow2 \; ) + ( cd $out && find drive-* -exec qemu-img convert {} -O qcow2 $out-{}.qcow2 \; ) done } diff --git a/.config/topgrade.d/topgrade.toml b/.config/topgrade.d/topgrade.toml index 2499c49..3103edc 100644 --- a/.config/topgrade.d/topgrade.toml +++ b/.config/topgrade.d/topgrade.toml @@ -40,7 +40,7 @@ repos = [ #pull_predefined = false # Arguments to pass Git when pulling Repositories -arguments = "--rebase --autostash --recurse-submodules" +pull_arguments = "--rebase --autostash --recurse-submodules" [composer] #self_update = false @@ -58,7 +58,7 @@ arguments = "--rebase --autostash --recurse-submodules" [linux] # Arguments to pass yay when updating packages -yay_arguments = "--nodiffmenu --overwrite '/usr/lib/node_modules/npm/**' --overwrite '/usr/lib/*' --ignore android-studio --ignore clion --ignore intellij-idea-ultimate-edition --ignore intellij-idea-ultimate-edition-jre --ignore webstorm --ignore linux --ignore stretchly-xeruf-git" +yay_arguments = "--nodiffmenu --overwrite '/usr/lib/node_modules/node-gyp/**' --overwrite '/usr/lib/node_modules/npm/**' --overwrite '/usr/lib/*' --ignore android-studio --ignore clion --ignore intellij-idea-ultimate-edition --ignore intellij-idea-ultimate-edition-jre --ignore webstorm --ignore linux --ignore stretchly-xeruf-git" #trizen_arguments = "--devel" #enable_tlmgr = true #emerge_sync_flags = "-q" diff --git a/.local/bin/scripts/clean b/.local/bin/scripts/clean index 0d55fb5..389a32a 100755 --- a/.local/bin/scripts/clean +++ b/.local/bin/scripts/clean @@ -5,7 +5,7 @@ typeset -A _clean_map _clean_map=([h]=$XDG_CACHE_HOME [t]=/var/tmp [l]=/var/log [v]=/var/cache) # TODO .mix - outdated version in socha -_clean_home=(.ant .autopsy .bundle .cargo .cpanm .docker .stack .hex .nix-defexpr .parallel .surf +_clean_home=(.ant .autopsy .bundle .cargo .cpanm .docker .stack .hex .nix-defexpr .parallel .surf .pub-cache #.cache .yarn .node_modules .npm .pnpm-store .node-gyp .nv .electron .electron-gyp .gradle .gradle-kotlin-dsl .java .kscript .konan .m2 .openjfx diff --git a/.local/bin/scripts/git-origin b/.local/bin/scripts/git-origin index 1c7d946..eda6c93 100755 --- a/.local/bin/scripts/git-origin +++ b/.local/bin/scripts/git-origin @@ -5,8 +5,8 @@ git remote $(case "$(git remote)" in (*"$remote"*) echo set-url;; (*) echo add;; esac) "$remote" "$(git-repo "$@")" -git remote -v && git fetch +git remote -v && git fetch --all git branch --format='%(refname:short)' | while read branch -do test $(git branch -a | grep $remote/$branch | wc -l) -gt 0 && git branch -u $remote/$branch $branch +do test $(git branch --all | grep "$remote/$branch" | wc -l) -gt 0 && git branch -u "$remote/$branch" "$branch" done diff --git a/.local/bin/scripts/s b/.local/bin/scripts/s index 3fa0e3a..e2fb162 100755 --- a/.local/bin/scripts/s +++ b/.local/bin/scripts/s @@ -2,8 +2,8 @@ # shows size statistics for subfolders # max depth is equal to the first argument if it is a number or 1 export chars=$(expr $(tput cols) - 60) -case "$1" in (+*) size=${1#+}; depth=2; shift;; esac +case "$1" in (+*) size=${1#+}G; depth=2; shift;; esac case "$1" in ([0-9]) depth=$1; shift;; esac -(du --max-depth "${depth:-1}" -xhat ${size:-50}M "$@" | sort -h | grep -v "^0") | +(du --max-depth "${depth:-1}" -xhat ${size:-500M} "$@" | sort -h | grep -v "^0") | while read line; do echo "$(tput smso)$line$(tput rmso) $(pacman -Qqo $(echo $line | awk '{print $2}') 2>/dev/null | paste -s -d',' | sed "s/\(.\{${chars}\}\).*/\1.../")"; done || #| column -t || (du --max-depth "${depth:-1}" -xha "$@" | sort -h | tail)