Skip to content

Commit be05c29

Browse files
committed
Allow spinning up different network versions
Resolves getumbrel#3
1 parent f463db2 commit be05c29

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

Vagrantfile

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@ umbrelLogo = <<-TEXT
2121
"%GGGGGG#"
2222
TEXT
2323

24+
network = File.open("network").read.strip
25+
2426
Vagrant.configure(2) do |config|
2527
# Install required plugins
2628
config.vagrant.plugins = {"vagrant-vbguest" => {"version" => "0.24.0"}}
2729

2830
# Setup VM
29-
config.vm.define "umbrel-dev"
31+
config.vm.define "#{network}-umbrel-dev"
3032
config.vm.box = "debian/buster64"
31-
config.vm.hostname = "umbrel-dev"
33+
config.vm.hostname = "#{network}-umbrel-dev"
3234
config.vm.network "public_network", bridge: "en0: Wi-Fi (AirPort)"
3335
config.vm.synced_folder ".", "/vagrant", type: "virtualbox"
3436

@@ -60,7 +62,7 @@ Vagrant.configure(2) do |config|
6062
config.vm.provision "shell", inline: <<-SHELL
6163
apt-get install -y fswatch rsync jq
6264
cd /vagrant/getumbrel/umbrel
63-
sudo NETWORK=regtest ./scripts/configure
65+
sudo NETWORK=#{network} ./scripts/configure
6466
docker-compose build --parallel
6567
docker-compose run dashboard -c yarn
6668
SHELL

umbrel-dev

+30-1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,34 @@ if [[ "$command" = "init" ]]; then
106106
exit 1
107107
fi
108108

109+
network="regtest"
110+
shift 1
111+
112+
while (( "$#" )); do
113+
case "$1" in
114+
-n|--network)
115+
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
116+
network=$2
117+
shift 2
118+
else
119+
echo "Error: Argument for $1 is missing" >&2
120+
exit 1
121+
fi
122+
;;
123+
-*|--*=) # unsupported flags
124+
echo "Error: Unsupported flag $1" >&2
125+
exit 1
126+
;;
127+
esac
128+
done
129+
130+
if [ "$network" != "mainnet" ] && [ "$network" != "testnet" ] && [ "$network" != "regtest" ]; then
131+
echo "Error: Umbrel dev can only be configured for regtest (default), testnet or mainnet"
132+
exit 1
133+
fi
134+
135+
echo "Network is $network"
136+
echo $network > "network"
109137
echo "Creating Vagrantfile..."
110138
cp "$(get_script_location)/Vagrantfile" .
111139

@@ -179,12 +207,13 @@ if [[ "$command" = "rebuild" ]]; then
179207
echo "A second argument is required!"
180208
exit 1
181209
fi
210+
network < "network"
182211
container="$2"
183212
run_in_vm " \
184213
docker-compose build $container \
185214
&& docker-compose stop $container \
186215
&& docker-compose rm -f $container \
187-
&& DEVICE_HOSTS=http://umbrel-dev.local docker-compose up -d $container"
216+
&& DEVICE_HOSTS=http://$network-umbrel-dev.local docker-compose up -d $container"
188217
exit
189218
fi
190219

0 commit comments

Comments
 (0)