Browse code

initscripts: add patch to handle services using systemctl

This was mishap that happened in:
https://github.com/vmware/photon/commit/201dfd351b89989418b3c7cad1fe347a2f09b092

Change-Id: Ie80db2aefa9c9a8436badd53dca4ef27a4d383df
Signed-off-by: Shreenidhi Shedi <sshedi@vmware.com>
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/c/photon/+/22458
Tested-by: gerrit-photon <photon-checkins@vmware.com>

Shreenidhi Shedi authored on 2023/11/24 04:07:55
Showing 3 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,28 @@
0
+From 27a924c0c0e5bea7cc72d338fb93de428c2c5033 Mon Sep 17 00:00:00 2001
1
+From: Shreenidhi Shedi <sshedi@vmware.com>
2
+Date: Thu, 23 Nov 2023 23:05:49 +0530
3
+Subject: [PATCH] use systemctl to manage services
4
+
5
+Signed-off-by: Shreenidhi Shedi <sshedi@vmware.com>
6
+---
7
+ usr/sbin/service | 4 +++-
8
+ 1 file changed, 3 insertions(+), 1 deletion(-)
9
+
10
+diff --git a/usr/sbin/service b/usr/sbin/service
11
+index 5909934..58bde1a 100755
12
+--- a/usr/sbin/service
13
+@@ -83,7 +83,9 @@ while [ $# -gt 0 ]; do
14
+     esac
15
+ done
16
+ 
17
+-if [ -f "${SERVICEDIR}/${SERVICE}" ]; then
18
++if [[ $ACTION =~ ^(start|stop|restart|try-restart|reload|force-reload|status|condrestart)$ ]]; then
19
++   exec /bin/systemctl "${ACTION}" ${OPTIONS} "${SERVICE}".service
20
++elif [ -f "${SERVICEDIR}/${SERVICE}" ]; then
21
+     # LSB daemons that dies abnormally in systemd looks alive in systemd's eyes due to RemainAfterExit=yes
22
+     # lets reap them before next start
23
+     if [ "${ACTION}" = 'start' ] && \
24
+-- 
25
+2.42.0
26
+
... ...
@@ -1,9 +1,9 @@
1 1
 Summary:        Scripts to bring up network interfaces and legacy utilities
2 2
 Name:           initscripts
3 3
 Version:        10.17
4
+Release:        3%{?dist}
4 5
 License:        GPLv2
5 6
 Group:          System Environment/Base
6
-Release:        2%{?dist}
7 7
 URL:            https://github.com/fedora-sysv/initscripts
8 8
 Vendor:         VMware, Inc.
9 9
 Distribution:   Photon
... ...
@@ -11,21 +11,24 @@ Distribution:   Photon
11 11
 Source0: https://github.com/fedora-sysv/initscripts/archive/%{name}-%{version}.tar.gz
12 12
 %define sha512 %{name}=6c99a7b52b5bc0ced1877a7b2a280b885778bb12e89dc0d606a5b5eda1aa87feecdea6c19803afab01953c9d352c409e59665914832f7107b6b3816d4740594c
13 13
 
14
-Source1:        adjtime
14
+Source1: adjtime
15
+Source2: networks
15 16
 
16
-Requires:       systemd
17
-Requires:       iproute2
18
-Requires:       util-linux
19
-Requires:       findutils
17
+Patch0: 0001-use-systemctl-to-manage-services.patch
20 18
 
21
-BuildRequires:  glib-devel
22
-BuildRequires:  python3-devel
23
-BuildRequires:  popt-devel
24
-BuildRequires:  gettext-devel
25
-BuildRequires:  pkg-config
26
-BuildRequires:  systemd
19
+Requires: systemd
20
+Requires: iproute2
21
+Requires: util-linux
22
+Requires: findutils
27 23
 
28
-Provides:       /sbin/service
24
+BuildRequires: glib-devel
25
+BuildRequires: python3-devel
26
+BuildRequires: popt-devel
27
+BuildRequires: gettext
28
+BuildRequires: pkg-config
29
+BuildRequires: systemd-devel
30
+
31
+Provides: /sbin/service
29 32
 
30 33
 %description
31 34
 This package contains the script that activates and deactivates most
... ...
@@ -34,11 +37,12 @@ network interfaces, some utilities, and other legacy files.
34 34
 %package -n     netconsole-service
35 35
 Summary:        Service for initializing of network console logging
36 36
 Requires:       %{name} = %{version}-%{release}
37
-BuildArch:      noarch
38 37
 Requires:       iputils
39 38
 Requires:       kmod
40 39
 Requires:       sed
41 40
 
41
+BuildArch:      noarch
42
+
42 43
 %description -n netconsole-service
43 44
 This packages provides a 'netconsole' service for loading of netconsole kernel
44 45
 module with the configured parameters. The netconsole kernel module itself then
... ...
@@ -47,15 +51,16 @@ allows logging of kernel messages over the network.
47 47
 %package -n     readonly-root
48 48
 Summary:        Service for configuring read-only root support
49 49
 Requires:       %{name} = %{version}-%{release}
50
-BuildArch:      noarch
51 50
 Requires:       cpio
52 51
 
52
+BuildArch:      noarch
53
+
53 54
 %description -n readonly-root
54 55
 This package provides script & configuration file for setting up read-only root
55 56
 support. Additional configuration is required after installation.
56 57
 
57 58
 %prep
58
-%autosetup
59
+%autosetup -p1
59 60
 
60 61
 %build
61 62
 %make_build PYTHON=%{python3}
... ...
@@ -70,36 +75,16 @@ rm -f %{buildroot}%{_sysconfdir}/sysconfig/network-scripts/ifup-ctc
70 70
 # Additional ways to access documentation:
71 71
 install -m 0755 -d %{buildroot}%{_docdir}/network-scripts
72 72
 
73
-ln -s %{_docdir}/%{name}/sysconfig.txt %{buildroot}%{_docdir}/network-scripts/
74
-ln -sr %{_mandir}/man8/ifup.8 %{buildroot}%{_mandir}/man8/ifdown.8
73
+ln -srv %{buildroot}%{_docdir}/%{name}-%{version}/sysconfig.txt \
74
+       %{buildroot}%{_docdir}/network-scripts/
75 75
 
76
-cp -r %{SOURCE1} %{buildroot}%{_sysconfdir}/
76
+ln -srv %{buildroot}%{_mandir}/man8/ifup.8 \
77
+       %{buildroot}%{_mandir}/man8/ifdown.8
77 78
 
78
-mkdir -p %{buildroot}%{_sysconfdir}/rwtab.d \
79
-         %{buildroot}%{_sysconfdir}/statetab.d \
80
-         %{buildroot}%{_sysconfdir}/NetworkManager/dispatcher.d
81
-
82
-cat >> %{buildroot}%{_sysconfdir}/sysconfig/network <<- "EOF"
83
-###
84
-# This file is used to specify information about the desired network configuration.
85
-# By default, it contains the following options:
86
-#
87
-
88
-# A boolean yes or no to Configure networking or not to configure networking.
89
-# NETWORKING=boolean
79
+cp %{SOURCE1} %{SOURCE2} %{buildroot}%{_sysconfdir}/
90 80
 
91
-# Hostname of your machine
92
-# HOSTNAME=value
93
-
94
-# where gwip is the IP address of the remote network gateway -if available.
95
-# GATEWAY=gwip
96
-EOF
97
-
98
-cat >> %{buildroot}%{_sysconfdir}/networks <<- "EOF"
99
-default 0.0.0.0
100
-loopback 127.0.0.0
101
-link-local 169.254.0.0
102
-EOF
81
+mkdir -p %{buildroot}%{_sysconfdir}/{rwtab.d,statetab.d} \
82
+         %{buildroot}%{_sysconfdir}/NetworkManager/dispatcher.d
103 83
 
104 84
 %post
105 85
 %systemd_post import-state.service loadmodules.service
... ...
@@ -129,6 +114,7 @@ EOF
129 129
 %systemd_postun readonly-root.service
130 130
 
131 131
 %files -f %{name}.lang
132
+%defattr(-,root,root)
132 133
 %license COPYING
133 134
 %doc doc/sysconfig.txt
134 135
 
... ...
@@ -164,11 +150,7 @@ EOF
164 164
 %dir %{_sysconfdir}/sysconfig/network-scripts
165 165
 %{_sysconfdir}/rc.d/init.d/network
166 166
 %{_sysconfdir}/sysconfig/network-scripts/*
167
-%config(noreplace)    %{_sysconfdir}/sysconfig/network-scripts/ifcfg-lo
168
-%ifarch s390 s390x
169
-%{_sysconfdir}/sysconfig/network-scripts/ifup-ctc
170
-%endif
171
-%config(noreplace) %{_sysconfdir}/sysconfig/network
167
+%config(noreplace) %{_sysconfdir}/sysconfig/network-scripts/ifcfg-lo
172 168
 %config(noreplace) %{_sysconfdir}/networks
173 169
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/adjtime
174 170
 
... ...
@@ -182,11 +164,13 @@ EOF
182 182
 %dir %{_sysconfdir}/NetworkManager/dispatcher.d
183 183
 
184 184
 %files -n netconsole-service
185
+%defattr(-,root,root)
185 186
 %config(noreplace) %{_sysconfdir}/sysconfig/netconsole
186 187
 %{_libexecdir}/netconsole
187 188
 %{_unitdir}/netconsole.service
188 189
 
189 190
 %files -n readonly-root
191
+%defattr(-,root,root)
190 192
 %dir %{_sharedstatedir}/stateless
191 193
 %dir %{_sharedstatedir}/stateless/state
192 194
 %dir %{_sharedstatedir}/stateless/writable
... ...
@@ -199,6 +183,9 @@ EOF
199 199
 %{_unitdir}/readonly-root.service
200 200
 
201 201
 %changelog
202
+* Thu Nov 23 2023 Shreenidhi Shedi <sshedi@vmware.com> 10.17-3
203
+- Spec clanups
204
+- Add patch to manage services using systemctl.
202 205
 * Sat Jan 14 2023 Ashwin Dayanand Kamat <kashwindayan@vmware.com> 10.17-2
203 206
 - Bump version as a part of gettext upgrade
204 207
 * Fri Oct 28 2022 Gerrit Photon <photon-checkins@vmware.com> 10.17-1
205 208
new file mode 100644
... ...
@@ -0,0 +1,3 @@
0
+default 0.0.0.0
1
+loopback 127.0.0.0
2
+link-local 169.254.0.0