forked from grantma/dms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
289 lines (275 loc) · 10.7 KB
/
Makefile
File metadata and controls
289 lines (275 loc) · 10.7 KB
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
#!/usr/bin/env make
#
# Copyright (c) Net24 Limited, Christchurch, New Zealand 2011-2012
# and Voyager Internet Ltd, New Zealand, 2012-2013
#
# This file is part of py-magcode-core.
#
# Py-magcode-core is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Py-magcode-core is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with py-magcode-core. If not, see <http://www.gnu.org/licenses/>.
#
DESTDIR =
#
# Installation Makefile for DMS
#
# This is rough! FIXME!
OSNAME := $(shell uname -s)
ETCDIR := /etc
DAEMONUSER := dmsdmd
DAEMONGROUP := dmsdmd
DMSGROUP := dms
CONFSUBDIRS := master-config-templates config-templates server-config-templates \
server-admin-config
CONFFILES = dms.conf rsync-dnsconf-password rsync-dnssec-password pgpassfile \
dr-settings.sh
CONFBINDFILES = named.conf named.conf.options named.conf.local named-dr-replica.conf
MASTERINCFILES = server-acl.conf zones.conf
WSGISCRIPTS = admin_dms.wsgi helpdesk_dms.wsgi value_reseller_dms.wsgi \
hosted_dms.wsgi
LISTZONEWSGISCRIPTS = list_zone.wsgi
ifeq ($(OSNAME), Linux)
PREFIX=/usr/local
CONFDIR=$(DESTDIR)$(ETCDIR)/dms
CONFBINDDIR=$(DESTDIR)$(ETCDIR)/dms/bind
SYSCTLDIR=$(DESTDIR)$(ETCDIR)/sysctl.d
NAMEDDATADIR=$(DESTDIR)/var/lib/bind
NAMEDDYNAMICDIR=$(DESTDIR)/var/lib/bind/dynamic
NAMEDKEYDIR=$(DESTDIR)/var/lib/bind/keys
NAMEDSLAVEDIR=$(DESTDIR)/var/cache/bind/slave
NAMEDSLAVELNDATA=../../cache/bind/slave
NAMEDSLAVELN=$(DESTDIR)/var/lib/bind/slave
NAMEDMASTERLNDATA=/etc/bind/master
NAMEDMASTERLN=$(DESTDIR)/var/lib/bind/master
NAMEDMASTERDIR=$(DESTDIR)$(ETCDIR)/bind/master
VARCONFDIR=$(DESTDIR)/var/lib/dms
NAMEDCONFDIR=$(DESTDIR)$(VARCONFDIR)/master-config
NAMEDSERVERCONFDIR=$(DESTDIR)$(VARCONFDIR)/rsync-config
RNDCCONFDIR=$(DESTDIR)$(VARCONFDIR)/rndc
LOGDIR=$(DESTDIR)/var/log/dms
RUNDIR=$(DESTDIR)/run/dms
BACKUPDIR=$(DESTDIR)/var/backups
PYTHON_INTERPRETER ?= /usr/bin/python3
PYTHON_SETUP_OPTS = --install-layout=deb
PGUSER=postgres
PGGROUP=postgres
else ifeq ($(OSNAME), FreeBSD)
PREFIX = /usr/local
CONFDIR = $(DESTDIR)$(PREFIX)$(ETCDIR)/dms
CONFBINDDIR=$(DESTDIR)$(PREFIX)$(ETCDIR)/dms/bind
NAMEDCONFDIR=$(DESTDIR)$(ETCDIR)/namedb/master-config
NAMEDSERVERCONFDIR=$(DESTDIR)$(ETCDIR)/namedb/rsync-config
RNDCCONFDIR=$(DESTDIR)$(ETCDIR)/nameddb
NAMEDDYNAMICDIR=$(DESTDIR)$(ETCDIR)/namedb/dynamic
NAMEDKEYDIR=$(DESTDIR)$(ETCDIR)/namedb/keys
VARCONFDIR = $(DESTDIR)/var/lib/dms
LOGDIR = $(DESTDIR)/var/log/dms
RUNDIR = $(DESTDIR)/var/run/dms
PYTHON_INTERPRETER ?= $(PREFIX)/bin/python3.2
PYTHON_SETUP_OPTS =
PGUSER=pgsql
PGGROUP=pgsql
else
PREFIX = /usr/local
CONFDIR = $(DESTDIR)$(PREFIX)/dms$(ETCDIR)
CONFBINDDIR=$(DESTDIR)$(PREFIX)/dms$(ETCDIR)/bind
NAMEDCONFDIR=$(DESTDIR)$(PREFIX)/namedb$(ETCDIR)/master-config
NAMEDSERVERCONFDIR=$(DESTDIR)$(PREFIX)/namedb$(ETCDIR)/rsync-config
RNDCCONFDIR=$(DESTDIR)$(PREFIX)/namedb$(ETCDIR)
NAMEDDYNAMICDIR=$(DESTDIR)$(PREFIX)/namedb$(ETCDIR)/dynamic
NAMEDKEYDIR=$(DESTDIR)$(PREFIX)/namedb$(ETCDIR)/keys
VARCONFDIR = $(DESTDIR)$(PREFIX)/dms/var
LOGDIR = $(DESTDIR)$(PREFIX)/dms/log
RUNDIR = $(DESTDIR)$(PREFIX)/dms/var
PYTHON_INTERPRETER ?= $(PREFIX)/bin/python3.2
PYTHON_SETUP_OPTS =
PGUSER=pgsql
PGGROUP=pgsql
endif
SHAREDIR = $(DESTDIR)$(PREFIX)/share/dms
BINDIR = $(DESTDIR)$(PREFIX)/bin
SBINDIR = $(DESTDIR)$(PREFIX)/sbin
MANDIR = $(DESTDIR)$(PREFIX)/man
INSTALL = /usr/bin/install
.PHONY: install install-dir install-conf install-python install-bin \
install-wsgi clean clean-python build-python
all: build-python
install: install-conf install-bin install-wsgi
install-dir:
- $(INSTALL) -d $(BINDIR)
- $(INSTALL) -d $(SBINDIR)
- $(INSTALL) -d $(MANDIR)
- $(INSTALL) -d $(CONFDIR)
- $(INSTALL) -d $(CONFBINDDIR)
- $(INSTALL) -d $(NAMEDCONFDIR)
- $(INSTALL) -d $(NAMEDSERVERCONFDIR)
- $(INSTALL) -d $(NAMEDDYNAMICDIR)
- $(INSTALL) -d $(NAMEDKEYDIR)
- $(INSTALL) -d $(RNDCCONFDIR)
- $(INSTALL) -d $(VARCONFDIR)/dms-sg
- $(INSTALL) -d $(LOGDIR)
- $(INSTALL) -d $(RUNDIR)
- $(INSTALL) -d $(SHAREDIR)
- $(INSTALL) -d $(SHAREDIR)/dr_scripts
- $(INSTALL) -d $(SHAREDIR)/setup_scripts
- $(INSTALL) -d $(SHAREDIR)/postgresql
- $(INSTALL) -d $(VARCONFDIR)/postgresql
ifeq ($(OSNAME), Linux)
- $(INSTALL) -d $(SYSCTLDIR)
- $(INSTALL) -d $(BACKUPDIR)
endif
ifndef DMS_DEB_BUILD
chown root:bind $(CONFBINDDIR)
chmod 2755 $(CONFBINDDIR)
chown $(DAEMONUSER):bind $(NAMEDCONFDIR)
chmod 2755 $(NAMEDCONFDIR)
chown bind:bind $(NAMEDSERVERCONFDIR)
chmod 755 $(NAMEDSERVERCONFDIR)
chown bind:$(DAEMONGROUP) $(NAMEDDYNAMICDIR)
chmod 2775 $(NAMEDDYNAMICDIR)
chown bind:$(DAEMONGROUP) $(NAMEDKEYDIR)
chmod 2775 $(NAMEDKEYDIR)
chown $(DAEMONUSER):$(DAEMONGROUP) $(VARCONFDIR)/dms-sg
chown $(DAEMONUSER):$(DAEMONGROUP) $(LOGDIR)
chown $(DAEMONUSER):$(DAEMONGROUP) $(RUNDIR)
endif
ifeq ($(OSNAME), Linux)
- $(INSTALL) -d $(NAMEDMASTERDIR)
- $(INSTALL) -d $(NAMEDSLAVEDIR)
ifndef DMS_DEB_BUILD
chown root:bind $(NAMEDSLAVEDIR)
chmod 775 $(NAMEDSLAVEDIR)
endif
- ln -snf $(NAMEDSLAVELNDATA) $(NAMEDSLAVELN)
- ln -snf $(NAMEDMASTERLNDATA) $(NAMEDMASTERLN)
endif
install-conf: install-dir
for f in $(CONFFILES); do \
if [ ! -f $(CONFDIR)/$${f}.sample ]; then \
$(INSTALL) -m 644 \
etc/$${f}.sample $(CONFDIR)/$${f}.sample; \
fi; \
if [ ! -f $(CONFDIR)/$$f ]; then \
$(INSTALL) -m 644 \
etc/$${f}.sample $(CONFDIR)/$$f; \
fi; \
done
ifndef DMS_DEB_BUILD
for f in $(CONFFILES); do \
chmod 640 $(CONFDIR)/$$f; \
done
chown root:$(DMSGROUP) $(CONFDIR)/dms.conf
chmod 640 $(CONFDIR)/dms.conf
chown root:$(DAEMONGROUP) $(CONFDIR)/rsync-dnsconf-password
chmod 640 $(CONFDIR)/rsync-dnsconf-password
chown root:$(DAEMONGROUP) $(CONFDIR)/rsync-dnssec-password
chmod 640 $(CONFDIR)/rsync-dnssec-password
chown $(PGUSER):$(PGGROUP) $(CONFDIR)/pgpassfile
chmod 600 $(CONFDIR)/pgpassfile
chmod 644 $(CONFDIR)/dr-settings.sh
endif
for d in $(CONFSUBDIRS); do \
if [ ! -e $(CONFDIR)/$$d ]; then \
cp -R etc/$${d} $(CONFDIR); \
fi; \
done
for f in $(MASTERINCFILES); do \
touch $(NAMEDCONFDIR)/$$f; \
done
for f in $(CONFBINDFILES); do \
$(INSTALL) -m 644 etc/debian/bind/$${f} $(CONFBINDDIR); \
done
ifndef DMS_DEB_BUILD
for f in $(MASTERINCFILES); do \
chown $(DAEMONUSER):bind $(NAMEDCONFDIR)/$$f; \
done
for f in $(CONDBINDFILES); do \
chown root:bind $(CONFBINDDIR)/$$f; \
done
endif
ifeq ($(OSNAME), Linux)
- $(INSTALL) -m 644 etc/debian/sysctl.d/30-dms-core-net.conf \
$(SYSCTLDIR)
endif
install-wsgi: install-dir
$(INSTALL) -d $(CONFDIR)/wsgi-scripts/list_zone; \
$(INSTALL) -d $(CONFDIR)/wsgi-scripts/dms; \
for f in $(WSGISCRIPTS); do \
$(INSTALL) -m 644 wsgi-scripts/dms/$$f \
$(CONFDIR)/wsgi-scripts/dms; \
done; \
for f in $(LISTZONEWSGISCRIPTS); do \
$(INSTALL) -m 644 wsgi-scripts/list_zone/$$f \
$(CONFDIR)/wsgi-scripts/list_zone; \
done;
clean-python:
- rm -rf build
build-python:
@$(PYTHON_INTERPRETER) setup.py build
install-python: build-python install-dir
# Allow python directory to be symlinked for development and debug
if [ ! -e $(SHAREDIR) -o ! -L $(SHAREDIR) ]; then \
$(PYTHON_INTERPRETER) setup.py install --install-pure=$(SHAREDIR) --install-scripts=$(SHAREDIR) $(PYTHON_SETUP_OPTS) ; \
fi
install-bin: install-python
- for P in dyndns_tool dmsdmd zone_tool; do \
$(INSTALL) -m 755 $${P} $(SHAREDIR) \
&& perl -pe 's~^#!/\S+/python3.[0-9]$$~#!$(PYTHON_INTERPRETER)~' -i $(SHAREDIR)/$${P}; \
done;
- $(INSTALL) -m 755 dns-createzonekeys $(SHAREDIR)
- $(INSTALL) -m 755 dns-recreateds $(SHAREDIR)
- for S in dms_start_as_replica dms_promote_replica dms_master_down; do \
$(INSTALL) -m 755 dr_scripts/$${S} $(SHAREDIR)/dr_scripts; \
done;
- $(INSTALL) -m 755 dr_scripts/etckeeper_git_shell $(SHAREDIR)/dr_scripts \
&& perl -pe 's~^#!/\S+/python3.[0-9]\s+.*$$~#!$(PYTHON_INTERPRETER)~' -i $(SHAREDIR)/dr_scripts/etckeeper_git_shell
- $(INSTALL) -m 644 postgresql/dms-schema-pg93.sql $(SHAREDIR)/postgresql
- $(INSTALL) -m 644 postgresql/dms-init-pg93.sql $(SHAREDIR)/postgresql
ifeq ($(OSNAME), Linux)
- $(INSTALL) -m 755 postgresql/dms_createdb $(SHAREDIR)/postgresql \
&& perl -pe 's~^DBLIBDIR=.*$$~DBLIBDIR=$(PREFIX)/share/dms/postgresql~' -i $(SHAREDIR)/postgresql/dms_createdb
- $(INSTALL) -m 755 postgresql/pg_dumpallgz $(SHAREDIR)/postgresql \
&& perl -pe 's~^#!/\S+/python3.[0-9]\s+.*$$~#!$(PYTHON_INTERPRETER)~' -i $(SHAREDIR)/postgresql/pg_dumpallgz
- $(INSTALL) -m 644 postgresql/pg_hba.conf $(SHAREDIR)/postgresql
- $(INSTALL) -m 644 postgresql/pg_ident.conf $(SHAREDIR)/postgresql
- $(INSTALL) -m 644 postgresql/postgresql.conf $(SHAREDIR)/postgresql
- $(INSTALL) -m 644 postgresql/30-dms-core-shm.conf $(SYSCTLDIR)
endif
ln -snf $(SHAREDIR)/dmsdmd $(SBINDIR)
ln -snf $(SHAREDIR)/dyndns_tool $(SBINDIR)
ln -snf $(SHAREDIR)/dns-createzonekeys $(SBINDIR)
ln -snf $(SHAREDIR)/dns-recreateds $(SBINDIR)
ln -snf $(SHAREDIR)/zone_tool $(BINDIR)
ln -snf $(SHAREDIR)/zone_tool~rnano $(BINDIR)
ln -snf $(SHAREDIR)/zone_tool~rvim $(BINDIR)
ln -snf $(SHAREDIR)/dr_scripts/etckeeper_git_shell $(SBINDIR)
ln -snf $(SHAREDIR)/dr_scripts/dms_start_as_replica $(SBINDIR)
ln -snf $(SHAREDIR)/dr_scripts/dms_start_as_replica $(SBINDIR)/dms_basebackup
ln -snf $(SHAREDIR)/dr_scripts/dms_start_as_replica $(SBINDIR)/dms_promote_replica
ln -snf $(SHAREDIR)/dr_scripts/dms_start_as_replica $(SBINDIR)/dms_prepare_binddata
ln -snf $(SHAREDIR)/dr_scripts/dms_start_as_replica $(SBINDIR)/dms_master_down
ln -snf $(SHAREDIR)/dr_scripts/dms_start_as_replica $(SBINDIR)/dms_master_up
ln -snf $(SHAREDIR)/dr_scripts/dms_start_as_replica $(SBINDIR)/dms_update_wsgi_dns
ifeq ($(OSNAME), Linux)
ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_createdb
ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_admindb
ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_dropdb
ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_dumpdb
ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_sqldb
ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_pg_basebackup
ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_write_recovery_conf
ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_replicadb
ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_promotedb
ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_move_xlog
ln -snf $(SHAREDIR)/postgresql/pg_dumpallgz $(SBINDIR)/pg_dumpallgz
endif
clean: clean-python