Skip to content

Commit

Permalink
Allow spinning up different network versions
Browse files Browse the repository at this point in the history
Resolves getumbrel#3
  • Loading branch information
bezysoftware committed Apr 6, 2021
1 parent f463db2 commit be05c29
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
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

0 comments on commit be05c29

Please sign in to comment.