De Wiki Clusterlab.com.br
Ir para navegação
Ir para pesquisar
echo Profile Loaded
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 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 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 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 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 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 k_logs() { k -n $1 logs $(k -n $1 get pods --no-headers | c1 | head -n 1) ; }
function ealias() { alias $1 | awk -F \' '{print $2}' ; }
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.
}
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 az_subscription='az account list --query "[].[name,id]" -o tsv | column -t'
alias load_agent="eval $(ssh-agent)"
alias load_key=ssh-add
alias az_location='az account list-locations --query "[].[name]" -o tsv'
alias loadall='eval $(ssh-agent);ssh-add'
alias k=kubectl
alias ki="k -n ingress"
alias km="k -n monitoring"
alias ks="k -n kube-system"
alias az_on="source $HOME/Projetos/azc/bin/activate"
alias azlogin="az login --use-device-code"
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
HISTCONTROL=ignoreboth
HISTSIZE=100000000
HISTFILESIZE=200000000
export PS1="%n@%m %1~ %# "
export PS2="%_> "
setopt interactivecomments