-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
114 lines (94 loc) · 3.43 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
SHELL := $(shell which bash)
.SHELLFLAGS = -c
.SILENT: ; # no need for @
.ONESHELL: ; # recipes execute in same shell
.NOTPARALLEL: ; # wait for this target to finish
.EXPORT_ALL_VARIABLES: ; # send all vars to shell
PWD = $(shell pwd | sed 's/\ /\\\ /g')
BIN_BREW := $(shell brew --version 2>/dev/null)
BIN_VAGRANT := $(shell vagrant -v 2>/dev/null)
BIN_VIRTUALBOX := $(shell VBoxManage --version 2>/dev/null)
BIN_LIBRARIAN := $(shell librarian-chef version 2>/dev/null)
VAGRANT_PLUGINS := $(shell vagrant plugin list)
VAGRANT_ENVIRONMENT := $(shell uname -s)
default: vagrant-up
info:
@echo ""
@echo "make info"
@echo "make help"
@echo "make install"
@echo "make vagrant-up"
@echo "make check-environment"
@echo ""
help:
@echo "/giphy boobies"
install: check-environment download-chef-cookbooks vagrant-up
download-chef-cookbooks:
@echo "Downloading chef cookbooks."
cd $(PWD)/chef-repo ; librarian-chef install --clean --verbose
vagrant-up:
ifeq "$(wildcard chef-repo/cookbooks/apache2)" ""
@echo "Please run make install."
endif
ssh-add -K ~/.ssh/id_rsa ; vagrant up ; vagrant rsync-auto
vagrant-provision:
@if make .prompt-yesno message="Do you want to continue?" 2> /dev/null; then \
vagrant reload --provision
fi; \
vagrant-destroy:
@if make .prompt-yesno message="Do you want to continue?" 2> /dev/null; then \
vagrant destroy -f
fi; \
check-environment: check-environment-virtualbox check-environment-vagrant check-environment-librarian check-vagrant-plugins
check-environment-virtualbox:
ifndef BIN_VIRTUALBOX
@echo "Virtualbox has not been installed yet."
@echo "Please install the latest version from https://www.virtualbox.org/wiki/Downloads."
exit 2;
endif
@echo "Virtualbox: OK"
check-environment-vagrant:
ifndef BIN_VAGRANT
@echo "Vagrant has not been installed yet."
@echo "Please install the version 1.7.1 from http://www.vagrantup.com/download-archive/v1.7.1.html."
exit 2;
endif
@echo "Vagrant: OK"
check-environment-librarian:
ifndef BIN_LIBRARIAN
@echo "Chef-Librarion has not been installed."
@echo "Installing Chef-Librarion."
gem install librarian-chef
endif
@echo "Chef-Librarian: OK"
check-environment-brew:
ifndef BIN_BREW
@echo "Homebrew has not been installed yet."
ifneq ($(UNAME),Linux)
exit 2;
endif
endif
@echo "Homebrew: OK"
check-vagrant-plugins: check-environment-vagrant
make .install-vagrant-plugin plugin=vagrant-cachier version=1.2.0
make .install-vagrant-plugin plugin=vagrant-hostmanager version=1.5.0
make .install-vagrant-plugin plugin=vagrant-hosts version=2.4.0
make .install-vagrant-plugin plugin=vagrant-hostsupdater version=0.0.11
make .install-vagrant-plugin plugin=vagrant-omnibus version=1.4.1
make .install-vagrant-plugin plugin=vagrant-persistent-storage version=0.0.16
make .install-vagrant-plugin plugin=vagrant-reload version=0.0.1
make .install-vagrant-plugin plugin=vagrant-share version=1.1.4
make .install-vagrant-plugin plugin=vagrant-triggers version=0.5.0
make .install-vagrant-plugin plugin=vagrant-vbguest version=0.10.0
.prompt-yesno:
@exec 9<&0 0</dev/tty
echo "$(message) [Y]:"
[[ -z $$FOUNDATION_NO_WAIT ]] && read -rs -t5 -n 1 yn;
exec 0<&9 9<&-
[[ -z $$yn ]] || [[ $$yn == [yY] ]] && echo Y >&2 || (echo N >&2 && exit 1)
.install-vagrant-plugin:
ifneq (,$(findstring $(plugin), $(VAGRANT_PLUGINS)))
@echo "Vagrant plugin $(plugin) is already installed."
else
vagrant plugin install $(plugin) --plugin-version '$(version)'
endif