add scripts and append to PATH

This commit is contained in:
Michael Grote 2024-01-25 09:53:09 +01:00
parent 3f22f67fc1
commit 9bd50408b0
10 changed files with 302 additions and 0 deletions

View File

@ -12,6 +12,10 @@ fi
eval "$(keychain -q --eval --timeout 60 --agents ssh,gpg)"
export GPG_TTY=$(tty)
### PATH
# add my scripts to PATH
PATH=$PATH:~/home/mg/dotfiles/scripts
### PS1
# Farben
BLUE='\[\e[34m\]'

185
scripts/countdown.sh Normal file
View File

@ -0,0 +1,185 @@
#!/bin/bash
# geklaut vom linuxhotel.de
LANG=C
export BUILD="2.9.64"
set -o nounset
function banner()
{
local -A b
local -i l
local -i i
b[00]=' 000'
b[01]=' 0 0'
b[02]='0 0 0'
b[03]='0 0 0'
b[04]='0 0 0'
b[05]=' 0 0'
b[06]=' 000'
b[07]=''
b[10]=' 1'
b[11]=' 11'
b[12]=' 1 1'
b[13]=' 1'
b[14]=' 1'
b[15]=' 1'
b[16]=' 11111'
b[17]=''
b[20]=' 22222'
b[21]='2 2'
b[22]=' 2'
b[23]=' 22222'
b[24]='2'
b[25]='2'
b[26]='2222222'
b[27]=''
b[30]=' 33333'
b[31]='3 3'
b[32]=' 3'
b[33]=' 33333'
b[34]=' 3'
b[35]='3 3'
b[36]=' 33333'
b[37]=''
b[40]='4'
b[41]='4 4'
b[42]='4 4'
b[43]='4444444'
b[44]=' 4'
b[45]=' 4'
b[46]=' 4'
b[47]=''
b[50]='5555555'
b[51]='5'
b[52]='5'
b[53]=' 55555'
b[54]=' 5'
b[55]='5 5'
b[56]=' 55555'
b[57]=''
b[60]=' 66666'
b[61]='6 6'
b[62]='6'
b[63]='666666'
b[64]='6 6'
b[65]='6 6'
b[66]=' 66666'
b[67]=''
b[70]='7777777'
b[71]='7 7'
b[72]=' 7'
b[73]=' 7'
b[74]=' 7'
b[75]=' 7'
b[76]=' 7'
b[77]=''
b[80]=' 88888'
b[81]='8 8'
b[82]='8 8'
b[83]=' 88888'
b[84]='8 8'
b[85]='8 8'
b[86]=' 88888'
b[87]=''
b[90]=' 99999'
b[91]='9 9'
b[92]='9 9'
b[93]=' 999999'
b[94]=' 9'
b[95]='9 9'
b[96]=' 99999'
b[97]=''
b[:0]=' :'
b[:1]=' :::'
b[:2]=' :'
b[:3]=''
b[:4]=' :'
b[:5]=' :::'
b[:6]=' :'
b[:7]=''
for ((l=0;l<8;l++)); do
for ((i=0;i<${#1};i++)); do
printf "%-8.8s" "${b[${1:i:1}$l]}"
done
echo
done
}
function usage()
{
local base="$(basename $0)"
echo "Build: $BUILD"
echo "Usage: $base HH:MM" >&2
echo " $base +minutes" >&2
echo " $base +0" >&2
}
if [ $# -ne 1 ]; then
usage
exit 1
elif [[ $1 =~ ^([01][0-9]|2[0-3]):[0-5][0-9]$ ]]; then
dateHHMMSS="${1}:00"
elif [[ $1 =~ ^\+[0-9]+ ]]; then
dateHHMMSS=$(date -d "now $1 minutes" +%H:%M:%S)
else
usage
exit 2
fi
clear
declare -i diff
declare -i initDiff=$(($(date -d "$dateHHMMSS" +%s)-$(date +%s)))
((initDiff == 0)) && initDiff=1
declare -i lenOutDate
declare -i lenOutTime
declare outDate
declare outTime
declare -r spaces=" "
declare -r pegel="#####################################"
declare -ri lenPegel=${#pegel}
declare -ri lenSpaces=${#spaces}
declare -i posPegel
declare -i pad
while true; do
key=""
diff=$(($(date -d "$dateHHMMSS" +%s)-$(date +%s)))
outDate=$(date +"%Y-%m-%d %H:%M:%S")
outTime="${dateHHMMSS} (${diff})"
lenOutDate=${#outDate}
lenOutTime=${#outTime}
tput home
pad=$((lenSpaces-lenOutDate))
echo "${spaces:0:$((pad/2))}${outDate}${spaces:0:$((pad/2))} "
pad=$((lenSpaces-lenOutTime))
echo -e "${spaces:0:$((pad/2))}${outTime}${spaces:0:$((pad/2))} "
posPegel=$((($initDiff-$diff)*$lenPegel/$initDiff))
if (($diff >= 0 )); then
echo "[${pegel:0:$posPegel}${spaces:$((posPegel+2))}]"
else
echo "$spaces"
fi
if (( $diff == 0 )); then
tput setaf 0
elif (( $diff < 0 )); then
((diff=-diff))
tput setaf 1
elif (( $diff < 60 )); then
tput setaf 4
else
tput setaf 2
fi
echo
banner $(date -d @$diff +%M:%S)
tput setaf 0
echo -ne "\r \r" &&
read -s -t 1 -n 1 && read -s -t 3 -n 1 -p "sure? (-/n) " key && [ "$key" != "n" ] && break
done
echo -en "\r"

View File

@ -0,0 +1,2 @@
#!/bin/bash
git branch | grep -v "*" | grep -v master | grep -v main | xargs git branch -D ; git fetch --prune

41
scripts/git_pull_all.sh Normal file
View File

@ -0,0 +1,41 @@
#!/bin/bash
# Update all git directories below current directory or specified directory
# Skips directories that contain a file called .ignore
HIGHLIGHT="\e[01;34m"
NORMAL='\e[00m'
function update {
local d="$1"
if [ -d "$d" ]; then
if [ -e "$d/.ignore" ]; then
echo -e "\n${HIGHLIGHT}Ignoring $d${NORMAL}"
else
cd $d > /dev/null
if [ -d ".git" ]; then
echo -e "\n${HIGHLIGHT}Updating pwd$NORMAL"
git add .
git stash
git pull
else
scan *
fi
cd .. > /dev/null
fi
fi
#echo "Exiting update: pwd=pwd"
}
function scan {
#echo "pwd"
for x in $*; do
update "$x"
done
}
if [ "$1" != "" ]; then cd $1 > /dev/null; fi
echo -e "${HIGHLIGHT}Scanning ${PWD}${NORMAL}"
scan *

View File

@ -0,0 +1,28 @@
#!/bin/bash
# Function to ask for confirmation
ask_confirmation() {
read -rp "Are you sure you want to proceed? (y/n): " response
case "$response" in
[yY][eE][sS]|[yY])
return 0 ;; # Proceed
*)
return 1 ;; # Cancel
esac
}
if ask_confirmation; then
echo "Proceeding..."
echo "docker system prune"
docker system prune -a
echo "Entferne inaktive Container"
docker container prune
echo "Entferne ungenutzte Images"
docker image prune
echo "Entferne inaktive Volumes"
docker volume prune
echo "Entferne inaktive Netzwerke"
docker network prune | docker images -q | xargs docker rmi
else
echo "Cancelled."
fi

View File

@ -0,0 +1,18 @@
#!/bin/bash
tmpfile=$(mktemp)
cat << EOF
kind: Secret
apiVersion: v1
metadata:
name: NAME_DES_SECRETS
namespace: drone
stringData:
ICH_BIN_DER VARIABLEN_NAME: ICH_BIN_DAS_PASSWORT
EOF > $tmpfile
vim $tmpfile
cat $tmpfile | kubeseal --controller-namespace kube-system --format yaml > ./sealed-secret.yaml
cat sealed-secret.yaml
rm $tmpfile ./sealed-secret.yaml

View File

@ -0,0 +1,8 @@
#!/bin/bash
if [[ "$#" -eq 2 ]]; then
kubectl get secret $1 -n $2 -o jsonpath="{.data.<key>}" | base64 --decode ; echo""
else
echo "Missing:
\$1 = secretname
\$2 = namespace"
fi

View File

@ -0,0 +1,8 @@
#!/bin/bash
echo ">>> write key to ./main.key"
kubectl get secret -n kube-system -l sealedsecrets.bitnami.com/sealed-secrets-key -o yaml > main.key
# https://github.com/bitnami-labs/sealed-secrets#how-can-i-do-a-backup-of-my-sealedsecrets
# restore with:
# kubectl apply -f main.key
# kubectl delete pod -n kube-system -l name=sealed-secrets-controller

View File

@ -0,0 +1,6 @@
#!/bin/bash
# Zeigt die Farben mit Beschriftung an
for (( i = 30; i < 38; i++ )); do
echo -e "\033[0;"$i"m Normal: (0;$i); \033[1;"$i"m Light: (1;$i)";
done

2
scripts/zfs_get_holds.sh Normal file
View File

@ -0,0 +1,2 @@
#!/bin/bash
zfs get -Ht snapshot userrefs | grep -v $'\t'0 | cut -d $'\t' -f 1 | tr '\n' '\0' | xargs -0 zfs holds