-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhouseinstall.mak
110 lines (84 loc) · 3.88 KB
/
houseinstall.mak
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
# houseportal - A simple web portal environment for home servers
#
# Copyright 2023, Pascal Martin
#
# This program 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 2
# of the License, or (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# This file is meant to be included from the main make file of dependent
# applications. The main make file must have defined the following:
#
# - Variable HAPP: the name of the specific house dependent application.
#
# - Target install-app: install the application-specific run-time files,
# with the exception of any file specific to the init system.
#
# - Target uninstall-app: remove the files installed by target install-app.
#
# - Target purge-app: remove development files shared with dependent
# applications, if any.
#
# - Target purge-config: delete the local application configuration.
#
# In addition, the unit file for Systemd must be locally named systemd.service
# and the local service script for runit must be named runit.run.
# Distribution agnostic install for systemd -------------------------
install-systemd:
grep -q '^house:' /etc/passwd || useradd -r house -s /usr/sbin/nologin -d /var/lib/house
cp systemd.service /lib/systemd/system/$(HAPP).service
chown root:root /lib/systemd/system/$(HAPP).service
systemctl daemon-reload
systemctl enable $(HAPP)
systemctl start $(HAPP)
uninstall-systemd:
if [ -e /etc/init.d/$(HAPP) ] ; then systemctl stop $(HAPP) ; systemctl disable $(HAPP) ; rm -f /etc/init.d/$(HAPP) ; fi
if [ -e /lib/systemd/system/$(HAPP).service ] ; then systemctl stop $(HAPP) ; systemctl disable $(HAPP) ; rm -f /lib/systemd/system/$(HAPP).service ; systemctl daemon-reload ; fi
stop-systemd: uninstall-systemd
# This is a do-nothing target, defined so that make files that don't need it
# do not have to define one. Those make files that need that target may
# define their own: the "::" syntax allows multiple (cumulative) definitions.
#
clean-systemd::
sleep 0
# Distribution agnostic install for runit ---------------------------
install-runit:
mkdir -p /etc/sv/$(HAPP)
cp runit.run /etc/sv/$(HAPP)/run
chown root:root /etc/sv/$(HAPP) /etc/sv/$(HAPP)/run
chmod 755 /etc/sv/$(HAPP)/run
rm -f /etc/runit/runsvdir/default/$(HAPP)
ln -s /etc/sv/$(HAPP) /etc/runit/runsvdir/default/$(HAPP)
/bin/sleep 5
/usr/bin/sv up $(HAPP)
uninstall-runit:
if [ -e /etc/sv/$(HAPP) ] ; then /usr/bin/sv stop $(HAPP) ; rm -rf /etc/sv/$(HAPP) ; rm -f /etc/runit/runsvdir/default/$(HAPP) ; /bin/sleep 5 ; fi
stop-runit:
if [ -e /etc/sv/$(HAPP) ] ; then /usr/bin/sv stop $(HAPP) ; fi
# Debian GNU/Linux install --------------------------------------
install-debian: stop-systemd clean-systemd install-app install-systemd
uninstall-debian: uninstall-systemd uninstall-app
purge-debian: uninstall-debian purge-app purge-config
# Devuan GNU/Linux install (using runit) ------------------------
install-devuan: stop-runit install-app install-runit
uninstall-devuan: uninstall-runit uninstall-app
purge-devuan: uninstall-devuan purge-app purge-config
# Void Linux install --------------------------------------------
install-void: stop-runit install-app install-runit
uninstall-void: uninstall-runit uninstall-app
purge-void: uninstall-void purge-app purge-config
# Default install (Debian GNU/Linux) ----------------------------
install: install-debian
uninstall: uninstall-debian
purge: purge-debian