-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
231 lines (159 loc) · 6.15 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# Make file with rules to automatic install the environment
# defines the shell to the make application
SHELL := /bin/bash
# get the user name
USER_NAME := $(shell whoami)
# get the user home directory
USER_HOME := $(shell echo ${HOME})
# Directories
BASH_DIR := bash
GIT_DIR := git
NVIM_DIR := neovim
SSH_DIR := ssh
MYSQL_DIR := mysql
NGINX_DIR := nginx
UWSGI_DIR := uwsgi
MUTT_DIR := mutt
FISH_DIR := fish
TMUX_DIR := tmux
I3WM_DIR := i3wm
MPLAYER_DIR := mplayer
THIRD_PARTY := third-party
PYTHON_DIR := python
RUBY_DIR := ruby
OS_NAME := $(shell uname -s)
# Control colors by OS type
COLOR_PREFIX := e
ifeq ($(OS_NAME),Darwin)
COLOR_PREFIX := 033
endif
# Colors to messages during execution
BROWN=\$(COLOR_PREFIX)[0;33m
BLUE=\$(COLOR_PREFIX)[1;34m
END_COLOR=\$(COLOR_PREFIX)[0m
# sudo command
SUDO := $(which sudo)
# Package managers command line options
INSTALL_OPTS := -y
# Package Manager binary based on operating system
ifeq ($(OS_NAME),Darwin)
SUDO :=
INSTALL_OPTS :=
ifeq ($(shell test -e /usr/local/bin/brew && echo "exist"),exist)
PKGMGR=/usr/local/bin/brew
else
PKGMGR=/opt/homebrew/bin/brew
endif
endif
ifeq ($(OS_NAME),Linux)
PKGMGR := $(shell which zypper || which yum)
endif
.PHONY: install server nginx uwsgi fish python
# make variables public to other make files
export USER_NAME USER_HOME BROWN BLUE END_COLOR PKGMGR OS_NAME SUDO INSTALL_OPTS
############# ### ## #
# TARGETS
help: greetings
@echo
@echo "Panfiles available target rules"
@echo
@echo -e " $(BLUE)desktop$(END_COLOR) Installs all dependencies for a desktop machine"
@echo -e " $(BLUE)server$(END_COLOR) Installs all dependencies for a server machine"
@echo -e " $(BLUE)tiled$(END_COLOR) Install packages for a tiled desktop using i3wm"
@echo -e " $(BLUE)services$(END_COLOR) Install third part services on any machine"
@echo -e " $(BLUE)darwin$(END_COLOR) Install and configures a Mac OS X"
@echo
@echo "CI target rules"
@echo
@echo -e " $(BLUE)build_img$(END_COLOR) Builds locally a docker image for test installation"
@echo -e " $(BLUE)test_server$(END_COLOR) Tests fully installing a server machine"
@echo -e " $(BLUE)test_tilled$(END_COLOR) Tests fully installing a tilled system"
@echo -e " $(BLUE)test_desktop$(END_COLOR) Tests fully installing a desktop machine"
@echo
install: greetings shell versioning editor mail sshconfig mysqldb uwsgi bye
greetings: clear
@echo -e "${BROWN} \
██████ █████ ███ ██ ███████ ██ ██ ███████ ███████ \n \
██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ \n \
██████ ███████ ██ ██ ██ █████ ██ ██ █████ ███████ \n \
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ \n \
██ ██ ██ ██ ████ ██ ██ ███████ ███████ ███████ \n \
\n \
Setting up personal environments$(END_COLOR)"
clear:
clear
bye:
@echo -e "\n$(BROWN)open your mind, happy hacking :D$(END_COLOR)\n"
base_dirs:
@mkdir -pv $(HOME)/dev/{playground,tmp} # Base development directories
@mkdir -pv $(HOME)/.config/panfiles/ # Base Panfiles directory
shell: ${BASH_DIR}/Makefile
make install -C ${BASH_DIR}
enable_repos:
$(info Enable community repositories on the target OS)
ifeq ($(USER_NAME),ec2-user)
sudo amazon-linux-extras install epel -y
endif
fish: ${FISH_DIR}/Makefile
make install -C ${FISH_DIR}
terminal: ${TMUX_DIR}/Makefile
make install -C ${TMUX_DIR}
versioning: ${GIT_DIR}/Makefile
make install -C ${GIT_DIR}
editor: ${NVIM_DIR}/Makefile
make install -C ${NVIM_DIR}
sshconfig: ${SSH_DIR}/Makefile
make install -C ${SSH_DIR}
mysqldb: ${MYSQL_DIR}/Makefile
make install -C ${MYSQL_DIR}
uwsgi: ${UWSGI_DIR}/Makefile
make install -C ${UWSGI_DIR}
nginx: ${NGINX_DIR}/Makefile
make install -C ${NGINX_DIR}
mail: ${MUTT_DIR}/muttrc
make install -C ${MUTT_DIR}
deps: $(THIRD_PARTY)/Makefile
make install -C ${THIRD_PARTY}
.PHONY: ruby
ruby:
make install -C ${RUBY_DIR}
python: ${PYTHON_DIR}
make install -C ${PYTHON_DIR}
i3: ${I3WM_DIR}/config
make install -C ${I3WM_DIR}
videoplayer: ${MPLAYER_DIR}/config
make install -C ${MPLAYER_DIR}
# Install and configure a desktop machine
desktop: greetings base_dirs editor fish terminal versioning sshconfig deps bye
# Install dependencies for a tiling window manager
tiled: greetings python i3 mutt videoplayer bye
# Install and configure a server machine
server: greetings enable_repos shell versioning editor bye
# Install basic services on a machine
services: greetings mysqldb nginx uwsgi bye
.PHONY: brew
brew:
$(info Installing Homebrew package manager...)
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh > $@-tmp.sh
chmod +x $@-tmp.sh
./$@-tmp.sh
@rm -v $@-tmp.sh
# Install and configure a Mac OS X
.PHONY: darwin
darwin: greetings brew base_dirs versioning sshconfig fish terminal editor
$(PKGMGR) install $(shell cat $(THIRD_PARTY)/brew)
$(PKGMGR) install --cask $(shell cat $(THIRD_PARTY)/cask)
$(MAKE) bye
# Download and install docker dmg from https://desktop.docker.com/mac/main/amd64/Docker.dmg
# Builds locally a docker image for testing purpose
build_img: Dockerfile
docker build --tag panfiles:local . --no-cache
# Tests installing a server machine
test_server:
docker run -it --name $@ --rm panfiles:local make server
# Tests installing a tiled system
test_tiled:
docker run -it --name $@ --rm panfiles:local make tiled
# Tests installing a tiled system
test_desktop:
docker run -it --name $@ --rm panfiles:local make desktop