Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Allow spinning up different network versions #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ umbrelLogo = <<-TEXT
"%GGGGGG#"
TEXT

network = File.open("network").read.strip

Vagrant.configure(2) do |config|
# Install required plugins
config.vagrant.plugins = {"vagrant-vbguest" => {"version" => "0.24.0"}}

# Setup VM
config.vm.define "umbrel-dev"
config.vm.define "#{network}-umbrel-dev"
config.vm.box = "debian/buster64"
config.vm.hostname = "umbrel-dev"
config.vm.hostname = "#{network}-umbrel-dev"
config.vm.network "public_network", bridge: "en0: Wi-Fi (AirPort)"
config.vm.synced_folder ".", "/vagrant", type: "virtualbox"

Expand Down Expand Up @@ -60,7 +62,7 @@ Vagrant.configure(2) do |config|
config.vm.provision "shell", inline: <<-SHELL
apt-get install -y fswatch rsync jq
cd /vagrant/getumbrel/umbrel
sudo NETWORK=regtest ./scripts/configure
sudo NETWORK=#{network} ./scripts/configure
docker-compose build --parallel
docker-compose run dashboard -c yarn
SHELL
Expand Down
31 changes: 30 additions & 1 deletion umbrel-dev
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,34 @@ if [[ "$command" = "init" ]]; then
exit 1
fi

network="regtest"
shift 1

while (( "$#" )); do
case "$1" in
-n|--network)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
network=$2
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
-*|--*=) # unsupported flags
echo "Error: Unsupported flag $1" >&2
exit 1
;;
esac
done

if [ "$network" != "mainnet" ] && [ "$network" != "testnet" ] && [ "$network" != "regtest" ]; then
echo "Error: Umbrel dev can only be configured for regtest (default), testnet or mainnet"
exit 1
fi

echo "Network is $network"
echo $network > "network"
echo "Creating Vagrantfile..."
cp "$(get_script_location)/Vagrantfile" .

Expand Down Expand Up @@ -179,12 +207,13 @@ if [[ "$command" = "rebuild" ]]; then
echo "A second argument is required!"
exit 1
fi
network < "network"
container="$2"
run_in_vm " \
docker-compose build $container \
&& docker-compose stop $container \
&& docker-compose rm -f $container \
&& DEVICE_HOSTS=http://umbrel-dev.local docker-compose up -d $container"
&& DEVICE_HOSTS=http://$network-umbrel-dev.local docker-compose up -d $container"
exit
fi

Expand Down