Created
December 17, 2021 20:45
-
-
Save chrisbergeron/b7d9e3032a7a4903a7a6b6b3458b946c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
## Get and run consul agent from within VMM ignite-firecracker | |
app="consul" | |
echo "Creating /tmp/${app}" | |
mkdir -p /tmp/${app} > /dev/null 2>&1 | |
cat << EON > /tmp/${app}-config.json | |
{ | |
"server": false, | |
"datacenter": "mlb", | |
"domain": "chrisbergeron.com", | |
"data_dir": "/tmp/consul-dir", | |
"enable_syslog": true, | |
"enable_script_checks": true, | |
"ui_config": { "enabled": true }, | |
"telemetry": { "disable_compat_1.9": true }, | |
"bind_addr": "{{ GetPrivateInterfaces | include \"network\" \"192.168.0.0/24\" | attr \"address\" }}", | |
"encrypt": "${CONSUL_TOKEN}", | |
"node_name": "$(hostname)", | |
"client_addr": "$(ip addr | grep 192 | tr -s " " | cut -f1 -d "/" | cut -f3 -d " ")", | |
"rejoin_after_leave": true, | |
"retry_join": [ | |
"192.168.0.243", | |
"192.168.0.158" | |
], | |
"dns_config": { | |
"node_ttl": "1m", | |
"service_ttl": { | |
"*": "1m" | |
} | |
}, | |
"addresses": { | |
"dns": "127.0.0.1 {{GetPrivateIP}}", | |
"grpc": "127.0.0.1 {{GetPrivateIP}}", | |
"https": "127.0.0.1 {{GetPrivateIP}}" | |
}, | |
"ports": { | |
"https": 8501, | |
"grpc": 8502 | |
}, | |
"connect": { "enabled": true }, | |
"key_file": "/tmp/privkey.pem", | |
"cert_file": "/tmp/cert.pem", | |
"ca_file": "/tmp/chain.pem" | |
} | |
EON | |
latest=$(curl -s GET https://api.github.com/repos/hashicorp/${app}/tags | grep --color=never "name" | cut -f2 -d ":" | cut -f2 -d "\"" | head -n1 | cut -f2 -d"v") | |
# 32 bit | |
# https://releases.hashicorp.com/${app}/1.2.2/${app}_1.2.2_linux_386.zip | |
# 64 bit | |
# https://releases.hashicorp.com/${app}/1.2.2/${app}_1.2.2_linux_amd64.zip | |
# arm 64 | |
# https://releases.hashicorp.com/${app}/1.2.2/${app}_1.2.2_linux_arm64.zip | |
# arm | |
# https://releases.hashicorp.com/${app}/1.2.2/${app}_1.2.2_linux_arm.zip | |
thisarch=$(uname -m) | |
case "${thisarch}" in | |
"armv7") archstr="arm";; # Pi | |
"armv7l") archstr="arm";; # Pi 4 | |
"arm64") archstr="arm64";; # M1 | |
"x86_64") archstr="amd64";; # x86 | |
"i386") archstr="386";; # old x86 | |
*) echo "Couldn't determine archstr from ${thisarch}"; exit 1;; | |
esac | |
echo "thisarch is: ${thisarch}; archstr is ${archstr}" | |
#exit | |
cd /tmp | |
echo "Removing any existing ${app} artifacts..." | |
rm -rf /tmp/${app} | |
rm -rf /tmp/consul-dir | |
#rm -rf /tmp/alloc/ | |
#rm -rf /tmp/checkpoint-signature | |
echo curl -ks "https://releases.hashicorp.com/${app}/${latest}/${app}_${latest}_linux_${archstr}.zip -o - | busybox unzip -" | |
curl -ks "https://releases.hashicorp.com/${app}/${latest}/${app}_${latest}_linux_${archstr}.zip" -o - | busybox unzip - | |
chmod oag+x /tmp/${app} | |
echo "Starting ${app} as client ..." | |
echo /tmp/${app} agent -config-file=/tmp/${app}-config.json | |
/tmp/${app} agent -config-file=/tmp/{$app}-config.json > /tmp/${app}.log 2>&1 & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment