-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
96 lines (74 loc) · 2.04 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
init: vm uuid2mac
vm:
@$(MAKE) -sC vm
upgrade:
@$(MAKE) -C vm upgrade
clean destroy: uuid2mac-clean
$(MAKE) -C vm clean
.PHONY: init vm upgrade clean destroy
#
# Commands
#
IP_ADDR := `bin/mac2ip.sh $$(cat vm/.mac_address)`
USERNAME := $(shell make -sC vm username)
PASSWORD := $(shell make -sC vm password)
SSH_ARGS := $(shell make -sC vm ssh_args)
run up: | init
@sudo echo "Booting up..." # to input password at the current window in advance
@bin/xhyveexec.sh "$(SHARED_FOLDER)"
mac: | status
@cat vm/.mac_address
ip: | status
@echo $(IP_ADDR)
ssh: | status
@expect -c ' \
spawn -noecho ssh $(USERNAME)@'$(IP_ADDR)' $(SSH_ARGS) $(filter-out $@,$(MAKECMDGOALS)); \
expect "(yes/no)?" { send "yes\r"; exp_continue; } "password:" { send "$(PASSWORD)\r"; }; \
interact; \
'
halt: | status
@expect -c ' \
spawn -noecho ssh $(USERNAME)@'$(IP_ADDR)' $(SSH_ARGS) sudo halt; \
expect "(yes/no)?" { send "yes\r"; exp_continue; } "password:" { send "$(PASSWORD)\r"; }; \
interact; \
'
@echo "Shutting down..."
reboot reload: | status
@expect -c ' \
spawn -noecho ssh $(USERNAME)@'$(IP_ADDR)' $(SSH_ARGS) sudo reboot; \
expect "(yes/no)?" { send "yes\r"; exp_continue; } "password:" { send "$(PASSWORD)\r"; }; \
interact; \
'
@echo "Rebooting..."
env: | status
@echo "export DOCKER_HOST=tcp://$(IP_ADDR):2375;"
@echo "unset DOCKER_CERT_PATH;"
@echo "unset DOCKER_TLS_VERIFY;"
status:
@if [ ! -f vm/.mac_address ]; then \
echo "barge-xhyve: stopped"; \
exit 1; \
else \
if ping -c 1 -t 1 $(IP_ADDR) >/dev/null 2>&1; then \
echo "barge-xhyve: running on $(IP_ADDR)"; \
else \
echo "barge-xhyve: starting"; \
exit 1; \
fi; \
fi >&2;
version: | status
@make ssh cat /etc/os-release 2>/dev/null | sed -n 's/^VERSION=\(.*\)$$/v\1/p'
.PHONY: run up mac ip ssh halt reboot reload env status version
.DEFAULT:
@:
#
# Helpers
#
uuid2mac: bin/uuid2mac
bin/uuid2mac:
$(MAKE) -C uuid2mac
@install -CSv uuid2mac/build/uuid2mac bin/
uuid2mac-clean:
$(MAKE) -C uuid2mac clean
$(RM) bin/uuid2mac
.PHONY: uuid2mac uuid2mac-clean