Compare commits

...

2 Commits

Author SHA1 Message Date
xeruf 109db5cebb config/shell: script adjustments 2024-09-15 17:42:56 +03:00
xeruf 2437dce296 config/bash: move pve aliases 2024-09-15 17:40:45 +03:00
19 changed files with 90 additions and 34 deletions

View File

@ -1,7 +1,7 @@
set -o pipefail set -o pipefail
alias localip="ip addr show | grep -E '(ens|eth)' | grep -oP '"'(?<=inet\s)\d+(\.\d+){3}'"' | head -1" alias localip="ip addr show | grep -E '(ens|eth)' | grep -oP '"'(?<=inet\s)\d+(\.\d+){3}'"' | head -1"
ip=$(localip) ip=`localip`
logs() { logs() {
if test $# -eq 0 if test $# -eq 0
@ -64,6 +64,7 @@ letsencrypt() {
hestia v-list-web-domain-ssl $user $domain | grep . >/dev/null && continue hestia v-list-web-domain-ssl $user $domain | grep . >/dev/null && continue
#echo "Generating Certificate" >&2 #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 ' ' ',') hestia v-add-letsencrypt-domain $user $domain $(hestia v-list-web-domain $user $domain | grep ALIAS | tr -s ' ' | cut -d' ' -f2- | tr ' ' ',')
echo "$domain: ${?}"
done done
echo "Waiting an hour to not trigger letsencrypt rate limits..." echo "Waiting an hour to not trigger letsencrypt rate limits..."
time=0 time=0

17
.config/bash/na.bash Normal file
View File

@ -0,0 +1,17 @@
[[ $- == *i* ]] && zfs list -d 0
alias cluster='scr corosync && scr pvesr'
qcow() { qemu-img convert $1 -O qcow2 ${2:-$1}.qcow2; }
extrac() {
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 drive-* -exec qemu-img convert {} -O qcow2 $out-{}.qcow2 \;
)
#vma extract $arg $out &&
#( cd $out && find *.raw -exec qemu-img convert {} -O qcow2 $arg-{}.qcow2 \; )
done
}

1
.config/bash/nas.bash Symbolic link
View File

@ -0,0 +1 @@
../shell/server

View File

@ -1,14 +0,0 @@
[[ $- == *i* ]] && zfs list -d 0
alias cluster='scr corosync && scr pvesr'
qcow() { qemu-img convert $1 -O qcow2 ${2:-$1}.qcow2; }
extrac() {
for var; do
arg=${var%.lzo}
out=$(basename ${arg%.vma})
lzop -x $arg.lzo
vma extract $arg $out &&
( cd $out && find *.raw -exec qemu-img convert {} -O qcow2 $arg-{}.qcow2 \; )
done
}

View File

@ -45,8 +45,8 @@ yas() {
) )
if test -n "$pkg" if test -n "$pkg"
then echo "Installing $pkg..." then echo "Installing $pkg..."
cmd="yay -Sy --batchinstall --rebuildall $pkg" cmd="yay -S --batchinstall --rebuildall $pkg"
print -s "$cmd" print -s $cmd
eval "$cmd" eval "$cmd"
rehash rehash
fi fi

View File

@ -272,9 +272,10 @@ curlh() {
unalias u 2>/dev/null # for bash unalias u 2>/dev/null # for bash
u() { u() {
# Line below handy for users of netkeeper # Line below handy for users of netkeeper internet blocker
#sudo nft list ruleset | grep -q outall && echo "Suspending netkeeper" >&2 | echo 'pausing netkeeper for sysupgrade' | netkeeper 30 2>/dev/null #sudo nft list ruleset | grep -q outall && echo "Suspending netkeeper" >&2 | echo 'pausing netkeeper for sysupgrade' | netkeeper 30 2>/dev/null
if command -v pacman >/dev/null; then if command -v pacman >/dev/null; then
sudo find /var/lib/pacman/db.lck -mmin +600 -delete 2>/dev/null && echo 'Deleted stale pacman db.lock'
if test "$(stat /etc/pacman.d/mirrorlist --printf=%y | cut -d'-' -f1-2)" != "$(date +%Y-%m)" if test "$(stat /etc/pacman.d/mirrorlist --printf=%y | cut -d'-' -f1-2)" != "$(date +%Y-%m)"
then then
# TODO also run if location changed significantly or mirror is slow # TODO also run if location changed significantly or mirror is slow

View File

@ -50,6 +50,7 @@ fileinfo() {
# I think this check is here to avoid scrolling text interpreted as video # I think this check is here to avoid scrolling text interpreted as video
#probe="$($elevate ffprobe "$arg" 2>&1)" #probe="$($elevate ffprobe "$arg" 2>&1)"
#echo $probe | grep -v -e '00:00:00.04' -e 'ansi' && #echo $probe | grep -v -e '00:00:00.04' -e 'ansi' &&
# Omit short videos: test $(printf "%.0f" $(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$file")) -gt 4
# Print media infos over file infos when <2G # Print media infos over file infos when <2G
if ! { test "$size" -lt 2000000000 && $elevate ffprobe -hide_banner "$arg" 2>&1 | grep -E "bitrate: .{3,5} " | sed 's/, start:[^,]\+,/,/'; } || $inspect if ! { test "$size" -lt 2000000000 && $elevate ffprobe -hide_banner "$arg" 2>&1 | grep -E "bitrate: .{3,5} " | sed 's/, start:[^,]\+,/,/'; } || $inspect
then $elevate stat --format "%U:%G %A %s $( then $elevate stat --format "%U:%G %A %s $(

View File

@ -16,10 +16,10 @@ if ! test "$command"; then
(*sqlite*) sqldiff --summary "${files[@]}" | grep -v '0 changes, 0 inserts, 0 deletes';; # TODO syntax highlighting for INSERT/UPDATE/DELETE (*sqlite*) sqldiff --summary "${files[@]}" | grep -v '0 changes, 0 inserts, 0 deletes';; # TODO syntax highlighting for INSERT/UPDATE/DELETE
(text/*) (text/*)
# Use wiked-diff only for text <100KB # Use wiked-diff only for text <100KB
if test 100000 -gt "$(stat --format=%s "${files[@]}" | paste -s -d'+' | bc)" test 100000 -gt "$(stat --format=%s "${files[@]}" | paste -s -d'+' | bc)" &&
then wiked-diff "${files[@]}" wiked-diff "${files[@]}" ||
else diff --color=always --unified=1 --report-identical-files "${files[@]}" diff --color=always --unified=1 --report-identical-files "${files[@]}"
fi;; ;;
(*) diff-color --report-identical-files "${files[@]}";; (*) diff-color --report-identical-files "${files[@]}";;
esac esac
fi fi

View File

@ -11,18 +11,20 @@ highlight() { echo "$1"; }
highlight "Checking SMART with hdparm" highlight "Checking SMART with hdparm"
# Needs sudo for read test # Needs sudo for read test
sudo hdparm -MWAgt "$disk" sudo hdparm -MWAgt "$disk" || true
if test $# -eq 0 if test $# -eq 0
then highlight "Write Test" then highlight "Write Test"
sync sync
count=100$(test $(df --output="avail" . | tail -1) -gt 999999 && echo 0 || true) count=3000$(test $(df --output="avail" . | tail -1) -gt 999999 && echo 0 || true)
# This prevents predictions by using random, but since that is too slow we have to copy a previously created file tempfile=/var/tmp/.$count
highlight "Preparing random bits:" && # Prevent deduplication/predictions by using random rather than zero, but since that is too slow we have to copy a previously created file
sudo dd status=progress if=/dev/random of=/var/tmp/tempfile bs=1M count=$count && test -s $tempfile ||
( highlight "Preparing random bits:" &&
sudo dd status=progress if=/dev/urandom of=$tempfile bs=1M count=$count ) &&
highlight "Copying random bits:" && highlight "Copying random bits:" &&
sudo dd status=progress if=/var/tmp/tempfile of=tempfile bs=1M count=$count sudo dd status=progress if=$tempfile of=.$count bs=1M count=$count
highlight "Copying zero bits:" && highlight "Copying zero bits:" &&
sudo dd status=progress if=/dev/zero of=tempfile bs=1M count=$count sudo dd status=progress if=/dev/zero of=.$count bs=1M count=$count
sudo rm tempfile sudo rm .$count
fi fi

View File

@ -0,0 +1,8 @@
#!/bin/sh -e
cd "$DATA/1-projects/software-challenge/capper/gui/src/main/resources/hui/"
rm -- *
mv "$DATA/5-incubator/download"/hui_*.zip .
unzip -- *.zip
mv -- */* .
git add .
exec $SHELL

4
.local/bin/scripts/fix Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
# Fix odd processes getting stuck
systemctl --user restart espanso &
mpdr

View File

@ -2,9 +2,14 @@
# Find terms in jrnl files and turn them into tags # Find terms in jrnl files and turn them into tags
# Check with jrnl --tags # Check with jrnl --tags
if test $# -eq 0 if test $# -eq 0
then $0 sleep lens uni nap cry health tech read girl dev phone Zinc bike tour laptop computer PC piano faith CB Claudia Franklin Kerstin Henri Katja Erlangen Bayreuth Berlin ICF Joan then
set -x
$0 sleep uni nap cry tech read dev phone bike tour laptop computer piano faith health lens Zinc \
girl CB Claudia Kerstin Turi Taura \
Erlangen Bayreuth Berlin ICF
true $?
else else
for arg for arg
do rpl "\(^\|[^@/]\)\b$arg\b" "\1@$arg" $JOURNAL/*.txt 2>/dev/null do rpl "\(^\|[^@/]\)\b$arg\b" "\1@$arg" "$JOURNAL"/*.jrnl 2>/dev/null
done done
fi fi

6
.local/bin/scripts/kubeclean Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh -e
# Cleanup Inactive and Broken Pods
kubectl get pods --all-namespaces --no-headers |
egrep -iv 'PodInitializing|Running|ContainerCreating|Terminating' |
awk '{print "--namespace=" $1 " " $2}' |
xargs -L 1 kubectl delete pod

View File

@ -10,7 +10,7 @@ dir="$(dirname "$1")"
test "$(lsattr -d "$dir" 2>/dev/null | cut -c6)" = a && setappend=true test "$(lsattr -d "$dir" 2>/dev/null | cut -c6)" = a && setappend=true
test -z "$setappend" || sudo chattr -V -a "$dir" test -z "$setappend" || sudo chattr -V -a "$dir"
$elevate mkdir -p $(case "$last" in (*/) echo "$last";; (*) dirname "$last";; esac) $elevate mkdir -p "$(case "$last" in (*/) echo "$last";; (*) dirname "$last";; esac)"
$elevate mv --verbose --interactive "$@" $elevate mv --verbose --interactive "$@"
# TODO Diff when interactive # TODO Diff when interactive

View File

@ -0,0 +1,14 @@
#!/bin/sh -e
# Extract the email address from the mailto link
mailto_link="$1"
email_address="${mailto_link#mailto:}"
# Copy the extracted email address to the clipboard
echo -n "$email_address" | xclip -selection clipboard
# Optional: Notify the user
notify-send "Email address copied to clipboard" "$email_address"
# Optional: Log the copied email addresses for debugging
echo "Copied email address: $email_address" >> ~/mailto_log.txt

3
.local/bin/scripts/nv Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh -e
# Toggle NordVPN
nordvpn status | grep --color=never Disconnected && nordvpn connect de || nordvpn disconnect; nordvpn status

View File

@ -1,4 +1,5 @@
#!/bin/sh -e #!/bin/sh -e
# Put system to sleep after specified number of seconds # Put system to sleep after specified number of seconds
$(which timer || sleep) "${@:-10}" mpc pause || mpdr
$(which timer || sleep) "${@:-30}"
systemctl suspend systemctl suspend

5
.local/bin/scripts/wl-save Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh -e
# Save wl clipboard image with last copied url
file="$(date +%y%m%d-%H%M%S)_$(cliphist list | grep https:// | head -1 | rev | cut -d/ -f1 | rev).png"
wl-paste >"$file"
b "$file"

View File

@ -154,6 +154,7 @@ export CMAKE_BUILD_PARALLEL_LEVEL=${SPARE_CORES}
export CTEST_PARALLEL_LEVEL=${SPARE_CORES} export CTEST_PARALLEL_LEVEL=${SPARE_CORES}
export CTEST_PROGRESS_OUTPUT=1 export CTEST_PROGRESS_OUTPUT=1
export CTEST_OUTPUT_ON_FAILURE=1 export CTEST_OUTPUT_ON_FAILURE=1
export CARGO_BUILD_JOBS=${SPARE_CORES}
# TODO move to proper place - is also called when firenvim starts # TODO move to proper place - is also called when firenvim starts
#autolight #autolight