De Wiki Clusterlab.com.br
Ir para navegação
Ir para pesquisar
echo Profile Loaded
# _
# / \ _____ _ _ __ ___
# / _ \ |_ / | | | '__/ _ \
# / ___ \ / /| |_| | | | __/
#/_/ \_\/___|\__,_|_| \___|
#
function KEYVAULT_SECRET_SET() { if [ $# -eq 0 ] ; then echo HELP; echo $0 "SUB_ID VAULT_NAME SECRET_NAME VALUE TAG" ; else az keyvault secret set --subscription $1 --vault-name $2 --name $3 --value "$4" --tags application=5 ;fi ; }
function KEYVAULT_SECRET_SHOW() { if [ $# -eq 0 ] ; then echo HELP; echo $0 "SUB_ID VAULT_NAME " ; else az keyvault secret list --subscription $1 --vault-name $2 | jq -r ".[]|.id" | while read ID; do az keyvault secret show --id $ID | jq -r '[.name,.value,.tags.key]|@csv ';done ;fi ; }
function AZURE_GET_VM_IPS() { if [ $# -ne 2 ] ; then echo -n "NOT ENOUGHT ARGUMENTS\n$0 SUB_ID RG_NAME" ; return 1 ; fi; az vm list --subscription $1 -g $2 -d | jq -r ".[]|[ .name,.networkProfile.networkInterfaces[].id]| @csv" | while IFS=\" read VM{1..5}; do echo $VM2 $VM4;done | while read VMNAME NIC; do echo $VMNAME $(az network nic show --ids $NIC| jq -r ".ipConfigurations[].privateIpAddress") ;done ; }
function VMSS_RUN_ALL_INSTANCE() { if [ $# -ne 4 ] ; then echo -n "NOT ENOUGHT ARGUMENTS\n$0 SUB_ID RG_NAME VMSS_NAME \"COMMANDS\"" ; return 1 ; fi; az vmss list-instances --subscription $1 -g $2 -n $3 | jq -r ".[].instanceId" | while read ID; do az vmss run-command invoke --subscription $1 -g $2 -n $3 --command-id RunShellScript --instance-id $ID --scripts "$4" | jq -r ".value[].message" ; done ; }
function FIGLET() { figlet $1 | sed -e "s/^/\#/g" ; }
alias az_subscription='az account list --query "[].[name,id]" -o tsv | column -t'
alias az_on="source $HOME/Projetos/azc/bin/activate"
alias azlogin="az login --use-device-code"
alias az_location='az account list-locations --query "[].[name]" -o tsv'
# _ __ _ _
#| |/ / _| |__ ___ _ __ _ __ ___| |_ ___ ___
#| ' / | | | '_ \ / _ \ '__| '_ \ / _ \ __/ _ \/ __|
#| . \ |_| | |_) | __/ | | | | | __/ || __/\__ \
#|_|\_\__,_|_.__/ \___|_| |_| |_|\___|\__\___||___/
#
function kcfg() {
if [ $# -eq 0 ]
then
if [ "$KUBECONFIG" != "" ]
then
echo """
###
KUBECONFIG=$KUBECONFIG
###
"""
else
echo """
###
KUBECONFIG empty
###
"""
fi
ls -1tr ~/.kube/configs
else
export KUBECONFIG=$HOME/.kube/configs/$1
fi
}
function k_logs() { k -n $1 logs $(k -n $1 get pods --no-headers | c1 | head -n 1) ; }
alias k=kubectl
alias ki="k -n ingress"
alias km="k -n monitoring"
alias ks="k -n kube-system"
# __ __ _
#| \/ (_)___ ___
#| |\/| | / __|/ __|
#| | | | \__ \ (__
#|_| |_|_|___/\___|
#
function ip_range() { seq $2 $3 | while read C; do seq $4 $5 | while read D ; do echo $1.$C.$D ; done;done ; }
function testport() { retorno=$(nc -w 5 -z $1 $2 2>/dev/null; echo $? ) ; if [ $retorno -eq 0 ] ; then echo $retorno $1 $2;fi ; }
function testrange() { seq $2 $3 | while read valor; do testport $1 $valor & done ; }
function ealias() { alias $1 | awk -F \' '{print $2}' ; }
function SSHLOOP() { if [ $# -ne 1 ] ; then echo -n "NOT ENOUGHT ARGUMENTS\n$0 SERVERNAME" ; return 1 ; fi; while true; do sshpass -f ~/.ssh/senha ssh -XC -A -o ConnectTimeout=3 $1 ; sleep 1;date;done ; }
function loop() { if [ $# -ne 2 ] ; then echo -n "NOT ENOUGHT ARGUMENTS\n$0 \"commands\" seconds" ; return 1 ; fi; while true; do date; bash -c "$1"; sleep $2 ;done ; }
function get_terraform_ips() { ; find . -type f -name terraform.tfstate -exec grep -w private_ip_address {} \; | awk -F \" '{ print $4} ' | sort -u ; }
function BACKUPNOW() {
export $BACKUPPATH=PATH TO SOMEWHERE
export DATADIR=$(date +"%y%m%d")
export DATAPATH=$BACKUPPATH/$DATADIR
mkdir -p $DATAPATH
tar cf - $(ls -1a | egrep -v "^OneDrive|^.$|^..$") | \
pv -s $(ls -1a | egrep -v "^OneDrive|^.$|^..$" | \
while read obj
do
du -sk $obj 2>/dev/null
done | \
awk '{ s = s + $1} END { print s"k"}') | \
pigz -p 8 -9 | \
split -b 256m - $DATAPATH/bkp.
}
function GENPASS() {
while true
do
export PASSWORD=$(tr -dc 'A-Za-z0-9!?@#_' < /dev/urandom | head -c 16 | xargs) ;
# echo $PASSWORD
if [[ $(echo $PASSWORD | egrep "\!|@|#|_|\?" | sed -e "s/./&\n/g" | wc -l ) -ne 0 && $(echo $PASSWORD | sed -e "s/./&\n/g" | grep "[0-9]" | wc -l ) -gt 2 && $(echo $PASSWORD | sed -e "s/./&\n/g" | grep "[a-z]" | wc -l ) -gt 2 && $(echo $PASSWORD | sed -e "s/./&\n/g" | grep "[A-Z]" | wc -l ) -gt 2 ]]
then
break
fi
done
echo $PASSWORD
}
alias aA='tr "[a-z]" "[A-Z]"'
alias Aa='tr "[A-Z]" "[a-z]"'
alias c1="awk '{print \$1}'"
alias c2="awk '{print \$2}'"
alias c3="awk '{print \$3}'"
alias c4="awk '{print \$4}'"
alias c5="awk '{print \$5}'"
alias c6="awk '{print \$6}'"
alias c7="awk '{print \$7}'"
alias c8="awk '{print \$8}'"
alias c9="awk '{print \$9}'"
alias c10="awk '{print \$10}'"
alias load_agent="eval $(ssh-agent)"
alias load_key=ssh-add
alias loadall='eval $(ssh-agent);ssh-add'
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
HISTCONTROL=ignoreboth
HISTSIZE=100000000
HISTFILESIZE=200000000
export PS1="%n@%m %1~ %# "
export PS2="%_> "
setopt interactivecomments