From c766602cc342a07a67afcd55c871479f7de4a21e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Wed, 27 Mar 2024 10:16:19 +0100 Subject: [PATCH 1/5] fix fixtoken function --- aliases | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aliases b/aliases index d20a23a..a1499ff 100644 --- a/aliases +++ b/aliases @@ -8,7 +8,7 @@ alias apv="ansible-playbook --ask-vault-pass" alias fuck='sudo $(history -p \!\!)' alias wosis='which $(history -p \!\!)' alias fix='reset; stty sane; tput rs1; clear; echo -e "\033c"' # Fix terminal aber binary output -alias fixbmi='ssh -Oexit svras' # Fix terminal aber binary output +alias fixbmi='fixtoken; ssh -Oexit svras' # Fix terminal aber binary output alias fixtoken='sudo systemctl restart pcscd.service' # Fix terminal aber binary output # Source https://www.digitalocean.com/community/tutorials/how-to-use-bash-history-commands-and-expansions-on-a-linux-vps alias vilastcatfile='vim $(history -p \!cat:$:t)' From 53bdc127e8ef069e900c064948df9d7a42a30b02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Thu, 7 Mar 2024 17:14:24 +0100 Subject: [PATCH 2/5] fix function to get ips and hostnames from net --- functions.sh | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/functions.sh b/functions.sh index 76b86e7..44e2b0e 100755 --- a/functions.sh +++ b/functions.sh @@ -1104,7 +1104,7 @@ getfreeip () { local N=$1 - sudo nmap -v -sn -n $1 -oG - | awk '/Status: Down/{print $2}' + nmap -v -sn -n ${N} -oG - | awk '/Status: Down/{print $2}' } @@ -1113,13 +1113,31 @@ getusedip () { local N=$1 local DNS=$2 - sudo nmap -v -sn -n $1 -oG - | awk '!/Status: Down/{print $2}'|while read i;do - echo "$i: $(dig "${DNS:+@}${DNS}" -x $i +short +search)" - + nmap -v -sn -n $1 -oG - | awk '!/Status: Down/{print $2}'|while read i;do + echo "$i: $(dig ${DNS:+@}${DNS:-} -x $i +short +search)" done } +getips () { + + local N=$1 + local DNS=$2 + + nmap -v -sn -n $1 -oG - | while read i + do + j=$(echo "$i"|awk '{print $2}') + case $i in + *Status:\ Down*) + echo "$j: $(dig ${DNS:+@}${DNS:-} -x $j +short +search)" + ;; + *Status:\ Up*) + echo "$j:" + ;; + esac + done +} + function getdbcreds_jra () { local APP_INST=/opt/atlassian/jira local JRA_HOME=$(awk -F "=" '/jira.home/ {gsub(/ /, "", $0); print $2}' "${APP_INST}/atlassian-jira/WEB-INF/classes/jira-application.properties") From 74a9180dc60506687af61a0bc1ed74658525a7e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Wed, 17 Apr 2024 16:25:41 +0200 Subject: [PATCH 3/5] fix goarchive --- functions.sh | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/functions.sh b/functions.sh index 44e2b0e..9d8cef9 100755 --- a/functions.sh +++ b/functions.sh @@ -1429,8 +1429,9 @@ EOF } function goarchive () { + local SHOPTEXTGLOB="$(shopt -p |grep extglob)" shopt -s extglob - if [ "{#:-0}" -gt 0 ] + if [ "${#:-0}" -gt 0 ] then case "$1" in -h) @@ -1462,23 +1463,8 @@ EOF else [ -e "$(xdg-user-dir ARCHIVE)" ] && cd "$(xdg-user-dir ARCHIVE)" fi - shopt -u extglob -} - -checkkernel () { -for i in /vmlinuz /boot/vmlinuz -do - [ -e "${i}" ] || continue - if [ $(basename $(readlink -f "${i}")) = vmlinuz-$(uname -r) ] - then - printf "%s\n" "Kein Upgrade notwendig. Kernel aktuell" - else - printf "%s\n" "Reboot notwendig!!" - res=1 - fi - return ${res:-0} -done - +# shopt -u extglob + eval $SHOPTEXTGLOB } #EOF From 4dc5a8455113814ca5e3d64c1ad3a37d64a9a1d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Tue, 27 Aug 2024 15:36:25 +0200 Subject: [PATCH 4/5] add autocompletion for bw bitwarden cli does not give autocompletion for bash, so add it. Source is https://github.com/bitwarden/cli/issues/307 --- bash_completion.d/bw | 284 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 284 insertions(+) create mode 100644 bash_completion.d/bw diff --git a/bash_completion.d/bw b/bash_completion.d/bw new file mode 100644 index 0000000..b48bfbc --- /dev/null +++ b/bash_completion.d/bw @@ -0,0 +1,284 @@ +#!/usr/bin/env bash + +# Return if not interactive +[[ $- != *i* ]] && return + +# Base options for bw +__BW_BASE_OPTS=" + --pretty + --raw + --response + --quiet + --nointeraction + --session + -v --version + -h --help +" +# Base commands for bw +__BW_BASE_COMMANDS=" + login logout lock + unlock sync generate + encode config update + completion status list + get create edit + delete restore share + confirm import export + send receive help +" +# Generic help options for simple commands +__BW_HELP_OPTS=" + -h --help +" +# Options for bw login +__BW_LOGIN_OPTS=" + --method + --code + --sso + --apikey + --passwordenv + --passwordfile + --check + -h --help +" +# Options for bw unlock +__BW_UNLOCK_OPTS=" + --raw + --check + -h --help +" +# Options for bw sync +__BW_SYNC_OPTS=" + -f --force + --last + -h --help +" +# Options for bw generate +__BW_GENERATE_OPTS=" + -u --uppercase + -l --lowercase + -n --number + -s --special + -p --passphrase + --length + --words + --separator + -h --help +" +# Options for bw config +__BW_CONFIG_OPTS=" + --web-vault + --api + --identity + --icons + --notifications + --events + -h --help +" +# Objects for bw config +__BW_CONFIG_OBJECTS=" + server +" +# Options for bw update +__BW_UPDATE_OPTS=" + --raw + -h --help +" +# Options for bw list +__BW_LIST_OPTS=" + --search + --url + --folderid + --collectionid + --organizationid + --trash + -h --help +" +# Objects for bw list +__BW_LIST_OBJECTS=" + items folders collections + organizations org-collections + org-members +" +# Options for bw get +__BW_GET_OPTS=" + --itemid + --output + --organizationid + -h --help +" +# Objects for bw get +__BW_GET_OBJECTS=" + item username password + uri totp exposed + attachment folder collection + org-collection organization template + fingerprint send email +" +# Options for bw create +__BW_CREATE_OPTS=" + --file + --itemid + --organizationid + -h --help +" +# Objects for bw create +__BW_CREATE_OBJECTS=" + item attachment folder + org-collection +" +# Options for bw edit +__BW_EDIT_OPTS=" + --organizationid + -h --help +" +# Objects for bw edit +__BW_EDIT_OBJECTS=" + item item-collections + folder org-collection +" +# Options for bw delete +__BW_DELETE_OPTS=" + --itemid + --organizationid + -p --permanent + -h --help +" +# Objects for bw delete +__BW_DELETE_OBJECTS=" + item attachment folder + org-collection +" +# Objects for bw restore +__BW_RESTORE_OBJECTS=" + item +" +# Options for bw confirm +__BW_CONFIRM_OPTS=" + --organizationid + -h --help +" +# Objects for bw confirm +__BW_CONFIRM_OBJECTS=" + org-member +" +# Options for bw import +__BW_IMPORT_OPTS=" + --formats + -h --help +" +# Options for bw export +__BW_EXPORT_OPTS=" + --output + --format + --raw + --organizationid + -h --help +" +# Options for bw send +__BW_SEND_OPTS=" + -f --file + -d --deleteInDays + --hidden + -n --name + --notes + --fullObject + -h --help +" +# Objects for bw send +__BW_SEND_OBJECTS=" + list template get + receive create edit + remove-password delete +" +# Options for bw receive +__BW_RECEIVE_OPTS=" + --password + --passwordenv + --passwordfile + --obj + --output + -h --help +" + +__bw_generic_completion() { + local cur + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + + if [[ "${COMP_WORDS[COMP_CWORD]}" =~ ^- ]]; then + COMPREPLY=($(compgen -W "$1" -- "$cur")) + return 0 + else + COMPREPLY=($(compgen -W "$2" -- "$cur")) + return 0 + fi +} + +__bw_completion() { + local prev + prev="${COMP_WORDS[COMP_CWORD - 1]}" + + case "$prev" in + login) + __bw_generic_completion "$__BW_LOGIN_OPTS" "" + ;; + logout | lock | encode | status | share) + __bw_generic_completion "$__BW_HELP_OPTS" "" + ;; + unlock) + __bw_generic_completion "$__BW_UNLOCK_OPTS" "" + ;; + sync) + __bw_generic_completion "$__BW_SYNC_OPTS" "" + ;; + generate) + __bw_generic_completion "$__BW_GENERATE_OPTS" "" + ;; + config) + __bw_generic_completion "$__BW_CONFIG_OPTS" "$__BW_CONFIG_OBJECTS" + ;; + update) + __bw_generic_completion "$__BW_UPDATE_OPTS" "" + ;; + list) + __bw_generic_completion "$__BW_LIST_OPTS" "$__BW_LIST_OBJECTS" + ;; + get) + __bw_generic_completion "$__BW_GET_OPTS" "$__BW_GET_OBJECTS" + ;; + create) + __bw_generic_completion "$__BW_CREATE_OPTS" "$__BW_CREATE_OBJECTS" + ;; + edit) + __bw_generic_completion "$__BW_EDIT_OPTS" "$__BW_EDIT_OBJECTS" + ;; + delete) + __bw_generic_completion "$__BW_DELETE_OPTS" "$__BW_DELETE_OBJECTS" + ;; + restore) + __bw_generic_completion "$__BW_HELP_OPTS" "$__BW_RESTORE_OBJECTS" + ;; + confirm) + __bw_generic_completion "$__BW_CONFIRM_OPTS" "$__BW_CONFIRM_OBJECTS" + ;; + import) + __bw_generic_completion "$__BW_IMPORT_OPTS" "" + ;; + export) + __bw_generic_completion "$__BW_EXPORT_OPTS" "" + ;; + send) + __bw_generic_completion "$__BW_SEND_OPTS" "$__BW_SEND_OBJECTS" + ;; + receive) + __bw_generic_completion "$__BW_RECEIVE_OPTS" "" + ;; + bw) + __bw_generic_completion "$__BW_BASE_OPTS" "$__BW_BASE_COMMANDS" + ;; + *) + __bw_generic_completion "" + esac +} + +complete -o default -F __bw_completion bw From 9f5d4fa402d48d9e020e6206cf2561acd7c9dade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Fri, 13 Sep 2024 16:23:44 +0200 Subject: [PATCH 5/5] add bitwarden-cli alias --- aliases | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aliases b/aliases index a1499ff..e988bf3 100644 --- a/aliases +++ b/aliases @@ -244,3 +244,5 @@ alias viserverxml='vi conf/server.xml' alias kxxx='killall gthumb ; uencfs /run/user/2000/decrypted/XXX ' +# Bitwarden +alias bwunlock='eval $(bw unlock|grep export|sed "s/^\$ //")'