pry0cc / axiom

The dynamic infrastructure framework for everybody! Distribute the workload of many different scanning tools with ease, including nmap, ffuf, masscan, nuclei, meg and many more!
MIT License
3.98k stars 617 forks source link

Axiom-init not working with Azure #262

Closed ResistanceIsUseless closed 3 years ago

ResistanceIsUseless commented 3 years ago

WARNING: Command group 'vm' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus ssh: Could not resolve hostname moser15: nodename nor servname provided, or not known

Looks like whatever az commands axiom is using have been changed. :-/

0xtavian commented 3 years ago

@ResistanceIsUseless Thank you for letting us know. Would you mind adding set -xv to the very start of the script in ~/.axiom/interact/axiom-init, running axiom-init again and pasting the debug output? Make sure to remove any sensitive data before posting.

cthulhu897 commented 3 years ago

Hi, I can confirm it wont deploy instances, and I've noticed there's a mismatch between the values provided during account setup and the ones used during image building, (region and something else I cant remeber) I think it could be related to the bug. I'm pasting thew requested output below:

cthulhu@offensive-master ~ % axiom-init
AXIOM_PATH="$HOME/.axiom"
+ AXIOM_PATH=/home/cthulhu/.axiom
DOCTL_CONFIG_PATH="$HOME/.config/doctl/config.yaml"
+ DOCTL_CONFIG_PATH=/home/cthulhu/.config/doctl/config.yaml
source "$AXIOM_PATH/interact/includes/vars.sh"
+ source /home/cthulhu/.axiom/interact/includes/vars.sh
names=("nat" "aspen" "vince" "stok" "pry" "chell" "fire" "bango" "cage" "xpn" "luke" "haddix" "omnom" "jobs" "knox" "batman" "blink" "ghost" "hickey" "jarvis" "medin" "mog" "thl" "fox" "hunt" "austin" "banzai" "bartik" "bassi" "beaver" "bell" "benz" "borg" "bose" "boyd" "brown" "buck" "cannon" "carson" "carter" "cerf"  "cohen" "clarke" "colden" "cori" "cray" "curie" "darwin" "diffie" "dirac" "edison" "elion" "ellis" "euclid" "euler" "fermat" "fermi" "gates" "gauss" "gould" "haibt" "hertz" "hoover" "hopper" "hugle" "jang" "jepsen" "joliot" "jones" "kalam" "kare" "keller" "kepler" "kilby" "kirch" "knuth" "lande" "lamar" "lamp" "leaky" "leder" "leman" "lewin" "liskov" "margo" "mato" "max" "mayer" "martho" "mclean" "mendel" "merkle" "moore" "morse" "murdo" "moser" "napier" "nash" "neum" "newton" "night" "nobel" "noyce" "pani" "pare" "pasa" "payne" "perl" "pike" "poba" "raman" "ride" "rich" "rhodes" "robin" "rubin" "saha" "sammet" "shamir" "shan" "shaw" "snyder" "spence" "stone" "suther" "swartz" "tesla" "thomp" "tu" "turing" "wilbur" "wiles" "wilson" "wing" "wright" "wu")
++ names=("nat" "aspen" "vince" "stok" "pry" "chell" "fire" "bango" "cage" "xpn" "luke" "haddix" "omnom" "jobs" "knox" "batman" "blink" "ghost" "hickey" "jarvis" "medin" "mog" "thl" "fox" "hunt" "austin" "banzai" "bartik" "bassi" "beaver" "bell" "benz" "borg" "bose" "boyd" "brown" "buck" "cannon" "carson" "carter" "cerf" "cohen" "clarke" "colden" "cori" "cray" "curie" "darwin" "diffie" "dirac" "edison" "elion" "ellis" "euclid" "euler" "fermat" "fermi" "gates" "gauss" "gould" "haibt" "hertz" "hoover" "hopper" "hugle" "jang" "jepsen" "joliot" "jones" "kalam" "kare" "keller" "kepler" "kilby" "kirch" "knuth" "lande" "lamar" "lamp" "leaky" "leder" "leman" "lewin" "liskov" "margo" "mato" "max" "mayer" "martho" "mclean" "mendel" "merkle" "moore" "morse" "murdo" "moser" "napier" "nash" "neum" "newton" "night" "nobel" "noyce" "pani" "pare" "pasa" "payne" "perl" "pike" "poba" "raman" "ride" "rich" "rhodes" "robin" "rubin" "saha" "sammet" "shamir" "shan" "shaw" "snyder" "spence" "stone" "suther" "swartz" "tesla" "thomp" "tu" "turing" "wilbur" "wiles" "wilson" "wing" "wright" "wu")

# Reset
Color_Off='\033[0m'       # Text Reset
++ Color_Off='\033[0m'

# Regular Colors
export Black='\033[0;30m'        # Black
++ export 'Black=\033[0;30m'
++ Black='\033[0;30m'
export Red='\033[0;31m'          # Red
++ export 'Red=\033[0;31m'
++ Red='\033[0;31m'
export Green='\033[0;32m'        # Green
++ export 'Green=\033[0;32m'
++ Green='\033[0;32m'
export Yellow='\033[0;33m'       # Yellow
++ export 'Yellow=\033[0;33m'
++ Yellow='\033[0;33m'
export Blue='\033[0;34m'         # Blue
++ export 'Blue=\033[0;34m'
++ Blue='\033[0;34m'
export Purple='\033[0;35m'       # Purple
++ export 'Purple=\033[0;35m'
++ Purple='\033[0;35m'
export Cyan='\033[0;36m'         # Cyan
++ export 'Cyan=\033[0;36m'
++ Cyan='\033[0;36m'
export White='\033[0;37m'        # White
++ export 'White=\033[0;37m'
++ White='\033[0;37m'

# Bold
export BBlack='\033[1;30m'       # Black
++ export 'BBlack=\033[1;30m'
++ BBlack='\033[1;30m'
export BRed='\033[1;31m'         # Red
++ export 'BRed=\033[1;31m'
++ BRed='\033[1;31m'
export BGreen='\033[1;32m'       # Green
++ export 'BGreen=\033[1;32m'
++ BGreen='\033[1;32m'
export BYellow='\033[1;33m'      # Yellow
++ export 'BYellow=\033[1;33m'
++ BYellow='\033[1;33m'
export BBlue='\033[1;34m'        # Blue
++ export 'BBlue=\033[1;34m'
++ BBlue='\033[1;34m'
export BPurple='\033[1;35m'      # Purple
++ export 'BPurple=\033[1;35m'
++ BPurple='\033[1;35m'
export BCyan='\033[1;36m'        # Cyan
++ export 'BCyan=\033[1;36m'
++ BCyan='\033[1;36m'
export BWhite='\033[1;37m'       # White
++ export 'BWhite=\033[1;37m'
++ BWhite='\033[1;37m'
source "$AXIOM_PATH/interact/includes/functions.sh"
+ source /home/cthulhu/.axiom/interact/includes/functions.sh
#!/bin/bash

AXIOM_PATH="$HOME/.axiom"
++ AXIOM_PATH=/home/cthulhu/.axiom
source "$AXIOM_PATH/interact/includes/appliance.sh"
++ source /home/cthulhu/.axiom/interact/includes/appliance.sh
#!/bin/bash

AXIOM_PATH="$HOME/.axiom"
+++ AXIOM_PATH=/home/cthulhu/.axiom
key="$(jq -r '.appliance_key?' "$AXIOM_PATH/axiom.json")"
++++ jq -r '.appliance_key?' /home/cthulhu/.axiom/axiom.json
+++ key=
app_name="$(jq -r '.appliance_name?' "$AXIOM_PATH/axiom.json")"
++++ jq -r '.appliance_name?' /home/cthulhu/.axiom/axiom.json
+++ app_name=
url="$(jq -r '.appliance_url?' "$AXIOM_PATH/axiom.json")"
++++ jq -r '.appliance_url?' /home/cthulhu/.axiom/axiom.json
+++ url=

function appliances() {
        curl -s "$url/heartbeats/$key" | jq
}

appliance_ip() {
        name="$1"

        appliances | jq -r ".[] | select(.name==\"$name\") | .lan_ip"
}

appliance_list() {
        appliances | jq -r '.[].name'
}

function pretty_appliances()  {
        data="$(appliances)"

        (echo "Instance,External IP,Last Seen,Connected,Authenticated,City,Region,ISP,Link" && echo $data | jq -r 'reverse' | jq  -r '.[] | [.name?,.external_ip?,.heartbeat_last_seen?,.connected?,.authenticated?,.geoip?.city?,.geoip?.region?,.geoip.company?.name?,.geoip.asn.type?] | @csv')| sed 's/"//g' | column -t -s, | perl -pe '$_ = "\033[0;37m$_\033[0;34m" if($. % 2)'

}

function gen_app_sshconfig() {
        echo "" >> "$AXIOM_PATH/.sshconfig"

        for appliance in $(appliance_list)
        do
                ip=$(appliance_ip "$appliance")
                jump="$app_name"

                echo -e "Host $appliance\n\tHostName $ip\n\tUser op\n\tPort 22\n\tProxyJump $jump\n" >> "$AXIOM_PATH/.sshconfig"
        done
}
LOG="$AXIOM_PATH/log.txt"
++ LOG=/home/cthulhu/.axiom/log.txt

# takes no arguments, outputs JSON object with instances
instances() {
        az vm list-ip-addresses
}

instance_id() {
        name="$1"
        az vm list | jq -r ".[] | select(.name==\"$name\") | .id"
}

# takes one argument, name of instance, returns raw IP address
instance_ip() {
        name="$1"
        az vm list-ip-addresses | jq -r ".[].virtualMachine | select(.name==\"$name\") | .network.publicIpAddresses[].ipAddress"
}

instance_ip_cache() {
        name="$1"
    config="$2"
    ssh_config="$AXIOM_PATH/.sshconfig"

    if [[ "$config" != "" ]]; then
        ssh_config="$config"
    fi
    cat "$ssh_config" | grep -A 1 "$name" | awk '{ print $2 }' | tail -n 1
}

instance_list() {
         az vm list | jq -r '.[].name'
}

# takes no arguments, creates an fzf menu
instance_menu() {
         az vm list | jq -r '.[].name' | fzf
}

quick_ip() {
        data="$1"
        ip=$(az vm list-ip-addresses | jq -r ".[].virtualMachine | select(.name==\"$name\") | .network.publicIpAddresses[].ipAddress")
        echo $ip
}

# create an instance, name, image_id (the source), sizes_slug, or the size (e.g 1vcpu-1gb), region, boot_script (this is required for expiry)
create_instance() {
        name="$1"
        image_id="$2"
        size_slug="$3"
        region="$4"
        boot_script="$5"

        location="$(az account list-locations | jq -r ".[] | select(.name==\"$region\") | .displayName")"
        az vm create --resource-group axiom --name "$name" --image "$image_id" --location "$location" --size "$size_slug"  >/dev/null 2>&1
        az vm open-port --resource-group axiom --name "$name" --port 0-65535 >/dev/null 2>&1
        sleep 10
}

instance_pretty() {
        data=$(instances)
        extra_data=$(az vm list)

        (i=0
        echo '"Instance","IP","Size","Region","$M"'

        for instance in $(echo $data | jq -c '.[].virtualMachine');
        do
                #echo $instance
                name=$(echo $instance | jq -r '.name')
                size=$(echo $extra_data | jq -r ".[] | select(.name==\"$name\") | .hardwareProfile.vmSize")
                region=$(echo $extra_data | jq -r ".[] | select(.name==\"$name\") | .location")
                price_monthly=$(cat $AXIOM_PATH/pricing/azure.json | jq -r ".[].costs[] | select(.id==\"$size\") | .firstParty[].meters[].amount")
                i=$(echo "$i+$price_monthly" | bc -l)

                data=$(echo $instance | jq ".size=\"$size\"" | jq ".region=\"$region\"" | jq ".price_monthly=\"$price_monthly\"")
                echo $data | jq -r '[.name, .network.publicIpAddresses[].ipAddress, .size, .region,.price_monthly] | @csv'
        done

        echo "\"_\",\"_\",\"_\",\"Total\",\"\$$i\"") | column -t -s, | tr -d '"' | perl -pe '$_ = "\033[0;37m$_\033[0;34m" if($. % 2)'

        i=0
        #for f in $(echo $data | jq -r '.[].size.price_monthly'); do new=$(expr $i + $f); i=$new; done
        #(echo "Instance,IP,Region,\$/M" && echo $data |  jq -r '.[].virtualMachine | [.name,.network.publicIpAddresses[].ipAddress, .region, .price_monthly] | @csv' && echo "_,_,_,Total,\$$i") | sed 's/"//g' | column -t -s, | perl -pe '$_ = "\033[0;37m$_\033[0;34m" if($. % 2)'
}

# identifies the selected instance/s
selected_instance() {
        cat "$AXIOM_PATH/selected.conf"
}

get_image_id() {
        query="$1"
        images=$(az image list)
        name=$(echo $images | jq -r ".[].name" | grep "$query" | tail -n 1)
        id=$(echo $images |  jq -r ".[] | select(.name==\"$name\") | .id")
        echo $id
}
#deletes instance, if the second argument is set to "true", will not prompt
delete_instance() {
    name="$1"
    force="$2"

    if [ "$force" == "true" ]; then
        az vm delete --name "$name" --resource-group axiom --yes
    else
        az vm delete --name "$name" --resource-group axiom
    fi
}

