My .bashrc

De Wiki Clusterlab.com.br
Revisão de 12h56min de 7 de março de 2022 por Damato (discussão | contribs) (Criou página com '<syntaxhighlight lang=bash> 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...')
(dif) ← Edição anterior | Revisão atual (dif) | Versão posterior → (dif)
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
}