-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
109 lines (73 loc) · 2.71 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
export SERVICE = docker-service
export CONTAINER = $(SERVICE)
export DESCRIPTION = A service to provide interface to the docker container <CONTAINER>
export TEMPLATE = docker-service-init
export OUTPUTDIR = build/
export OUTPUT = $(OUTPUTDIR)$(SERVICE)
INSTALLDIR = /etc/init.d/
INSTALL = $(INSTALLDIR)$(SERVICE)
SCRIPT_DIR =
export PRE_START_SCRIPT = $(SCRIPT_DIR)PRE_START
export POST_START_SCRIPT = $(SCRIPT_DIR)POST_START
export PRE_STOP_SCRIPT = $(SCRIPT_DIR)PRE_STOP
export POST_STOP_SCRIPT = $(SCRIPT_DIR)POST_STOP
export PRE_RESTART_SCRIPT = $(SCRIPT_DIR)PRE_RESTART
export POST_RESTART_SCRIPT = $(SCRIPT_DIR)POST_RESTART
export PRE_PAUSE_SCRIPT = $(SCRIPT_DIR)PRE_PAUSE
export POST_PAUSE_SCRIPT = $(SCRIPT_DIR)POST_PAUSE
export PRE_UNPAUSE_SCRIPT = $(SCRIPT_DIR)PRE_UNPAUSE
export POST_UNPAUSE_SCRIPT = $(SCRIPT_DIR)POST_UNPAUSE
SCRIPTS = $(PRE_START_SCRIPT) $(POST_START_SCRIPT) $(PRE_STOP_SCRIPT) $(POST_STOP_SCRIPT) $(PRE_RESTART_SCRIPT) $(POST_RESTART_SCRIPT) $(PRE_PAUSE_SCRIPT) $(POST_PAUSE_SCRIPT) $(PRE_UNPAUSE_SCRIPT) $(POST_UNPAUSE_SCRIPT)
$(OUTPUT) : $(OUTPUTDIR) $(TEMPLATE) subs.sh
cp $(TEMPLATE) $@
bash subs.sh
$(OUTPUTDIR) :
mkdir -p $@
$(INSTALLDIR) :
mkdir -p $@
$(INSTALL) : $(OUTPUT) $(INSTALLDIR)
cp $(OUTPUT) $@
ifneq ($(SCRIPT_DIR),)
$(SCRIPT_DIR) :
mkdir -p $(SCRIPT_DIR)
endif
$(PRE_START_SCRIPT) : $(SCRIPT_DIR)
echo "# $@ CONTENT" > $@
$(POST_START_SCRIPT) : $(SCRIPT_DIR)
echo "# $@ CONTENT" > $@
$(PRE_STOP_SCRIPT) : $(SCRIPT_DIR)
echo "# $@ CONTENT" > $@
$(POST_STOP_SCRIPT) : $(SCRIPT_DIR)
echo "# $@ CONTENT" > $@
$(PRE_RESTART_SCRIPT) : $(SCRIPT_DIR)
echo "# $@ CONTENT" > $@
$(POST_RESTART_SCRIPT) : $(SCRIPT_DIR)
echo "# $@ CONTENT" > $@
$(PRE_PAUSE_SCRIPT) : $(SCRIPT_DIR)
echo "# $@ CONTENT" > $@
$(POST_PAUSE_SCRIPT) : $(SCRIPT_DIR)
echo "# $@ CONTENT" > $@
$(PRE_UNPAUSE_SCRIPT) : $(SCRIPT_DIR)
echo "# $@ CONTENT" > $@
$(POST_UNPAUSE_SCRIPT) : $(SCRIPT_DIR)
echo "# $@ CONTENT" > $@
.PHONY : START_SCRIPTS STOP_SCRIPTS RESTART_SCRIPTS PAUSE_SCRIPTS UNPAUSE_SCRIPTS
START_SCRIPTS : $(PRE_START_SCRIPT) $(POST_START_SCRIPT)
STOP_SCRIPTS : $(PRE_STOP_SCRIPT) $(POST_STOP_SCRIPT)
RESTART_SCRIPTS : $(PRE_RESTART_SCRIPT) $(POST_RESTART_SCRIPT)
PAUSE_SCRIPTS : $(PRE_PAUSE_SCRIPT) $(POST_PAUSE_SCRIPT)
UNPAUSE_SCRIPTS : $(PRE_UNPAUSE_SCRIPT) $(POST_UNPAUSE_SCRIPT)
.PHONY : scripts clean_scripts generate install enable disable uninstall clean
scripts : START_SCRIPTS STOP_SCRIPTS RESTART_SCRIPTS PAUSE_SCRIPTS UNPAUSE_SCRIPTS
clean_scripts :
rm -f $(SCRIPTS)
generate : $(OUTPUT)
install : $(INSTALL)
enable : install
update-rc.d $(SERVICE) defaults
disable : $(INSTALL)
update-rc.d -f $(SERVICE) remove
uninstall : disable
rm $(INSTALL)
clean :
rm -r $(OUTPUTDIR)