# TBD
instance_exists() {
        instance="$1"
}

list_regions() {
    az account list-locations | jq -r '.[].displayName'
}

regions() {
        az account list-locations
}

instance_sizes() {
    az vm list-sizes --location "East US"
}

snapshots() {
        az image list
}
# Delete a snapshot by its name
delete_snapshot() {
        name="$1"

        az image delete --name "$name" --resource-group axiom
}

msg_success() {
        echo -e "${BGreen}$1${Color_Off}"
        echo "SUCCESS $(date):$1" >> $LOG
}

msg_error() {
        echo -e "${BRed}$1${Color_Off}"
        echo "ERROR $(date):$1" >> $LOG
}

msg_neutral() {
        echo -e "${Blue}$1${Color_Off}"
        echo "INFO $(date): $1" >> $LOG
}

# takes any number of arguments, each argument should be an instance or a glob, say 'omnom*', returns a sorted list of instances based on query
# $ query_instances 'john*' marin39
# Resp >>  john01 john02 john03 john04 nmarin39
query_instances() {
        droplets="$(instances)"
        selected=""

        for var in "$@"; do
                if [[ "$var" =~ "*" ]]
                then
                        var=$(echo "$var" | sed 's/*/.*/g')
                        selected="$selected $(echo $droplets | jq -r '.[].virtualMachine.name' | grep "$var")"
                else
                        if [[ $query ]];
                        then
                                query="$query\|$var"
                        else
                                query="$var"
                        fi
                fi
        done

        if [[ "$query" ]]
        then
                selected="$selected $(echo $droplets | jq -r '.[].virtualMachine.name' | grep -w "$query")"
        else
                if [[ ! "$selected" ]]
                then
                        echo -e "${Red}No instance supplied, use * if you want to delete all instances...${Color_Off}"
                        exit
                fi
        fi

        selected=$(echo "$selected" | tr ' ' '\n' | sort -u)
        echo -n $selected
}

query_instances_cache() {
        selected=""
    ssh_conf="$AXIOM_PATH/.sshconfig"

        for var in "$@"; do
        if [[ "$var" =~ "-F=" ]]; then
            ssh_conf="$(echo "$var" | cut -d "=" -f 2)"
        elif [[ "$var" =~ "*" ]]; then
                        var=$(echo "$var" | sed 's/*/.*/g')
            selected="$selected $(cat "$ssh_conf" | grep "Host " | awk '{ print $2 }' | grep "$var")"
                else
                        if [[ $query ]];
                        then
                                query="$query\|$var"
                        else
                                query="$var"
                        fi
                fi
        done

        if [[ "$query" ]]
        then
        selected="$selected $(cat "$ssh_conf" | grep "Host " | awk '{ print $2 }' | grep -w "$query")"
        else
                if [[ ! "$selected" ]]
                then
                        echo -e "${Red}No instance supplied, use * if you want to delete all instances...${Color_Off}"
                        exit
                fi
        fi

        selected=$(echo "$selected" | tr ' ' '\n' | sort -u)
        echo -n $selected
}

# take no arguments, generate a SSH config from the current Digitalocean layout
generate_sshconfig() {
        boxes="$(az vm list-ip-addresses)"
        echo -n "" > $AXIOM_PATH/.sshconfig.new

        for name in $(echo "$boxes" | jq -r '.[].virtualMachine.name')
        do
                ip=$(echo "$boxes" | jq -r ".[].virtualMachine | select(.name==\"$name\") | .network.publicIpAddresses[].ipAddress")                echo -e "Host $name\n\tHostName $ip\n\tUser op\n\tPort 2266\n" >> $AXIOM_PATH/.sshconfig.new
    echo -e "ServerAliveInterval 60" >> $AXIOM_PATH/.sshconfig.new
    echo -e "Host *\n\tControlMaster auto\n\tControlPath  ~/.ssh/sockets/%r@%h-%p\n\tControlPersist 600" >> $AXIOM_PATH/.sshconfig.new
        done
        mv $AXIOM_PATH/.sshconfig.new $AXIOM_PATH/.sshconfig

        if [ "$key" != "null" ]
        then
                gen_app_sshconfig
        fi
}

# Check if host is in .sshconfig, and if it's not, regenerate sshconfig
conf_check() {
        instance="$1"

        l="$(cat "$AXIOM_PATH/.sshconfig" | grep "$instance" | wc -l | awk '{ print $1 }')"

        if [[ $l -lt 1 ]]
        then
                generate_sshconfig
        fi
}

###################
###### DNS
# List DNS records for domain
list_dns() {
        domain="$1"

        doctl compute domain records list "$domain"
}

list_domains_json() {
    doctl compute domain list -o json
}

# List domains
list_domains() {
        doctl compute domain list
}

list_subdomains() {
    domain="$1"

    doctl compute domain records list $domain -o json | jq '.[]'
}
# get JSON data for snapshots

delete_record() {
    domain="$1"
    id="$2"

    doctl compute domain records delete $domain $id
}

delete_record_force() {
    domain="$1"
    id="$2"

    doctl compute domain records delete $domain $id -f
}
add_dns_record() {
    subdomain="$1"
    domain="$2"
    ip="$3"

    doctl compute domain records create $domain --record-type A --record-name $subdomain --record-data $ip
}

source "$AXIOM_PATH/interact/includes/system-notification.sh"
+ source /home/cthulhu/.axiom/interact/includes/system-notification.sh
#!/bin/bash

NOTIFY_CMD=notify
++ NOTIFY_CMD=notify
BASEOS="$(uname)"
+++ uname
++ BASEOS=Linux

# method issuing notifications for at least most ubuntu like systems
# expects a title as first and a notification as second argument
function notify {
  [ -x "$(command -v notify-send)" ] && notify-send "$1" "$2"
}

# method issuing notifications in place of notify-send on OSX
# expects a title as first and a notification as second argument
function notifyOSX {
  osascript -e "display notification \"$2\" with title \"$1\""
}

if [ $BASEOS == "Darwin" ]; then NOTIFY_CMD=notifyOSX; fi
++ '[' Linux == Darwin ']'

BASEOS="$(uname)"
++ uname
+ BASEOS=Linux
provider="$(jq -r ".provider" "$AXIOM_PATH/axiom.json")"
++ jq -r .provider /home/cthulhu/.axiom/axiom.json
+ provider=azure

function help() {
        echo -e "${BWhite}Usage of axiom-init${Color_Off}"
        echo -e "Example Usage: ${Blue}axiom-init bigstok${Color_Off}"
        echo -e "  <name> string (optional)"
        echo -e "    Name of the instance, supplied as a positional first argument"
        echo -e "  --deploy=<profile>"
        echo -e "    Deploy a profile after initialization (e.g masscan, nmap, gowitness, ffuf)"
        echo -e "  --restore=<backup>"
        echo -e "    Output to default output (whatever that is for the module)"
        echo -e "  --help"
        echo -e "    Display this help menu"
}

# function called by trap
other_commands() {
    tput setaf 1
    printf "\rExiting..."
    echo "Cleaning up created resources..."
    kill -9  "$PID"
    $AXIOM_PATH/interact/axiom-rm $gen_name -f
        echo "Thank you for using axiom :) - @pry0cc"
        exit
}

trap 'other_commands' SIGINT
+ trap other_commands SIGINT

if [[ "$provider" == "do" ]]; then
# Per doctl readme the config path differs on OSX: https://github.com/digitalocean/doctl#configuring-default-values
if [ $BASEOS == "Darwin" ]; then DOCTL_CONFIG_PATH=~/"Library/Application Support/doctl/config.yaml"; fi

if ! command -v doctl &> /dev/null
then
    echo -e "${BRed}Error: doctl could not be found. Please install it from the binary${No_Color}"
    exit
else
        token_length=$(cat "$DOCTL_CONFIG_PATH"  | grep access-token | wc -c | awk '{ print $1 }')
        if [[ "$token_length" -lt 32 ]];
        then
                echo -e "${Red}Warning: it looks like your doctl might not be configured with a token!${Color_Off}"
        fi
fi
fi
+ [[ azure == \d\o ]]

if ! command -v jq &> /dev/null
then
    echo -e "${BRed}Error: jq could not be found. Please install it.${No_Color}"
    exit
fi
+ command -v jq

gen_name="${names[$RANDOM % ${#names[@]}]}$((10 + RANDOM % 20))"
+ gen_name=hickey25
region="$(jq -r '.region' $AXIOM_PATH/axiom.json)"
++ jq -r .region /home/cthulhu/.axiom/axiom.json
+ region=centralus
size="$(jq -r '.default_size' $AXIOM_PATH/axiom.json)"
++ jq -r .default_size /home/cthulhu/.axiom/axiom.json
+ size=Standard_B1s
image="$(jq -r '.image' $AXIOM_PATH/axiom.json)"
++ jq -r .image /home/cthulhu/.axiom/axiom.json
+ image=null

box_name=""
+ box_name=
connect_shell=false
+ connect_shell=false
restore=false
+ restore=false
deploy=false
+ deploy=false
expire=false
+ expire=false
default_expiry=525600000
+ default_expiry=525600000
quiet=false
+ quiet=false
domain=false
+ domain=false
manual_image_id=false
+ manual_image_id=false
user_region=""
+ user_region=
no_select=false
+ no_select=false

if [ -z "$1" ] || [[ $1 =~ "image" ]] || [[ $1 =~ "shell" ]] || [[ $1 =~ "restore" ]] || [[ $1 =~ "deploy" ]] || [[ $1 =~ "size" ]] || [[ $1 =~ "expire" ]] || [[ $1 =~ "quiet" ]] | [[ $1 =~ "domain" ]]; then
        name="$gen_name"
else
        name="$1"
fi
+ '[' -z '' ']'
+ name=hickey25

for var in "$@"; do
        if [ "$var" == "--shell" ]; then
                connect_shell=true
        fi
        if [ "$var" == "--quiet" ]; then
                quiet=true
        fi
        if [ "$var" == "--no-select" ]; then
                no_select=true
        fi
        if [[ "$var" == "-h" ]] || [[ "$var" == "--help" ]];
    then
        help
        exit 0
    fi
        if [[ $var =~ "--restore" ]]; then
                restore="$(echo "$var" | sed 's/=/ /g' | awk '{ print $2 }')"
                echo -e "${BWhite}Using restore backup '$restore'${Color_Off}"
        fi
        if [[ $var =~ "--uregion" ]]; then
                user_region="$(echo "$var" | sed 's/=/ /g' | awk '{ print $2 }')"
                #echo -e "${BWhite}Using user region '$user_region'${Color_Off}"
        fi
        if [[ "$var" =~ "--deploy" ]]; then
                deploy="$(echo "$var" | sed 's/=/ /g' | awk '{ print $2 }')"
                echo -e "${BWhite}Deploying '$deploy' after init${Color_Off}"
        fi
        if [[ "$var" =~ "--domain=" ]]; then
                domain="$(echo "$var" | sed 's/=/ /g' | awk '{ print $2 }')"
                if [ "$quiet" != "true" ]; then
                        echo -e "${BWhite}Manually setting domain to '$domain'${Color_Off}"
                fi
        fi
        if [[ "$var" =~ "--size" ]]; then
                size="$(echo "$var" | sed 's/=/ /g' | awk '{ print $2 }')"
                if [ "$quiet" != "true" ]; then
                        echo -e "${BWhite}Manually setting size to '$size'${Color_Off}"
                fi
        fi
        if [[ "$var" =~ "--image=" ]]; then
                image="$(echo "$var" | sed 's/=/ /g' | awk '{ print $2 }')"
                if [ "$quiet" != "true" ]; then
                        echo -e "${BWhite}Setting image to '$image'${Color_Off}"
                fi
        fi
        if [[ "$var" =~ "--image-id=" ]]; then
                manual_image_id="$(echo "$var" | sed 's/=/ /g' | awk '{ print $2 }')"
                if [ "$quiet" != "true" ]; then
                        echo -e "${BWhite}Setting image id to '$image'${Color_Off}"
                fi
        fi

        if [[ "$var" =~ "--expire" ]]; then
                expire="$(echo "$var" | sed 's/=/ /g' | awk '{ print $2 }')"
                default_expiry=${expire%\.*}
                if [ "$quiet" != "true" ]; then
                        echo -e "${BWhite}Setting expiry to $expire minutes...(This is non-functional)${Color_Off}"
                fi
        fi
done

if [[ "$quiet" != "true" ]]; then
        "$NOTIFY_CMD" "Axiom Info" "Initializing '$name'..."
        echo -e "${BWhite}Initializing '$name'"
fi
+ [[ false != \t\r\u\e ]]
+ notify 'Axiom Info' 'Initializing '\''hickey25'\''...'
++ command -v notify-send
+ '[' -x '' ']'
+ echo -e '\033[1;37mInitializing '\''hickey25'\'''
Initializing 'hickey25'

image_name=""
+ image_name=
if [[ "$image" != "null" ]]
then
        image_name="$image-$region"
else
        image_name="axiom-$region"
fi
+ [[ null != \n\u\l\l ]]
+ image_name=axiom-centralus

