net/ can now deploy Snaps
This commit is contained in:
43
net/gce.sh
43
net/gce.sh
@ -29,7 +29,7 @@ usage() {
|
||||
cat <<EOF
|
||||
usage: $0 [create|config|delete] [common options] [command-specific options]
|
||||
|
||||
Manage a GCE-based testnet
|
||||
Configure a GCE-based testnet
|
||||
|
||||
create - create a new testnet (implies 'config')
|
||||
config - configure the testnet and write a config file describing it
|
||||
@ -40,11 +40,11 @@ Manage a GCE-based testnet
|
||||
(default: $prefix)
|
||||
|
||||
create-specific options:
|
||||
-n number - Number of validator nodes (default: $validatorNodeCount)
|
||||
-c number - Number of client nodes (default: $clientNodeCount)
|
||||
-P - Use GCE internal/private network (default: $internalNetwork)
|
||||
-z - GCP Zone for the nodes (default: $zone)
|
||||
-i imageName - Existing image on GCE (default: $imageName)
|
||||
-n number - Number of validator nodes (default: $validatorNodeCount)
|
||||
-c number - Number of client nodes (default: $clientNodeCount)
|
||||
-P - Use GCE internal/private network (default: $internalNetwork)
|
||||
-z - GCP Zone for the nodes (default: $zone)
|
||||
-i imageName - Existing image on GCE (default: $imageName)
|
||||
|
||||
config-specific options:
|
||||
none
|
||||
@ -92,9 +92,11 @@ while getopts "h?p:Pi:n:c:z:" opt; do
|
||||
done
|
||||
|
||||
|
||||
writeConfigFile() {
|
||||
prepareInstancesAndWriteConfigFile() {
|
||||
echo "# autogenerated at $(date)" >> "$configFile"
|
||||
|
||||
echo "netBasename=$prefix" >> "$configFile"
|
||||
|
||||
declare sshPrivateKey="$netConfigDir/id_$prefix"
|
||||
rm -rf "$sshPrivateKey"{,.pub}
|
||||
(
|
||||
@ -117,17 +119,36 @@ writeConfigFile() {
|
||||
fi
|
||||
}
|
||||
|
||||
prepareInstance() {
|
||||
declare name="$1"
|
||||
declare publicIp="$3"
|
||||
|
||||
# TODO: Make the following a requirement of $imageName
|
||||
# instead of a manual install
|
||||
ssh "${sshOptions[@]}" "$publicIp" "
|
||||
set -ex;
|
||||
sudo systemctl disable apt-daily.service # disable run when system boot
|
||||
sudo systemctl disable apt-daily.timer # disable timer run
|
||||
sudo apt-get --assume-yes install rsync libssl-dev;
|
||||
mkdir -p ~/solana ~/.cargo/bin;
|
||||
"
|
||||
}
|
||||
|
||||
gcloud_FindInstances "name=$prefix-leader" show
|
||||
[[ ${#instances[@]} -eq 1 ]] || {
|
||||
echo "Unable to start leader"
|
||||
exit 1
|
||||
}
|
||||
gcloud_FigureRemoteUsername "${instances[0]}"
|
||||
echo "sshUsername=$gcloud_username" >> "$configFile"
|
||||
sshUsername=$gcloud_username
|
||||
echo "sshUsername=$sshUsername" >> "$configFile"
|
||||
buildSshOptions
|
||||
|
||||
gcloud_PrepInstancesForSsh "$gcloud_username" "$sshPrivateKey"
|
||||
|
||||
echo "leaderIp=()" >> "$configFile"
|
||||
gcloud_ForEachInstance recordInstanceIp leaderIp
|
||||
gcloud_ForEachInstance prepareInstance
|
||||
|
||||
gcloud_FindInstances "name~^$prefix-validator" show
|
||||
[[ ${#instances[@]} -gt 0 ]] || {
|
||||
@ -137,12 +158,14 @@ writeConfigFile() {
|
||||
echo "validatorIpList=()" >> "$configFile"
|
||||
gcloud_PrepInstancesForSsh "$gcloud_username" "$sshPrivateKey"
|
||||
gcloud_ForEachInstance recordInstanceIp validatorIpList
|
||||
gcloud_ForEachInstance prepareInstance
|
||||
|
||||
echo "clientIpList=()" >> "$configFile"
|
||||
gcloud_FindInstances "name~^$prefix-client" show
|
||||
if [[ ${#instances[@]} -gt 0 ]]; then
|
||||
gcloud_PrepInstancesForSsh "$gcloud_username" "$sshPrivateKey"
|
||||
gcloud_ForEachInstance recordInstanceIp clientIpList
|
||||
gcloud_ForEachInstance prepareInstance
|
||||
fi
|
||||
|
||||
echo "Wrote $configFile"
|
||||
@ -177,11 +200,11 @@ create)
|
||||
"$zone" "$imageName" "$clientMachineType" "$clientAccelerator"
|
||||
fi
|
||||
|
||||
writeConfigFile
|
||||
prepareInstancesAndWriteConfigFile
|
||||
;;
|
||||
|
||||
config)
|
||||
writeConfigFile
|
||||
prepareInstancesAndWriteConfigFile
|
||||
;;
|
||||
*)
|
||||
usage "Unknown command: $command"
|
||||
|
Reference in New Issue
Block a user