image_id=""
+ image_id=
if  [[ "$manual_image_id" != "false" ]]
then
        image_id="$manual_image_id"
else
        image_id="$(get_image_id "$image_name")"
fi
+ [[ false != \f\a\l\s\e ]]
++ get_image_id axiom-centralus
++ query=axiom-centralus
+++ az image list
++ images='[
  {
    "extendedLocation": null,
    "hyperVGeneration": "V2",
    "id": "/subscriptions/V-W-X-Y-Z/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-centralus-1615926485",
    "location": "eastus",
    "name": "axiom-centralus-1615926485",
    "provisioningState": "Succeeded",
    "resourceGroup": "AXIOM",
    "sourceVirtualMachine": {
      "id": "/subscriptions/V-W-X-Y-Z/resourceGroups/pkr-Resource-Group-ekoeqmukfn/providers/Microsoft.Compute/virtualMachines/pkrvmekoeqmukfn",
      "resourceGroup": "pkr-Resource-Group-ekoeqmukfn"
    },
    "storageProfile": {
      "dataDisks": [],
      "osDisk": {
        "blobUri": null,
        "caching": "ReadWrite",
        "diskEncryptionSet": null,
        "diskSizeGb": 30,
        "managedDisk": {
          "id": "/subscriptions/V-W-X-Y-Z/resourceGroups/pkr-Resource-Group-ekoeqmukfn/providers/Microsoft.Compute/disks/pkrosekoeqmukfn",
          "resourceGroup": "pkr-Resource-Group-ekoeqmukfn"
        },
        "osState": "Generalized",
        "osType": "Linux",
        "snapshot": null,
        "storageAccountType": "Standard_LRS"
      },
      "zoneResilient": false
    },
    "tags": null,
    "type": "Microsoft.Compute/images"
  },
  {
    "extendedLocation": null,
    "hyperVGeneration": "V2",
    "id": "/subscriptions/V-W-X-Y-Z/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-centralus-1616086756",
    "location": "eastus",
    "name": "axiom-centralus-1616086756",
    "provisioningState": "Succeeded",
    "resourceGroup": "AXIOM",
    "sourceVirtualMachine": {
      "id": "/subscriptions/V-W-X-Y-Z/resourceGroups/pkr-Resource-Group-ymooqhy7dj/providers/Microsoft.Compute/virtualMachines/pkrvmymooqhy7dj",
      "resourceGroup": "pkr-Resource-Group-ymooqhy7dj"
    },
    "storageProfile": {
      "dataDisks": [],
      "osDisk": {
        "blobUri": null,
        "caching": "ReadWrite",
        "diskEncryptionSet": null,
        "diskSizeGb": 30,
        "managedDisk": {
          "id": "/subscriptions/V-W-X-Y-Z/resourceGroups/pkr-Resource-Group-ymooqhy7dj/providers/Microsoft.Compute/disks/pkrosymooqhy7dj",
          "resourceGroup": "pkr-Resource-Group-ymooqhy7dj"
        },
        "osState": "Generalized",
        "osType": "Linux",
        "snapshot": null,
        "storageAccountType": "Standard_LRS"
      },
      "zoneResilient": false
    },
    "tags": null,
    "type": "Microsoft.Compute/images"
  }
]'
+++ tail -n 1
+++ grep axiom-centralus
+++ jq -r '.[].name'
+++ echo '[' '{' '"extendedLocation":' null, '"hyperVGeneration":' '"V2",' '"id":' '"/subscriptions/V-W-X-Y-Z/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-centralus-1615926485",' '"location":' '"eastus",' '"name":' '"axiom-centralus-1615926485",' '"provisioningState":' '"Succeeded",' '"resourceGroup":' '"AXIOM",' '"sourceVirtualMachine":' '{' '"id":' '"/subscriptions/V-W-X-Y-Z/resourceGroups/pkr-Resource-Group-ekoeqmukfn/providers/Microsoft.Compute/virtualMachines/pkrvmekoeqmukfn",' '"resourceGroup":' '"pkr-Resource-Group-ekoeqmukfn"' '},' '"storageProfile":' '{' '"dataDisks":' '[],' '"osDisk":' '{' '"blobUri":' null, '"caching":' '"ReadWrite",' '"diskEncryptionSet":' null, '"diskSizeGb":' 30, '"managedDisk":' '{' '"id":' '"/subscriptions/V-W-X-Y-Z/resourceGroups/pkr-Resource-Group-ekoeqmukfn/providers/Microsoft.Compute/disks/pkrosekoeqmukfn",' '"resourceGroup":' '"pkr-Resource-Group-ekoeqmukfn"' '},' '"osState":' '"Generalized",' '"osType":' '"Linux",' '"snapshot":' null, '"storageAccountType":' '"Standard_LRS"' '},' '"zoneResilient":' false '},' '"tags":' null, '"type":' '"Microsoft.Compute/images"' '},' '{' '"extendedLocation":' null, '"hyperVGeneration":' '"V2",' '"id":' '"/subscriptions/V-W-X-Y-Z/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-centralus-1616086756",' '"location":' '"eastus",' '"name":' '"axiom-centralus-1616086756",' '"provisioningState":' '"Succeeded",' '"resourceGroup":' '"AXIOM",' '"sourceVirtualMachine":' '{' '"id":' '"/subscriptions/V-W-X-Y-Z/resourceGroups/pkr-Resource-Group-ymooqhy7dj/providers/Microsoft.Compute/virtualMachines/pkrvmymooqhy7dj",' '"resourceGroup":' '"pkr-Resource-Group-ymooqhy7dj"' '},' '"storageProfile":' '{' '"dataDisks":' '[],' '"osDisk":' '{' '"blobUri":' null, '"caching":' '"ReadWrite",' '"diskEncryptionSet":' null, '"diskSizeGb":' 30, '"managedDisk":' '{' '"id":' '"/subscriptions/V-W-X-Y-Z/resourceGroups/pkr-Resource-Group-ymooqhy7dj/providers/Microsoft.Compute/disks/pkrosymooqhy7dj",' '"resourceGroup":' '"pkr-Resource-Group-ymooqhy7dj"' '},' '"osState":' '"Generalized",' '"osType":' '"Linux",' '"snapshot":' null, '"storageAccountType":' '"Standard_LRS"' '},' '"zoneResilient":' false '},' '"tags":' null, '"type":' '"Microsoft.Compute/images"' '}' ']'
++ name=axiom-centralus-1616086756
+++ jq -r '.[] | select(.name=="axiom-centralus-1616086756") | .id'
+++ echo '[' '{' '"extendedLocation":' null, '"hyperVGeneration":' '"V2",' '"id":' '"/subscriptions/V-W-X-Y-Z/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-centralus-1615926485",' '"location":' '"eastus",' '"name":' '"axiom-centralus-1615926485",' '"provisioningState":' '"Succeeded",' '"resourceGroup":' '"AXIOM",' '"sourceVirtualMachine":' '{' '"id":' '"/subscriptions/V-W-X-Y-Z/resourceGroups/pkr-Resource-Group-ekoeqmukfn/providers/Microsoft.Compute/virtualMachines/pkrvmekoeqmukfn",' '"resourceGroup":' '"pkr-Resource-Group-ekoeqmukfn"' '},' '"storageProfile":' '{' '"dataDisks":' '[],' '"osDisk":' '{' '"blobUri":' null, '"caching":' '"ReadWrite",' '"diskEncryptionSet":' null, '"diskSizeGb":' 30, '"managedDisk":' '{' '"id":' '"/subscriptions/V-W-X-Y-Z/resourceGroups/pkr-Resource-Group-ekoeqmukfn/providers/Microsoft.Compute/disks/pkrosekoeqmukfn",' '"resourceGroup":' '"pkr-Resource-Group-ekoeqmukfn"' '},' '"osState":' '"Generalized",' '"osType":' '"Linux",' '"snapshot":' null, '"storageAccountType":' '"Standard_LRS"' '},' '"zoneResilient":' false '},' '"tags":' null, '"type":' '"Microsoft.Compute/images"' '},' '{' '"extendedLocation":' null, '"hyperVGeneration":' '"V2",' '"id":' '"/subscriptions/V-W-X-Y-Z/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-centralus-1616086756",' '"location":' '"eastus",' '"name":' '"axiom-centralus-1616086756",' '"provisioningState":' '"Succeeded",' '"resourceGroup":' '"AXIOM",' '"sourceVirtualMachine":' '{' '"id":' '"/subscriptions/V-W-X-Y-Z/resourceGroups/pkr-Resource-Group-ymooqhy7dj/providers/Microsoft.Compute/virtualMachines/pkrvmymooqhy7dj",' '"resourceGroup":' '"pkr-Resource-Group-ymooqhy7dj"' '},' '"storageProfile":' '{' '"dataDisks":' '[],' '"osDisk":' '{' '"blobUri":' null, '"caching":' '"ReadWrite",' '"diskEncryptionSet":' null, '"diskSizeGb":' 30, '"managedDisk":' '{' '"id":' '"/subscriptions/V-W-X-Y-Z/resourceGroups/pkr-Resource-Group-ymooqhy7dj/providers/Microsoft.Compute/disks/pkrosymooqhy7dj",' '"resourceGroup":' '"pkr-Resource-Group-ymooqhy7dj"' '},' '"osState":' '"Generalized",' '"osType":' '"Linux",' '"snapshot":' null, '"storageAccountType":' '"Standard_LRS"' '},' '"zoneResilient":' false '},' '"tags":' null, '"type":' '"Microsoft.Compute/images"' '}' ']'
++ id=/subscriptions/V-W-X-Y-Z/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-centralus-1616086756
++ echo /subscriptions/V-W-X-Y-Z/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-centralus-1616086756
+ image_id=/subscriptions/V-W-X-Y-Z/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-centralus-1616086756

show_spinner() {
        local -r pid="${1}"
        # This delay is very carefully selected, as it makes makes the spinup feelfaster!!!
        local -r delay='0.48'
        # I picked 230 because it's slightly too high, you'll feel happy abouta fast spin time ;_
        i=420
        while ps a | awk '{print $1}' | grep -q "${pid}"; do
                echo -ne "${BWhite}>> T-Minus $i to full initialization...${Color_Off}\r"
                : $((i--))
                sleep "$delay"
        done
        printf "    \b\b\b\b"
}

waitabit() {
        local -r pid="${1}"
        # This delay is very carefully selected, as it makes makes the spinup feelfaster!!!
        local -r delay='0.38'
        # I picked 230 because it's slightly too high, you'll feel happy abouta fast spin time ;_
        i=420
        while ps a | awk '{print $1}' | grep -q "${pid}"; do
                : $((i--))
                sleep "$delay"
        done
        printf "    \b\b\b\b"
}

mkdir -p "$AXIOM_PATH/tmp/"
+ mkdir -p /home/cthulhu/.axiom/tmp/

if [ -z "$image_id" ]; then
        echo -e "${BRed}An image has not been found in this region. Do you need to run 'axiom-build'?${Color_Off}"
        exit 1
fi
+ '[' -z /subscriptions/V-W-X-Y-Z/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-centralus-1616086756 ']'

if [[ "$user_region" == "" ]]; then
        user_region="$region"
fi
+ [[ '' == '' ]]
+ user_region=centralus

create_instance "$name" "$image_id" "$size" "$user_region" &
PID="$!"
+ PID=2952
if [ "$quiet" != "true" ]; then
        show_spinner "$PID"
else
        waitabit "$PID"
fi
+ '[' false '!=' true ']'
+ show_spinner 2952
+ local -r pid=2952
+ local -r delay=0.48
+ i=420
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ create_instance hickey25 /subscriptions/V-W-X-Y-Z/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-centralus-1616086756 Standard_B1s centralus
+ name=hickey25
+ image_id=/subscriptions/V-W-X-Y-Z/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-centralus-1616086756
+ size_slug=Standard_B1s
+ region=centralus
+ boot_script=
+ echo -ne '\033[1;37m>> T-Minus 420 to full initialization...\033[0m\r'
+ : 420nus 420 to full initialization...
+ sleep 0.48
++ jq -r '.[] | select(.name=="centralus") | .displayName'
++ az account list-locations
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 419 to full initialization...\033[0m\r'
+ : 419nus 419 to full initialization...
+ sleep 0.48
+ location='Central US'
+ az vm create --resource-group axiom --name hickey25 --image /subscriptions/V-W-X-Y-Z/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-centralus-1616086756 --location 'Central US' --size Standard_B1s
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 418 to full initialization...\033[0m\r'
+ : 418nus 418 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 417 to full initialization...\033[0m\r'
+ : 417nus 417 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 416 to full initialization...\033[0m\r'
+ : 416nus 416 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 415 to full initialization...\033[0m\r'
+ : 415nus 415 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 414 to full initialization...\033[0m\r'
+ : 414nus 414 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 413 to full initialization...\033[0m\r'
+ : 413nus 413 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 412 to full initialization...\033[0m\r'
+ : 412nus 412 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 411 to full initialization...\033[0m\r'
+ : 411nus 411 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 410 to full initialization...\033[0m\r'
+ : 410nus 410 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 409 to full initialization...\033[0m\r'
+ : 409nus 409 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 408 to full initialization...\033[0m\r'
+ : 408nus 408 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 407 to full initialization...\033[0m\r'
+ : 407nus 407 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 406 to full initialization...\033[0m\r'
+ : 406nus 406 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 405 to full initialization...\033[0m\r'
+ : 405nus 405 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 404 to full initialization...\033[0m\r'
+ : 404nus 404 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 403 to full initialization...\033[0m\r'
+ : 403nus 403 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 402 to full initialization...\033[0m\r'
+ : 402nus 402 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 401 to full initialization...\033[0m\r'
+ : 401nus 401 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 400 to full initialization...\033[0m\r'
+ : 400nus 400 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 399 to full initialization...\033[0m\r'
+ : 399nus 399 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 398 to full initialization...\033[0m\r'
+ : 398nus 398 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 397 to full initialization...\033[0m\r'
+ : 397nus 397 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 396 to full initialization...\033[0m\r'
+ : 396nus 396 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 395 to full initialization...\033[0m\r'
+ : 395nus 395 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 394 to full initialization...\033[0m\r'
+ : 394nus 394 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 393 to full initialization...\033[0m\r'
+ : 393nus 393 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 392 to full initialization...\033[0m\r'
+ : 392nus 392 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 391 to full initialization...\033[0m\r'
+ : 391nus 391 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 390 to full initialization...\033[0m\r'
+ : 390nus 390 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 389 to full initialization...\033[0m\r'
+ : 389nus 389 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 388 to full initialization...\033[0m\r'
+ : 388nus 388 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 387 to full initialization...\033[0m\r'
+ : 387nus 387 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 386 to full initialization...\033[0m\r'
+ : 386nus 386 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 385 to full initialization...\033[0m\r'
+ : 385nus 385 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 384 to full initialization...\033[0m\r'
+ : 384nus 384 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 383 to full initialization...\033[0m\r'
+ : 383nus 383 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 382 to full initialization...\033[0m\r'
+ : 382nus 382 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 381 to full initialization...\033[0m\r'
+ : 381nus 381 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 380 to full initialization...\033[0m\r'
+ : 380nus 380 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 379 to full initialization...\033[0m\r'
+ : 379nus 379 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 378 to full initialization...\033[0m\r'
+ : 378nus 378 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 377 to full initialization...\033[0m\r'
+ : 377nus 377 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 376 to full initialization...\033[0m\r'
+ : 376nus 376 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 375 to full initialization...\033[0m\r'
+ : 375nus 375 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 374 to full initialization...\033[0m\r'
+ : 374nus 374 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 373 to full initialization...\033[0m\r'
+ : 373nus 373 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 372 to full initialization...\033[0m\r'
+ : 372nus 372 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 371 to full initialization...\033[0m\r'
+ : 371nus 371 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 370 to full initialization...\033[0m\r'
+ : 370nus 370 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 369 to full initialization...\033[0m\r'
+ : 369nus 369 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 368 to full initialization...\033[0m\r'
+ : 368nus 368 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 367 to full initialization...\033[0m\r'
+ : 367nus 367 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 366 to full initialization...\033[0m\r'
+ : 366nus 366 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 365 to full initialization...\033[0m\r'
+ : 365nus 365 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 364 to full initialization...\033[0m\r'
+ : 364nus 364 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 363 to full initialization...\033[0m\r'
+ : 363nus 363 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 362 to full initialization...\033[0m\r'
+ : 362nus 362 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 361 to full initialization...\033[0m\r'
+ : 361nus 361 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 360 to full initialization...\033[0m\r'
+ : 360nus 360 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 359 to full initialization...\033[0m\r'
+ : 359nus 359 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 358 to full initialization...\033[0m\r'
+ : 358nus 358 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 357 to full initialization...\033[0m\r'
+ : 357nus 357 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 356 to full initialization...\033[0m\r'
+ : 356nus 356 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 355 to full initialization...\033[0m\r'
+ : 355nus 355 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 354 to full initialization...\033[0m\r'
+ : 354nus 354 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 353 to full initialization...\033[0m\r'
+ : 353nus 353 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 352 to full initialization...\033[0m\r'
+ : 352nus 352 to full initialization...
+ sleep 0.48
+ az vm open-port --resource-group axiom --name hickey25 --port 0-65535
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 351 to full initialization...\033[0m\r'
+ : 351nus 351 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 350 to full initialization...\033[0m\r'
+ : 350nus 350 to full initialization...
+ sleep 0.48
+ sleep 10
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 349 to full initialization...\033[0m\r'
+ : 349nus 349 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 348 to full initialization...\033[0m\r'
+ : 348nus 348 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 347 to full initialization...\033[0m\r'
+ : 347nus 347 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 346 to full initialization...\033[0m\r'
+ : 346nus 346 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 345 to full initialization...\033[0m\r'
+ : 345nus 345 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 344 to full initialization...\033[0m\r'
+ : 344nus 344 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 343 to full initialization...\033[0m\r'
+ : 343nus 343 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 342 to full initialization...\033[0m\r'
+ : 342nus 342 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 341 to full initialization...\033[0m\r'
+ : 341nus 341 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 340 to full initialization...\033[0m\r'
+ : 340nus 340 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 339 to full initialization...\033[0m\r'
+ : 339nus 339 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 338 to full initialization...\033[0m\r'
+ : 338nus 338 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 337 to full initialization...\033[0m\r'
+ : 337nus 337 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 336 to full initialization...\033[0m\r'
+ : 336nus 336 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 335 to full initialization...\033[0m\r'
+ : 335nus 335 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 334 to full initialization...\033[0m\r'
+ : 334nus 334 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 333 to full initialization...\033[0m\r'
+ : 333nus 333 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 332 to full initialization...\033[0m\r'
+ : 332nus 332 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 331 to full initialization...\033[0m\r'
+ : 331nus 331 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ echo -ne '\033[1;37m>> T-Minus 330 to full initialization...\033[0m\r'
+ : 330nus 330 to full initialization...
+ sleep 0.48
+ grep -q 2952
+ awk '{print $1}'
+ ps a
+ printf '    \b\b\b\b'

if [ "$quiet" != "true" ]; then
        secs=$((20))
        while [ $secs -gt 0 ]; do
                echo -ne "${BWhite}>> T-Minus $secs to full initialization...${Color_Off}\r"
                sleep 1
                : $((secs--))
        done
else
        sleep 20
fi
+ '[' false '!=' true ']'
+ secs=20
+ '[' 20 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 20 to full initialization...\033[0m\r'
+ sleep 1s 20 to full initialization...
+ : 20
+ '[' 19 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 19 to full initialization...\033[0m\r'
+ sleep 1s 19 to full initialization...
+ : 19
+ '[' 18 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 18 to full initialization...\033[0m\r'
+ sleep 1s 18 to full initialization...
+ : 18
+ '[' 17 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 17 to full initialization...\033[0m\r'
+ sleep 1s 17 to full initialization...
+ : 17
+ '[' 16 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 16 to full initialization...\033[0m\r'
+ sleep 1s 16 to full initialization...
+ : 16
+ '[' 15 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 15 to full initialization...\033[0m\r'
+ sleep 1s 15 to full initialization...
+ : 15
+ '[' 14 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 14 to full initialization...\033[0m\r'
+ sleep 1s 14 to full initialization...
+ : 14
+ '[' 13 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 13 to full initialization...\033[0m\r'
+ sleep 1s 13 to full initialization...
+ : 13
+ '[' 12 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 12 to full initialization...\033[0m\r'
+ sleep 1s 12 to full initialization...
+ : 12
+ '[' 11 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 11 to full initialization...\033[0m\r'
+ sleep 1s 11 to full initialization...
+ : 11
+ '[' 10 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 10 to full initialization...\033[0m\r'
+ sleep 1s 10 to full initialization...
+ : 10
+ '[' 9 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 9 to full initialization...\033[0m\r'
+ sleep 1s 9 to full initialization...
+ : 9
+ '[' 8 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 8 to full initialization...\033[0m\r'
+ sleep 1s 8 to full initialization...
+ : 8
+ '[' 7 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 7 to full initialization...\033[0m\r'
+ sleep 1s 7 to full initialization...
+ : 7
+ '[' 6 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 6 to full initialization...\033[0m\r'
+ sleep 1s 6 to full initialization...
+ : 6
+ '[' 5 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 5 to full initialization...\033[0m\r'
+ sleep 1s 5 to full initialization...
+ : 5
+ '[' 4 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 4 to full initialization...\033[0m\r'
+ sleep 1s 4 to full initialization...
+ : 4
+ '[' 3 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 3 to full initialization...\033[0m\r'
+ sleep 1s 3 to full initialization...
+ : 3
+ '[' 2 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 2 to full initialization...\033[0m\r'
+ sleep 1s 2 to full initialization...
+ : 2
+ '[' 1 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 1 to full initialization...\033[0m\r'
+ sleep 1s 1 to full initialization...
+ : 1
+ '[' 0 -gt 0 ']'

ip="$(instance_ip "$name")"
++ instance_ip hickey25
++ name=hickey25
++ jq -r '.[].virtualMachine | select(.name=="hickey25") | .network.publicIpAddresses[].ipAddress'
++ az vm list-ip-addresses
+ ip=
ssh-keygen -R "[$ip]:2266" >>  /dev/null 2>&1
+ ssh-keygen -R '[]:2266'

if [[ "$no_select" != "true" ]]; then
        echo "$name" > $AXIOM_PATH/selected.conf
fi
+ [[ false != \t\r\u\e ]]
+ echo hickey25

if [[ "$no_select" != "true" ]]; then
        "$NOTIFY_CMD" "Axiom Info" "$name successfully initialized at $ip!"
fi
+ [[ false != \t\r\u\e ]]
+ notify 'Axiom Info' 'hickey25 successfully initialized at !'
++ command -v notify-send
+ '[' -x '' ']'
echo -e "${BWhite}Initialized instance '${BGreen}$name${Color_Off}${BWhite}' at '${BGreen}$ip${BWhite}'!"
+ echo -e '\033[1;37mInitialized instance '\''\033[1;32mhickey25\033[0m\033[1;37m'\'' at '\''\033[1;32m\033[1;37m'\''!'
Initialized instance 'hickey25' at ''!

if [ "$quiet" != "true" ]; then
        echo -e "${BWhite}To connect, run '${BGreen}axiom-ssh $name${Color_Off}'${BWhite} or '${BGreen}axiom-connect'${Color_Off}"
fi
+ '[' false '!=' true ']'
+ echo -e '\033[1;37mTo connect, run '\''\033[1;32maxiom-ssh hickey25\033[0m'\''\033[1;37m or '\''\033[1;32maxiom-connect'\''\033[0m'
To connect, run 'axiom-ssh hickey25' or 'axiom-connect'

axiom-exec "touch /tmp/.connected" "$name" -q >> /dev/null 2>&1
+ axiom-exec 'touch /tmp/.connected' hickey25 -q

if [ "$restore" != false ]; then
        #echo -e "${BWhite}Waiting 65 seconds before restore...${Color_Off}"
        $AXIOM_PATH/interact/axiom-restore "$restore" "$name"
fi
+ '[' false '!=' false ']'

if [ "$deploy" != false ]; then
        #echo -e "${BWhite}Waiting 65 seconds before deploy... ${Color_Off}"
        $AXIOM_PATH/interact/axiom-deploy "$deploy" "$name"
fi
+ '[' false '!=' false ']'

#if [ "$domain" != false ]; then
##      echo -e "${BWhite}Adding DNS record $name.$domain to -> $ip"
#       $AXIOM_PATH/interact/axiom-dns add $name $domain $ip
#fi

$AXIOM_PATH/interact/header.sh
+ /home/cthulhu/.axiom/interact/header.sh
cthulhu897 commented 3 years ago

I can confirm the bug is related to the image building script, but I dont know how o where to fix it. -> when provisioning the image it is always built at "eastus", so when creating an instance it is wrongly referenced.

ResistanceIsUseless commented 3 years ago

Image creation worked for me in azure but not deploying. Manually creating the VM worked i just haven't had the time to update the script and retry building the VM. I'll try and get to that today or tomorrowand paste some output as well as my review of the script. I think one of the switches might be unneeded or a wrong value.

On Mon, Mar 22, 2021 at 5:18 PM Francisco Díaz @.***> wrote:

I can confirm the bug is related to the image building script, but I dont know how o where to fix it. -> when provisioning the image it is always built at "eastus", so when creating an instance it is wrongly referenced.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pry0cc/axiom/issues/262#issuecomment-804488003, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKCJ2N6RITYLZZZPM7WLQLTE7M5LANCNFSM4ZPKIOIA .

ResistanceIsUseless commented 3 years ago

just tested it out and i get the following error with the command axiom is sending to ARM CLI.

az vm create --resource-group axiom --name jepsen13 --image *scrubbed*/axiom-eastus-1616176463 --location 'East US' --size Standard_B1s 

admin user name cannot contain upper case character A-Z, special characters \/"[]:|<>+=;,?*@#()! or start with $ or -

Running it again manually and adding "--admin-username axiom" resolves the issue. I'm not sure if that got changed away from the azure default someplace or it's now required. The az vm create -h doesn't say it's required.

0xtavian commented 3 years ago

@ResistanceIsUseless @cthulhu897 I updated the azure builder https://github.com/pry0cc/axiom/blob/master/images/builders/azure.json to include region. Can you run axiom-update and axiom-build, axiom-init to see if that fixes it? If not i'll make time later tonight and recreate. thanks guy for bringing this issue forward!

To debug, I would also add set -xv to axiom-build and rerun to see what errors show up.

cthulhu897 commented 3 years ago

I had to run axiom-account-setup againt for axiom-init to work, but now it does create instances and I'm finally experiencing unlimited power in az!

0xtavian commented 3 years ago

@ResistanceIsUseless let us know if youre still having issues. If everything is copacetic, feel free to close.

ResistanceIsUseless commented 3 years ago

Did axiom-update, axioom-account-setup, axiom-init right now and the build from image to vm still fails. Looks like it's still not liking the missing username. I then did the following(below) and re-ran everything and it fixed it. This could just be something wrong with me if @cthulhu897 wasn't having any issues.

I added "--admin-username op" to the following line https://github.com/pry0cc/axiom/blob/master/providers/azure-functions.sh#L58

az vm create --resource-group axiom --name "$name" --image "$image_id" --location "$location" --size "$size_slug" --admin-username op >/dev/null 2>&1

Once I did that and reran axiom-init it successfully built the VM from the image. Feel free to close this out if it's just me having this issue or leave it open to see if other azure users have issues. I'm not sure if hardcoding the username would break building for people not running into this issue. Weird that this fixes it for me if it's still a region issue.


AXIOM_PATH="$HOME/.axiom"
+ AXIOM_PATH=/Users/XXXXXXXXX/.axiom
DOCTL_CONFIG_PATH="$HOME/.config/doctl/config.yaml"
+ DOCTL_CONFIG_PATH=/Users/XXXXXXXXX/.config/doctl/config.yaml
source "$AXIOM_PATH/interact/includes/vars.sh"
+ source /Users/XXXXXXXXX/.axiom/interact/includes/vars.sh
names=("nat" "aspen" "vince" "stok" "pry" "chell" "fire" "bango" "cage" "xpn" "luke" "haddix" "omnom" "jobs" "knox" "batman" "blink" "ghost" "hickey" "jarvis" "medin" "mog" "thl" "fox" "hunt" "austin" "banzai" "bartik" "bassi" "beaver" "bell" "benz" "borg" "bose" "boyd" "brown" "buck" "cannon" "carson" "carter" "cerf"  "cohen" "clarke" "colden" "cori" "cray" "curie" "darwin" "diffie" "dirac" "edison" "elion" "ellis" "euclid" "euler" "fermat" "fermi" "gates" "gauss" "gould" "haibt" "hertz" "hoover" "hopper" "hugle" "jang" "jepsen" "joliot" "jones" "kalam" "kare" "keller" "kepler" "kilby" "kirch" "knuth" "lande" "lamar" "lamp" "leaky" "leder" "leman" "lewin" "liskov" "margo" "mato" "max" "mayer" "martho" "mclean" "mendel" "merkle" "moore" "morse" "murdo" "moser" "napier" "nash" "neum" "newton" "night" "nobel" "noyce" "pani" "pare" "pasa" "payne" "perl" "pike" "poba" "raman" "ride" "rich" "rhodes" "robin" "rubin" "saha" "sammet" "shamir" "shan" "shaw" "snyder" "spence" "stone" "suther" "swartz" "tesla" "thomp" "tu" "turing" "wilbur" "wiles" "wilson" "wing" "wright" "wu")
++ names=("nat" "aspen" "vince" "stok" "pry" "chell" "fire" "bango" "cage" "xpn" "luke" "haddix" "omnom" "jobs" "knox" "batman" "blink" "ghost" "hickey" "jarvis" "medin" "mog" "thl" "fox" "hunt" "austin" "banzai" "bartik" "bassi" "beaver" "bell" "benz" "borg" "bose" "boyd" "brown" "buck" "cannon" "carson" "carter" "cerf" "cohen" "clarke" "colden" "cori" "cray" "curie" "darwin" "diffie" "dirac" "edison" "elion" "ellis" "euclid" "euler" "fermat" "fermi" "gates" "gauss" "gould" "haibt" "hertz" "hoover" "hopper" "hugle" "jang" "jepsen" "joliot" "jones" "kalam" "kare" "keller" "kepler" "kilby" "kirch" "knuth" "lande" "lamar" "lamp" "leaky" "leder" "leman" "lewin" "liskov" "margo" "mato" "max" "mayer" "martho" "mclean" "mendel" "merkle" "moore" "morse" "murdo" "moser" "napier" "nash" "neum" "newton" "night" "nobel" "noyce" "pani" "pare" "pasa" "payne" "perl" "pike" "poba" "raman" "ride" "rich" "rhodes" "robin" "rubin" "saha" "sammet" "shamir" "shan" "shaw" "snyder" "spence" "stone" "suther" "swartz" "tesla" "thomp" "tu" "turing" "wilbur" "wiles" "wilson" "wing" "wright" "wu")

# Reset
Color_Off='\033[0m'       # Text Reset
++ Color_Off='\033[0m'

# Regular Colors
export Black='\033[0;30m'        # Black
++ export 'Black=\033[0;30m'
++ Black='\033[0;30m'
export Red='\033[0;31m'          # Red
++ export 'Red=\033[0;31m'
++ Red='\033[0;31m'
export Green='\033[0;32m'        # Green
++ export 'Green=\033[0;32m'
++ Green='\033[0;32m'
export Yellow='\033[0;33m'       # Yellow
++ export 'Yellow=\033[0;33m'
++ Yellow='\033[0;33m'
export Blue='\033[0;34m'         # Blue
++ export 'Blue=\033[0;34m'
++ Blue='\033[0;34m'
export Purple='\033[0;35m'       # Purple
++ export 'Purple=\033[0;35m'
++ Purple='\033[0;35m'
export Cyan='\033[0;36m'         # Cyan
++ export 'Cyan=\033[0;36m'
++ Cyan='\033[0;36m'
export White='\033[0;37m'        # White
++ export 'White=\033[0;37m'
++ White='\033[0;37m'

# Bold
export BBlack='\033[1;30m'       # Black
++ export 'BBlack=\033[1;30m'
++ BBlack='\033[1;30m'
export BRed='\033[1;31m'         # Red
++ export 'BRed=\033[1;31m'
++ BRed='\033[1;31m'
export BGreen='\033[1;32m'       # Green
++ export 'BGreen=\033[1;32m'
++ BGreen='\033[1;32m'
export BYellow='\033[1;33m'      # Yellow
++ export 'BYellow=\033[1;33m'
++ BYellow='\033[1;33m'
export BBlue='\033[1;34m'        # Blue
++ export 'BBlue=\033[1;34m'
++ BBlue='\033[1;34m'
export BPurple='\033[1;35m'      # Purple
++ export 'BPurple=\033[1;35m'
++ BPurple='\033[1;35m'
export BCyan='\033[1;36m'        # Cyan
++ export 'BCyan=\033[1;36m'
++ BCyan='\033[1;36m'
export BWhite='\033[1;37m'       # White
++ export 'BWhite=\033[1;37m'
++ BWhite='\033[1;37m'
source "$AXIOM_PATH/interact/includes/functions.sh"
+ source /Users/XXXXXXXXX/.axiom/interact/includes/functions.sh
#!/bin/bash

AXIOM_PATH="$HOME/.axiom"
++ AXIOM_PATH=/Users/XXXXXXXXX/.axiom
source "$AXIOM_PATH/interact/includes/appliance.sh"
++ source /Users/XXXXXXXXX/.axiom/interact/includes/appliance.sh
#!/bin/bash

AXIOM_PATH="$HOME/.axiom"
+++ AXIOM_PATH=/Users/XXXXXXXXX/.axiom
key="$(jq -r '.appliance_key?' "$AXIOM_PATH/axiom.json")"
jq -r '.appliance_key?' "$AXIOM_PATH/axiom.json"
++++ jq -r '.appliance_key?' /Users/XXXXXXXXX/.axiom/axiom.json
+++ key=
app_name="$(jq -r '.appliance_name?' "$AXIOM_PATH/axiom.json")"
jq -r '.appliance_name?' "$AXIOM_PATH/axiom.json"
++++ jq -r '.appliance_name?' /Users/XXXXXXXXX/.axiom/axiom.json
+++ app_name=
url="$(jq -r '.appliance_url?' "$AXIOM_PATH/axiom.json")"
jq -r '.appliance_url?' "$AXIOM_PATH/axiom.json"
++++ jq -r '.appliance_url?' /Users/XXXXXXXXX/.axiom/axiom.json
+++ url=

function appliances() {
    curl -s "$url/heartbeats/$key" | jq
}

appliance_ip() {
    name="$1"

    appliances | jq -r ".[] | select(.name==\"$name\") | .lan_ip"
}

appliance_list() {
    appliances | jq -r '.[].name'
}

function pretty_appliances()  {
    data="$(appliances)"

    (echo "Instance,External IP,Last Seen,Connected,Authenticated,City,Region,ISP,Link" && echo $data | jq -r 'reverse' | jq  -r '.[] | [.name?,.external_ip?,.heartbeat_last_seen?,.connected?,.authenticated?,.geoip?.city?,.geoip?.region?,.geoip.company?.name?,.geoip.asn.type?] | @csv')| sed 's/"//g' | column -t -s, | perl -pe '$_ = "\033[0;37m$_\033[0;34m" if($. % 2)'

}

function gen_app_sshconfig() {
    echo "" >> "$AXIOM_PATH/.sshconfig"

    for appliance in $(appliance_list)
    do
        ip=$(appliance_ip "$appliance")
        jump="$app_name"

        echo -e "Host $appliance\n\tHostName $ip\n\tUser op\n\tPort 22\n\tProxyJump $jump\n" >> "$AXIOM_PATH/.sshconfig"
    done
}
LOG="$AXIOM_PATH/log.txt"
++ LOG=/Users/XXXXXXXXX/.axiom/log.txt

# takes no arguments, outputs JSON object with instances
instances() {
    az vm list-ip-addresses
}

instance_id() {
    name="$1"
    az vm list | jq -r ".[] | select(.name==\"$name\") | .id"
}

# takes one argument, name of instance, returns raw IP address
instance_ip() {
    name="$1"
    az vm list-ip-addresses | jq -r ".[].virtualMachine | select(.name==\"$name\") | .network.publicIpAddresses[].ipAddress"
}

instance_ip_cache() {
    name="$1"
    config="$2"
    ssh_config="$AXIOM_PATH/.sshconfig"

    if [[ "$config" != "" ]]; then
        ssh_config="$config"
    fi
    cat "$ssh_config" | grep -A 1 "$name" | awk '{ print $2 }' | tail -n 1
}

instance_list() {
     az vm list | jq -r '.[].name'
}

# takes no arguments, creates an fzf menu
instance_menu() {
     az vm list | jq -r '.[].name' | fzf
}

quick_ip() {
    data="$1"
    ip=$(az vm list-ip-addresses | jq -r ".[].virtualMachine | select(.name==\"$name\") | .network.publicIpAddresses[].ipAddress")
    echo $ip
}

# create an instance, name, image_id (the source), sizes_slug, or the size (e.g 1vcpu-1gb), region, boot_script (this is required for expiry)
create_instance() {
    name="$1"
    image_id="$2"
    size_slug="$3"
    region="$4"
    boot_script="$5"

    location="$(az account list-locations | jq -r ".[] | select(.name==\"$region\") | .displayName")"
    az vm create --resource-group axiom --name "$name" --image "$image_id" --location "$location" --size "$size_slug" >/dev/null 2>&1 
    az vm open-port --resource-group axiom --name "$name" --port 0-65535 >/dev/null 2>&1 
    sleep 10
}

instance_pretty() {
    data=$(instances)
    extra_data=$(az vm list)

    (i=0
    echo '"Instance","IP","Size","Region","$M"'

    for instance in $(echo $data | jq -c '.[].virtualMachine');
    do
        #echo $instance
        name=$(echo $instance | jq -r '.name')
        size=$(echo $extra_data | jq -r ".[] | select(.name==\"$name\") | .hardwareProfile.vmSize")
        region=$(echo $extra_data | jq -r ".[] | select(.name==\"$name\") | .location")
        price_monthly=$(cat $AXIOM_PATH/pricing/azure.json | jq -r ".[].costs[] | select(.id==\"$size\") | .firstParty[].meters[].amount")
        i=$(echo "$i+$price_monthly" | bc -l)

        data=$(echo $instance | jq ".size=\"$size\"" | jq ".region=\"$region\"" | jq ".price_monthly=\"$price_monthly\"")
        echo $data | jq -r '[.name, .network.publicIpAddresses[].ipAddress, .size, .region,.price_monthly] | @csv'
    done

    echo "\"_\",\"_\",\"_\",\"Total\",\"\$$i\"") | column -t -s, | tr -d '"' | perl -pe '$_ = "\033[0;37m$_\033[0;34m" if($. % 2)'

    i=0
    #for f in $(echo $data | jq -r '.[].size.price_monthly'); do new=$(expr $i + $f); i=$new; done
    #(echo "Instance,IP,Region,\$/M" && echo $data |  jq -r '.[].virtualMachine | [.name,.network.publicIpAddresses[].ipAddress, .region, .price_monthly] | @csv' && echo "_,_,_,Total,\$$i") | sed 's/"//g' | column -t -s, | perl -pe '$_ = "\033[0;37m$_\033[0;34m" if($. % 2)'
}

# identifies the selected instance/s
selected_instance() {
    cat "$AXIOM_PATH/selected.conf"
}

get_image_id() {
    query="$1"
    images=$(az image list)
    name=$(echo $images | jq -r ".[].name" | grep "$query" | tail -n 1)
    id=$(echo $images |  jq -r ".[] | select(.name==\"$name\") | .id")
    echo $id
}
#deletes instance, if the second argument is set to "true", will not prompt
delete_instance() {
    name="$1"
    force="$2"

    if [ "$force" == "true" ]; then
        az vm delete --name "$name" --resource-group axiom --yes
    else
        az vm delete --name "$name" --resource-group axiom
    fi
}

# TBD 
instance_exists() {
    instance="$1"
}

list_regions() {
    az account list-locations | jq -r '.[].displayName'
}

regions() {
    az account list-locations
}

instance_sizes() {
    az vm list-sizes --location "East US"
}

snapshots() {
    az image list
}
# Delete a snapshot by its name
delete_snapshot() {
    name="$1"

    az image delete --name "$name" --resource-group axiom
}

msg_success() {
    echo -e "${BGreen}$1${Color_Off}"
    echo "SUCCESS $(date):$1" >> $LOG
}

msg_error() {
    echo -e "${BRed}$1${Color_Off}"
    echo "ERROR $(date):$1" >> $LOG
}

msg_neutral() {
    echo -e "${Blue}$1${Color_Off}"
    echo "INFO $(date): $1" >> $LOG
}

# takes any number of arguments, each argument should be an instance or a glob, say 'omnom*', returns a sorted list of instances based on query
# $ query_instances 'john*' marin39
# Resp >>  john01 john02 john03 john04 nmarin39
query_instances() {
    droplets="$(instances)"
    selected=""

    for var in "$@"; do
        if [[ "$var" =~ "*" ]]
        then
            var=$(echo "$var" | sed 's/*/.*/g')
            selected="$selected $(echo $droplets | jq -r '.[].virtualMachine.name' | grep "$var")"
        else
            if [[ $query ]];
            then
                query="$query\|$var"
            else
                query="$var"
            fi
        fi
    done

    if [[ "$query" ]]
    then
        selected="$selected $(echo $droplets | jq -r '.[].virtualMachine.name' | grep -w "$query")"
    else
        if [[ ! "$selected" ]]
        then
            echo -e "${Red}No instance supplied, use * if you want to delete all instances...${Color_Off}"
            exit
        fi
    fi

    selected=$(echo "$selected" | tr ' ' '\n' | sort -u)
    echo -n $selected
}

query_instances_cache() {
    selected=""
    ssh_conf="$AXIOM_PATH/.sshconfig"

    for var in "$@"; do
        if [[ "$var" =~ "-F=" ]]; then
            ssh_conf="$(echo "$var" | cut -d "=" -f 2)"
        elif [[ "$var" =~ "*" ]]; then
            var=$(echo "$var" | sed 's/*/.*/g')
            selected="$selected $(cat "$ssh_conf" | grep "Host " | awk '{ print $2 }' | grep "$var")"
        else
            if [[ $query ]];
            then
                query="$query\|$var"
            else
                query="$var"
            fi
        fi
    done

    if [[ "$query" ]]
    then
        selected="$selected $(cat "$ssh_conf" | grep "Host " | awk '{ print $2 }' | grep -w "$query")"
    else
        if [[ ! "$selected" ]]
        then
            echo -e "${Red}No instance supplied, use * if you want to delete all instances...${Color_Off}"
            exit
        fi
    fi

    selected=$(echo "$selected" | tr ' ' '\n' | sort -u)
    echo -n $selected
}

# take no arguments, generate a SSH config from the current Digitalocean layout
generate_sshconfig() {
    boxes="$(az vm list-ip-addresses)"
    echo -n "" > $AXIOM_PATH/.sshconfig.new

    for name in $(echo "$boxes" | jq -r '.[].virtualMachine.name')
    do 
        ip=$(echo "$boxes" | jq -r ".[].virtualMachine | select(.name==\"$name\") | .network.publicIpAddresses[].ipAddress")
        echo -e "Host $name\n\tHostName $ip\n\tUser op\n\tPort 2266\n" >> $AXIOM_PATH/.sshconfig.new
    echo -e "ServerAliveInterval 60" >> $AXIOM_PATH/.sshconfig.new
    echo -e "Host *\n\tControlMaster auto\n\tControlPath  ~/.ssh/sockets/%r@%h-%p\n\tControlPersist 600" >> $AXIOM_PATH/.sshconfig.new
    done
    mv $AXIOM_PATH/.sshconfig.new $AXIOM_PATH/.sshconfig

    if [ "$key" != "null" ]
    then
        gen_app_sshconfig
    fi
}

# Check if host is in .sshconfig, and if it's not, regenerate sshconfig
conf_check() {
    instance="$1"

    l="$(cat "$AXIOM_PATH/.sshconfig" | grep "$instance" | wc -l | awk '{ print $1 }')"

    if [[ $l -lt 1 ]]
    then
        generate_sshconfig  
    fi
}

###################
###### DNS
# List DNS records for domain
list_dns() {
    domain="$1"

    doctl compute domain records list "$domain"
}

list_domains_json() {
    doctl compute domain list -o json
}

# List domains
list_domains() {
    doctl compute domain list
}

list_subdomains() {
    domain="$1"

    doctl compute domain records list $domain -o json | jq '.[]'
}
# get JSON data for snapshots

delete_record() {
    domain="$1"
    id="$2"

    doctl compute domain records delete $domain $id
}

delete_record_force() {
    domain="$1"
    id="$2"

    doctl compute domain records delete $domain $id -f
}
add_dns_record() {
    subdomain="$1"
    domain="$2"
    ip="$3"

    doctl compute domain records create $domain --record-type A --record-name $subdomain --record-data $ip
}

source "$AXIOM_PATH/interact/includes/system-notification.sh"
+ source /Users/XXXXXXXXX/.axiom/interact/includes/system-notification.sh
#!/bin/bash

NOTIFY_CMD=notify
++ NOTIFY_CMD=notify
BASEOS="$(uname)"
uname
+++ uname
++ BASEOS=Darwin

# method issuing notifications for at least most ubuntu like systems
# expects a title as first and a notification as second argument
function notify {
  [ -x "$(command -v notify-send)" ] && notify-send "$1" "$2"
}

# method issuing notifications in place of notify-send on OSX
# expects a title as first and a notification as second argument
function notifyOSX {
  osascript -e "display notification \"$2\" with title \"$1\""
}

if [ $BASEOS == "Darwin" ]; then NOTIFY_CMD=notifyOSX; fi
++ '[' Darwin == Darwin ']'
++ NOTIFY_CMD=notifyOSX

BASEOS="$(uname)"
uname
++ uname
+ BASEOS=Darwin
provider="$(jq -r ".provider" "$AXIOM_PATH/axiom.json")"
jq -r ".provider" "$AXIOM_PATH/axiom.json"
++ jq -r .provider /Users/XXXXXXXXX/.axiom/axiom.json
+ provider=azure

function help() {
    echo -e "${BWhite}Usage of axiom-init${Color_Off}"
    echo -e "Example Usage: ${Blue}axiom-init bigstok${Color_Off}"
    echo -e "  <name> string (optional)"
    echo -e "    Name of the instance, supplied as a positional first argument"
    echo -e "  --deploy=<profile>"
    echo -e "    Deploy a profile after initialization (e.g masscan, nmap, gowitness, ffuf)"
    echo -e "  --restore=<backup>"
    echo -e "    Output to default output (whatever that is for the module)"
    echo -e "  --help"
    echo -e "    Display this help menu"
}

# function called by trap
other_commands() {
    tput setaf 1
    printf "\rExiting..."
    echo "Cleaning up created resources..."
    kill -9  "$PID"
    $AXIOM_PATH/interact/axiom-rm $gen_name -f
    echo "Thank you for using axiom :) - @pry0cc"
    exit
}

trap 'other_commands' SIGINT
+ trap other_commands SIGINT

if [[ "$provider" == "do" ]]; then
# Per doctl readme the config path differs on OSX: https://github.com/digitalocean/doctl#configuring-default-values
if [ $BASEOS == "Darwin" ]; then DOCTL_CONFIG_PATH=~/"Library/Application Support/doctl/config.yaml"; fi

if ! command -v doctl &> /dev/null
then
    echo -e "${BRed}Error: doctl could not be found. Please install it from the binary${No_Color}"
    exit
else
    token_length=$(cat "$DOCTL_CONFIG_PATH"  | grep access-token | wc -c | awk '{ print $1 }')
    if [[ "$token_length" -lt 32 ]];
    then
        echo -e "${Red}Warning: it looks like your doctl might not be configured with a token!${Color_Off}"
    fi
fi
fi
+ [[ azure == \d\o ]]

if ! command -v jq &> /dev/null
then
    echo -e "${BRed}Error: jq could not be found. Please install it.${No_Color}"
    exit
fi
+ command -v jq

gen_name="${names[$RANDOM % ${#names[@]}]}$((10 + RANDOM % 20))"
+ gen_name=brown17
region="$(jq -r '.region' $AXIOM_PATH/axiom.json)"
jq -r '.region' $AXIOM_PATH/axiom.json
++ jq -r .region /Users/XXXXXXXXX/.axiom/axiom.json
+ region=eastus
size="$(jq -r '.default_size' $AXIOM_PATH/axiom.json)"
jq -r '.default_size' $AXIOM_PATH/axiom.json
++ jq -r .default_size /Users/XXXXXXXXX/.axiom/axiom.json
+ size=Standard_B1s
image="$(jq -r '.image' $AXIOM_PATH/axiom.json)"
jq -r '.image' $AXIOM_PATH/axiom.json
++ jq -r .image /Users/XXXXXXXXX/.axiom/axiom.json
+ image=null

box_name=""
+ box_name=
connect_shell=false
+ connect_shell=false
restore=false
+ restore=false
deploy=false
+ deploy=false
expire=false
+ expire=false
default_expiry=525600000
+ default_expiry=525600000
quiet=false
+ quiet=false
domain=false
+ domain=false
manual_image_id=false
+ manual_image_id=false
user_region=""
+ user_region=
no_select=false
+ no_select=false

if [ -z "$1" ] || [[ $1 =~ "image" ]] || [[ $1 =~ "shell" ]] || [[ $1 =~ "restore" ]] || [[ $1 =~ "deploy" ]] || [[ $1 =~ "size" ]] || [[ $1 =~ "expire" ]] || [[ $1 =~ "quiet" ]] | [[ $1 =~ "domain" ]]; then
    name="$gen_name"
else
    name="$1"
fi
+ '[' -z '' ']'
+ name=brown17

for var in "$@"; do
    if [ "$var" == "--shell" ]; then
        connect_shell=true
    fi
    if [ "$var" == "--quiet" ]; then
        quiet=true
    fi
    if [ "$var" == "--no-select" ]; then
        no_select=true
    fi
    if [[ "$var" == "-h" ]] || [[ "$var" == "--help" ]];
    then
        help
        exit 0
    fi
    if [[ $var =~ "--restore" ]]; then
        restore="$(echo "$var" | sed 's/=/ /g' | awk '{ print $2 }')"
        echo -e "${BWhite}Using restore backup '$restore'${Color_Off}"
    fi
    if [[ $var =~ "--uregion" ]]; then
        user_region="$(echo "$var" | sed 's/=/ /g' | awk '{ print $2 }')"
        #echo -e "${BWhite}Using user region '$user_region'${Color_Off}"
    fi
    if [[ "$var" =~ "--deploy" ]]; then
        deploy="$(echo "$var" | sed 's/=/ /g' | awk '{ print $2 }')"
        echo -e "${BWhite}Deploying '$deploy' after init${Color_Off}"
    fi
    if [[ "$var" =~ "--domain=" ]]; then
        domain="$(echo "$var" | sed 's/=/ /g' | awk '{ print $2 }')"
        if [ "$quiet" != "true" ]; then
            echo -e "${BWhite}Manually setting domain to '$domain'${Color_Off}"
        fi
    fi
    if [[ "$var" =~ "--size" ]]; then
        size="$(echo "$var" | sed 's/=/ /g' | awk '{ print $2 }')"
        if [ "$quiet" != "true" ]; then
            echo -e "${BWhite}Manually setting size to '$size'${Color_Off}"
        fi
    fi
    if [[ "$var" =~ "--image=" ]]; then
        image="$(echo "$var" | sed 's/=/ /g' | awk '{ print $2 }')"
        if [ "$quiet" != "true" ]; then
            echo -e "${BWhite}Setting image to '$image'${Color_Off}"
        fi
    fi
    if [[ "$var" =~ "--image-id=" ]]; then
        manual_image_id="$(echo "$var" | sed 's/=/ /g' | awk '{ print $2 }')"
        if [ "$quiet" != "true" ]; then
            echo -e "${BWhite}Setting image id to '$image'${Color_Off}"
        fi
    fi

    if [[ "$var" =~ "--expire" ]]; then
        expire="$(echo "$var" | sed 's/=/ /g' | awk '{ print $2 }')"
        default_expiry=${expire%\.*}
        if [ "$quiet" != "true" ]; then
            echo -e "${BWhite}Setting expiry to $expire minutes...(This is non-functional)${Color_Off}"
        fi
    fi
done

if [[ "$quiet" != "true" ]]; then
    "$NOTIFY_CMD" "Axiom Info" "Initializing '$name'..."
    echo -e "${BWhite}Initializing '$name'"
fi
+ [[ false != \t\r\u\e ]]
+ notifyOSX 'Axiom Info' 'Initializing '\''brown17'\''...'
+ osascript -e 'display notification "Initializing '\''brown17'\''..." with title "Axiom Info"'
+ echo -e '\033[1;37mInitializing '\''brown17'\'''
Initializing 'brown17'

image_name=""
+ image_name=
if [[ "$image" != "null" ]]
then
    image_name="$image-$region"
else
    image_name="axiom-$region"
fi
+ [[ null != \n\u\l\l ]]
+ image_name=axiom-eastus

image_id=""
+ image_id=
if  [[ "$manual_image_id" != "false" ]]
then
    image_id="$manual_image_id"
else
    image_id="$(get_image_id "$image_name")"
fi
+ [[ false != \f\a\l\s\e ]]
get_image_id "$image_name"
++ get_image_id axiom-eastus
++ query=axiom-eastus
az image list
+++ az image list
++ images='[
  {
    "hyperVGeneration": "V2",
    "id": "/subscriptions/xxxxx/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-eastus-1616176463",
    "location": "eastus",
    "name": "axiom-eastus-1616176463",
    "provisioningState": "Succeeded",
    "resourceGroup": "AXIOM",
    "sourceVirtualMachine": {
      "id": "/subscriptions/xxxxx/resourceGroups/pkr-Resource-Group-vj5o7w56xd/providers/Microsoft.Compute/virtualMachines/pkrvmvj5o7w56xd",
      "resourceGroup": "pkr-Resource-Group-vj5o7w56xd"
    },
    "storageProfile": {
      "dataDisks": [],
      "osDisk": {
        "blobUri": null,
        "caching": "ReadWrite",
        "diskEncryptionSet": null,
        "diskSizeGb": 30,
        "managedDisk": {
          "id": "/subscriptions/xxxxx/resourceGroups/pkr-Resource-Group-vj5o7w56xd/providers/Microsoft.Compute/disks/pkrosvj5o7w56xd",
          "resourceGroup": "pkr-Resource-Group-vj5o7w56xd"
        },
        "osState": "Generalized",
        "osType": "Linux",
        "snapshot": null,
        "storageAccountType": "Standard_LRS"
      },
      "zoneResilient": false
    },
    "tags": {},
    "type": "Microsoft.Compute/images"
  },
  {
    "hyperVGeneration": "V2",
    "id": "/subscriptions/xxxxx/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-eastus-1616523460",
    "location": "eastus",
    "name": "axiom-eastus-1616523460",
    "provisioningState": "Succeeded",
    "resourceGroup": "AXIOM",
    "sourceVirtualMachine": {
      "id": "/subscriptions/xxxxx/resourceGroups/pkr-Resource-Group-u6lxee50w5/providers/Microsoft.Compute/virtualMachines/pkrvmu6lxee50w5",
      "resourceGroup": "pkr-Resource-Group-u6lxee50w5"
    },
    "storageProfile": {
      "dataDisks": [],
      "osDisk": {
        "blobUri": null,
        "caching": "ReadWrite",
        "diskEncryptionSet": null,
        "diskSizeGb": 30,
        "managedDisk": {
          "id": "/subscriptions/xxxxx/resourceGroups/pkr-Resource-Group-u6lxee50w5/providers/Microsoft.Compute/disks/pkrosu6lxee50w5",
          "resourceGroup": "pkr-Resource-Group-u6lxee50w5"
        },
        "osState": "Generalized",
        "osType": "Linux",
        "snapshot": null,
        "storageAccountType": "Standard_LRS"
      },
      "zoneResilient": false
    },
    "tags": {},
    "type": "Microsoft.Compute/images"
  },
  {
    "hyperVGeneration": "V2",
    "id": "/subscriptions/xxxxx/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-eastus-1616611230",
    "location": "eastus",
    "name": "axiom-eastus-1616611230",
    "provisioningState": "Succeeded",
    "resourceGroup": "AXIOM",
    "sourceVirtualMachine": {
      "id": "/subscriptions/xxxxx/resourceGroups/pkr-Resource-Group-sft8co2izw/providers/Microsoft.Compute/virtualMachines/pkrvmsft8co2izw",
      "resourceGroup": "pkr-Resource-Group-sft8co2izw"
    },
    "storageProfile": {
      "dataDisks": [],
      "osDisk": {
        "blobUri": null,
        "caching": "ReadWrite",
        "diskEncryptionSet": null,
        "diskSizeGb": 30,
        "managedDisk": {
          "id": "/subscriptions/xxxxx/resourceGroups/pkr-Resource-Group-sft8co2izw/providers/Microsoft.Compute/disks/pkrossft8co2izw",
          "resourceGroup": "pkr-Resource-Group-sft8co2izw"
        },
        "osState": "Generalized",
        "osType": "Linux",
        "snapshot": null,
        "storageAccountType": "Standard_LRS"
      },
      "zoneResilient": false
    },
    "tags": {},
    "type": "Microsoft.Compute/images"
  }
]'
echo $images | jq -r ".[].name" | grep "$query" | tail -n 1
+++ jq -r '.[].name'
+++ grep axiom-eastus
+++ echo '[' '{' '"hyperVGeneration":' '"V2",' '"id":' '"/subscriptions/xxxxx/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-eastus-1616176463",' '"location":' '"eastus",' '"name":' '"axiom-eastus-1616176463",' '"provisioningState":' '"Succeeded",' '"resourceGroup":' '"AXIOM",' '"sourceVirtualMachine":' '{' '"id":' '"/subscriptions/xxxxx/resourceGroups/pkr-Resource-Group-vj5o7w56xd/providers/Microsoft.Compute/virtualMachines/pkrvmvj5o7w56xd",' '"resourceGroup":' '"pkr-Resource-Group-vj5o7w56xd"' '},' '"storageProfile":' '{' '"dataDisks":' '[],' '"osDisk":' '{' '"blobUri":' null, '"caching":' '"ReadWrite",' '"diskEncryptionSet":' null, '"diskSizeGb":' 30, '"managedDisk":' '{' '"id":' '"/subscriptions/xxxxx/resourceGroups/pkr-Resource-Group-vj5o7w56xd/providers/Microsoft.Compute/disks/pkrosvj5o7w56xd",' '"resourceGroup":' '"pkr-Resource-Group-vj5o7w56xd"' '},' '"osState":' '"Generalized",' '"osType":' '"Linux",' '"snapshot":' null, '"storageAccountType":' '"Standard_LRS"' '},' '"zoneResilient":' false '},' '"tags":' '{},' '"type":' '"Microsoft.Compute/images"' '},' '{' '"hyperVGeneration":' '"V2",' '"id":' '"/subscriptions/xxxxx/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-eastus-1616523460",' '"location":' '"eastus",' '"name":' '"axiom-eastus-1616523460",' '"provisioningState":' '"Succeeded",' '"resourceGroup":' '"AXIOM",' '"sourceVirtualMachine":' '{' '"id":' '"/subscriptions/xxxxx/resourceGroups/pkr-Resource-Group-u6lxee50w5/providers/Microsoft.Compute/virtualMachines/pkrvmu6lxee50w5",' '"resourceGroup":' '"pkr-Resource-Group-u6lxee50w5"' '},' '"storageProfile":' '{' '"dataDisks":' '[],' '"osDisk":' '{' '"blobUri":' null, '"caching":' '"ReadWrite",' '"diskEncryptionSet":' null, '"diskSizeGb":' 30, '"managedDisk":' '{' '"id":' '"/subscriptions/xxxxx/resourceGroups/pkr-Resource-Group-u6lxee50w5/providers/Microsoft.Compute/disks/pkrosu6lxee50w5",' '"resourceGroup":' '"pkr-Resource-Group-u6lxee50w5"' '},' '"osState":' '"Generalized",' '"osType":' '"Linux",' '"snapshot":' null, '"storageAccountType":' '"Standard_LRS"' '},' '"zoneResilient":' false '},' '"tags":' '{},' '"type":' '"Microsoft.Compute/images"' '},' '{' '"hyperVGeneration":' '"V2",' '"id":' '"/subscriptions/xxxxx/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-eastus-1616611230",' '"location":' '"eastus",' '"name":' '"axiom-eastus-1616611230",' '"provisioningState":' '"Succeeded",' '"resourceGroup":' '"AXIOM",' '"sourceVirtualMachine":' '{' '"id":' '"/subscriptions/xxxxx/resourceGroups/pkr-Resource-Group-sft8co2izw/providers/Microsoft.Compute/virtualMachines/pkrvmsft8co2izw",' '"resourceGroup":' '"pkr-Resource-Group-sft8co2izw"' '},' '"storageProfile":' '{' '"dataDisks":' '[],' '"osDisk":' '{' '"blobUri":' null, '"caching":' '"ReadWrite",' '"diskEncryptionSet":' null, '"+++ tail -n 1
diskSizeGb":' 30, '"managedDisk":' '{' '"id":' '"/subscriptions/xxxxx/resourceGroups/pkr-Resource-Group-sft8co2izw/providers/Microsoft.Compute/disks/pkrossft8co2izw",' '"resourceGroup":' '"pkr-Resource-Group-sft8co2izw"' '},' '"osState":' '"Generalized",' '"osType":' '"Linux",' '"snapshot":' null, '"storageAccountType":' '"Standard_LRS"' '},' '"zoneResilient":' false '},' '"tags":' '{},' '"type":' '"Microsoft.Compute/images"' '}' ']'
++ name=axiom-eastus-1616611230
echo $images |  jq -r ".[] | select(.name==\"$name\") | .id"
+++ jq -r '.[] | select(.name=="axiom-eastus-1616611230") | .id'
+++ echo '[' '{' '"hyperVGeneration":' '"V2",' '"id":' '"/subscriptions/xxxxx/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-eastus-1616176463",' '"location":' '"eastus",' '"name":' '"axiom-eastus-1616176463",' '"provisioningState":' '"Succeeded",' '"resourceGroup":' '"AXIOM",' '"sourceVirtualMachine":' '{' '"id":' '"/subscriptions/xxxxx/resourceGroups/pkr-Resource-Group-vj5o7w56xd/providers/Microsoft.Compute/virtualMachines/pkrvmvj5o7w56xd",' '"resourceGroup":' '"pkr-Resource-Group-vj5o7w56xd"' '},' '"storageProfile":' '{' '"dataDisks":' '[],' '"osDisk":' '{' '"blobUri":' null, '"caching":' '"ReadWrite",' '"diskEncryptionSet":' null, '"diskSizeGb":' 30, '"managedDisk":' '{' '"id":' '"/subscriptions/xxxxx/resourceGroups/pkr-Resource-Group-vj5o7w56xd/providers/Microsoft.Compute/disks/pkrosvj5o7w56xd",' '"resourceGroup":' '"pkr-Resource-Group-vj5o7w56xd"' '},' '"osState":' '"Generalized",' '"osType":' '"Linux",' '"snapshot":' null, '"storageAccountType":' '"Standard_LRS"' '},' '"zoneResilient":' false '},' '"tags":' '{},' '"type":' '"Microsoft.Compute/images"' '},' '{' '"hyperVGeneration":' '"V2",' '"id":' '"/subscriptions/xxxxx/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-eastus-1616523460",' '"location":' '"eastus",' '"name":' '"axiom-eastus-1616523460",' '"provisioningState":' '"Succeeded",' '"resourceGroup":' '"AXIOM",' '"sourceVirtualMachine":' '{' '"id":' '"/subscriptions/xxxxx/resourceGroups/pkr-Resource-Group-u6lxee50w5/providers/Microsoft.Compute/virtualMachines/pkrvmu6lxee50w5",' '"resourceGroup":' '"pkr-Resource-Group-u6lxee50w5"' '},' '"storageProfile":' '{' '"dataDisks":' '[],' '"osDisk":' '{' '"blobUri":' null, '"caching":' '"ReadWrite",' '"diskEncryptionSet":' null, '"diskSizeGb":' 30, '"managedDisk":' '{' '"id":' '"/subscriptions/xxxxx/resourceGroups/pkr-Resource-Group-u6lxee50w5/providers/Microsoft.Compute/disks/pkrosu6lxee50w5",' '"resourceGroup":' '"pkr-Resource-Group-u6lxee50w5"' '},' '"osState":' '"Generalized",' '"osType":' '"Linux",' '"snapshot":' null, '"storageAccountType":' '"Standard_LRS"' '},' '"zoneResilient":' false '},' '"tags":' '{},' '"type":' '"Microsoft.Compute/images"' '},' '{' '"hyperVGeneration":' '"V2",' '"id":' '"/subscriptions/xxxxx/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-eastus-1616611230",' '"location":' '"eastus",' '"name":' '"axiom-eastus-1616611230",' '"provisioningState":' '"Succeeded",' '"resourceGroup":' '"AXIOM",' '"sourceVirtualMachine":' '{' '"id":' '"/subscriptions/xxxxx/resourceGroups/pkr-Resource-Group-sft8co2izw/providers/Microsoft.Compute/virtualMachines/pkrvmsft8co2izw",' '"resourceGroup":' '"pkr-Resource-Group-sft8co2izw"' '},' '"storageProfile":' '{' '"dataDisks":' '[],' '"osDisk":' '{' '"blobUri":' null, '"caching":' '"ReadWrite",' '"diskEncryptionSet":' null, '"diskSizeGb":' 30, '"managedDisk":' '{' '"id":' '"/subscriptions/xxxxx/resourceGroups/pkr-Resource-Group-sft8co2izw/providers/Microsoft.Compute/disks/pkrossft8co2izw",' '"resourceGroup":' '"pkr-Resource-Group-sft8co2izw"' '},' '"osState":' '"Generalized",' '"osType":' '"Linux",' '"snapshot":' null, '"storageAccountType":' '"Standard_LRS"' '},' '"zoneResilient":' false '},' '"tags":' '{},' '"type":' '"Microsoft.Compute/images"' '}' ']'
++ id=/subscriptions/xxxxx/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-eastus-1616611230
++ echo /subscriptions/xxxxx/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-eastus-1616611230
+ image_id=/subscriptions/xxxxx/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-eastus-1616611230

show_spinner() {
    local -r pid="${1}"
    # This delay is very carefully selected, as it makes makes the spinup feelfaster!!!
    local -r delay='0.48'
    # I picked 230 because it's slightly too high, you'll feel happy abouta fast spin time ;_
    i=420
    while ps a | awk '{print $1}' | grep -q "${pid}"; do
        echo -ne "${BWhite}>> T-Minus $i to full initialization...${Color_Off}\r"
        : $((i--))
        sleep "$delay"
    done
    printf "    \b\b\b\b"
}

waitabit() {
    local -r pid="${1}"
    # This delay is very carefully selected, as it makes makes the spinup feelfaster!!!
    local -r delay='0.38'
    # I picked 230 because it's slightly too high, you'll feel happy abouta fast spin time ;_
    i=420
    while ps a | awk '{print $1}' | grep -q "${pid}"; do
        : $((i--))
        sleep "$delay"
    done
    printf "    \b\b\b\b"
}

mkdir -p "$AXIOM_PATH/tmp/"
+ mkdir -p /Users/XXXXXXXXX/.axiom/tmp/

if [ -z "$image_id" ]; then
    echo -e "${BRed}An image has not been found in this region. Do you need to run 'axiom-build'?${Color_Off}"
    exit 1
fi
+ '[' -z /subscriptions/xxxxx/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-eastus-1616611230 ']'

if [[ "$user_region" == "" ]]; then
    user_region="$region"
fi
+ [[ '' == '' ]]
+ user_region=eastus

create_instance "$name" "$image_id" "$size" "$user_region" &
PID="$!"
+ PID=8564
if [ "$quiet" != "true" ]; then
    show_spinner "$PID"
else
    waitabit "$PID"
fi
+ '[' false '!=' true ']'
+ show_spinner 8564
+ local -r pid=8564
+ local -r delay=0.48
+ i=420
+ create_instance brown17 /subscriptions/xxxxx/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-eastus-1616611230 Standard_B1s eastus
+ name=brown17
+ image_id=/subscriptions/xxxxx/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-eastus-1616611230
+ size_slug=Standard_B1s
+ region=eastus
+ boot_script=
+ ps a
+ awk '{print $1}'
az account list-locations | jq -r ".[] | select(.name==\"$region\") | .displayName"
+ grep -q 8564
++ az account list-locations
++ jq -r '.[] | select(.name=="eastus") | .displayName'
+ echo -ne '\033[1;37m>> T-Minus 420 to full initialization...\033[0m\r'
+ : 420nus 420 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 419 to full initialization...\033[0m\r'
+ : 419nus 419 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 418 to full initialization...\033[0m\r'
+ : 418nus 418 to full initialization...
+ sleep 0.48
+ location='East US'
+ az vm create --resource-group axiom --name brown17 --image /subscriptions/xxxxx/resourceGroups/AXIOM/providers/Microsoft.Compute/images/axiom-eastus-1616611230 --location 'East US' --size Standard_B1s
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 417 to full initialization...\033[0m\r'
+ : 417nus 417 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 416 to full initialization...\033[0m\r'
+ : 416nus 416 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 415 to full initialization...\033[0m\r'
+ : 415nus 415 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 414 to full initialization...\033[0m\r'
+ : 414nus 414 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 413 to full initialization...\033[0m\r'
+ : 413nus 413 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 412 to full initialization...\033[0m\r'
+ : 412nus 412 to full initialization...
+ sleep 0.48
+ az vm open-port --resource-group axiom --name brown17 --port 0-65535
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 411 to full initialization...\033[0m\r'
+ : 411nus 411 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 410 to full initialization...\033[0m\r'
+ : 410nus 410 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 409 to full initialization...\033[0m\r'
+ : 409nus 409 to full initialization...
+ sleep 0.48
+ sleep 10
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 408 to full initialization...\033[0m\r'
+ : 408nus 408 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 407 to full initialization...\033[0m\r'
+ : 407nus 407 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 406 to full initialization...\033[0m\r'
+ : 406nus 406 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 405 to full initialization...\033[0m\r'
+ : 405nus 405 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 404 to full initialization...\033[0m\r'
+ : 404nus 404 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 403 to full initialization...\033[0m\r'
+ : 403nus 403 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 402 to full initialization...\033[0m\r'
+ : 402nus 402 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 401 to full initialization...\033[0m\r'
+ : 401nus 401 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 400 to full initialization...\033[0m\r'
+ : 400nus 400 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 399 to full initialization...\033[0m\r'
+ : 399nus 399 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 398 to full initialization...\033[0m\r'
+ : 398nus 398 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 397 to full initialization...\033[0m\r'
+ : 397nus 397 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 396 to full initialization...\033[0m\r'
+ : 396nus 396 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 395 to full initialization...\033[0m\r'
+ : 395nus 395 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 394 to full initialization...\033[0m\r'
+ : 394nus 394 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 393 to full initialization...\033[0m\r'
+ : 393nus 393 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 392 to full initialization...\033[0m\r'
+ : 392nus 392 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ echo -ne '\033[1;37m>> T-Minus 391 to full initialization...\033[0m\r'
+ : 391nus 391 to full initialization...
+ sleep 0.48
+ ps a
+ awk '{print $1}'
+ grep -q 8564
+ printf '    \b\b\b\b'

if [ "$quiet" != "true" ]; then
    secs=$((20))
    while [ $secs -gt 0 ]; do
        echo -ne "${BWhite}>> T-Minus $secs to full initialization...${Color_Off}\r"
        sleep 1
        : $((secs--))
    done
else
    sleep 20
fi
+ '[' false '!=' true ']'
+ secs=20
+ '[' 20 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 20 to full initialization...\033[0m\r'
+ sleep 1s 20 to full initialization...
+ : 20
+ '[' 19 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 19 to full initialization...\033[0m\r'
+ sleep 1s 19 to full initialization...
+ : 19
+ '[' 18 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 18 to full initialization...\033[0m\r'
+ sleep 1s 18 to full initialization...
+ : 18
+ '[' 17 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 17 to full initialization...\033[0m\r'
+ sleep 1s 17 to full initialization...
+ : 17
+ '[' 16 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 16 to full initialization...\033[0m\r'
+ sleep 1s 16 to full initialization...
+ : 16
+ '[' 15 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 15 to full initialization...\033[0m\r'
+ sleep 1s 15 to full initialization...
+ : 15
+ '[' 14 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 14 to full initialization...\033[0m\r'
+ sleep 1s 14 to full initialization...
+ : 14
+ '[' 13 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 13 to full initialization...\033[0m\r'
+ sleep 1s 13 to full initialization...
+ : 13
+ '[' 12 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 12 to full initialization...\033[0m\r'
+ sleep 1s 12 to full initialization...
+ : 12
+ '[' 11 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 11 to full initialization...\033[0m\r'
+ sleep 1s 11 to full initialization...
+ : 11
+ '[' 10 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 10 to full initialization...\033[0m\r'
+ sleep 1s 10 to full initialization...
+ : 10
+ '[' 9 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 9 to full initialization...\033[0m\r'
+ sleep 1s 9 to full initialization...
+ : 9
+ '[' 8 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 8 to full initialization...\033[0m\r'
+ sleep 1s 8 to full initialization...
+ : 8
+ '[' 7 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 7 to full initialization...\033[0m\r'
+ sleep 1s 7 to full initialization...
+ : 7
+ '[' 6 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 6 to full initialization...\033[0m\r'
+ sleep 1s 6 to full initialization...
+ : 6
+ '[' 5 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 5 to full initialization...\033[0m\r'
+ sleep 1s 5 to full initialization...
+ : 5
+ '[' 4 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 4 to full initialization...\033[0m\r'
+ sleep 1s 4 to full initialization...
+ : 4
+ '[' 3 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 3 to full initialization...\033[0m\r'
+ sleep 1s 3 to full initialization...
+ : 3
+ '[' 2 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 2 to full initialization...\033[0m\r'
+ sleep 1s 2 to full initialization...
+ : 2
+ '[' 1 -gt 0 ']'
+ echo -ne '\033[1;37m>> T-Minus 1 to full initialization...\033[0m\r'
+ sleep 1s 1 to full initialization...
+ : 1
+ '[' 0 -gt 0 ']'

ip="$(instance_ip "$name")"
instance_ip "$name"
++ instance_ip brown17
++ name=brown17
++ az vm list-ip-addresses
++ jq -r '.[].virtualMachine | select(.name=="brown17") | .network.publicIpAddresses[].ipAddress'
WARNING: Command group 'vm' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus
+ ip=
ssh-keygen -R "[$ip]:2266" >>  /dev/null 2>&1
+ ssh-keygen -R '[]:2266'

if [[ "$no_select" != "true" ]]; then
    echo "$name" > $AXIOM_PATH/selected.conf
fi
+ [[ false != \t\r\u\e ]]
+ echo brown17

if [[ "$no_select" != "true" ]]; then
    "$NOTIFY_CMD" "Axiom Info" "$name successfully initialized at $ip!"
fi
+ [[ false != \t\r\u\e ]]
+ notifyOSX 'Axiom Info' 'brown17 successfully initialized at !'
+ osascript -e 'display notification "brown17 successfully initialized at !" with title "Axiom Info"'
echo -e "${BWhite}Initialized instance '${BGreen}$name${Color_Off}${BWhite}' at '${BGreen}$ip${BWhite}'!"
+ echo -e '\033[1;37mInitialized instance '\''\033[1;32mbrown17\033[0m\033[1;37m'\'' at '\''\033[1;32m\033[1;37m'\''!'
Initialized instance 'brown17' at ''!

if [ "$quiet" != "true" ]; then
    echo -e "${BWhite}To connect, run '${BGreen}axiom-ssh $name${Color_Off}'${BWhite} or '${BGreen}axiom-connect'${Color_Off}"
fi
+ '[' false '!=' true ']'
+ echo -e '\033[1;37mTo connect, run '\''\033[1;32maxiom-ssh brown17\033[0m'\''\033[1;37m or '\''\033[1;32maxiom-connect'\''\033[0m'
To connect, run 'axiom-ssh brown17' or 'axiom-connect'

axiom-exec "touch /tmp/.connected" "$name" -q >> /dev/null 2>&1
+ axiom-exec 'touch /tmp/.connected' brown17 -q

if [ "$restore" != false ]; then
    #echo -e "${BWhite}Waiting 65 seconds before restore...${Color_Off}"
    $AXIOM_PATH/interact/axiom-restore "$restore" "$name"
fi
+ '[' false '!=' false ']'

if [ "$deploy" != false ]; then
    #echo -e "${BWhite}Waiting 65 seconds before deploy... ${Color_Off}"
    $AXIOM_PATH/interact/axiom-deploy "$deploy" "$name"
fi
+ '[' false '!=' false ']'

#if [ "$domain" != false ]; then
##  echo -e "${BWhite}Adding DNS record $name.$domain to -> $ip"
#   $AXIOM_PATH/interact/axiom-dns add $name $domain $ip
#fi

$AXIOM_PATH/interact/header.sh
+ /Users/XXXXXXXXX/.axiom/interact/header.sh```
0xtavian commented 3 years ago

@ResistanceIsUseless after provisioning an instance like that, can you ssh into it and axiom is set up? That is an odd issue, and I havent read anything to suggest the username is required. Can you try to run axiom-build again and see if that makes a difference? If that doesnt work, I would suggest setting up axiom on a fresh VPS or VM to test. I still havent had time to attempt an azure fleet, I hope to have some time tonight. Reach out to us on Discord as well if you are still experiencing issues. Thanks you!

cthulhu897 commented 3 years ago

I'd suggest removing ~/.axiom and also all the resources in your azure panel, and then try it again. I think that axiom-rm or some of its inner mechanisms could have a bug during the deletion of the resources, so my guess is something between your local install and the remote objects is not working right, and the script seems to not remove faulty assets properly, so it reuses the faulty image.

ResistanceIsUseless commented 3 years ago

Everything works as expected when provisioning like this. So I'm guessing its just me. If it causes any issues I'll delete everything and start over.