Patch chkconfig to print whether the service is on or off based on the current runlevel
Change-Id: I76cc3253929f2c642bc63897878c798a589e6293
Reviewed-on: http://photon-jenkins.eng.vmware.com/191
Tested-by: jenkins-photon <wangnan2015@hotmail.com>
Reviewed-by: Sharath George
| ... | ... |
@@ -1,12 +1,13 @@ |
| 1 | 1 |
Summary: A system tool for maintaining the /etc/rc*.d hierarchy |
| 2 | 2 |
Name: chkconfig |
| 3 | 3 |
Version: 1.5 |
| 4 |
-Release: 2%{?dist}
|
|
| 4 |
+Release: 3%{?dist}
|
|
| 5 | 5 |
License: GPLv2 |
| 6 | 6 |
Group: System Environment/Base |
| 7 | 7 |
URL: https://git.fedorahosted.org/git/chkconfig.git |
| 8 | 8 |
Source: http://fedorahosted.org/releases/c/h/chkconfig/%{name}-%{version}.tar.bz2
|
| 9 | 9 |
Patch0:chkconfig-shortopt.patch |
| 10 |
+Patch1:print-service-on-off.patch |
|
| 10 | 11 |
%define sha1 chkconfig=19a15a6690788686cc173b0d0626eaae01bec0c1 |
| 11 | 12 |
Requires: libselinux |
| 12 | 13 |
Requires: libsepol |
| ... | ... |
@@ -40,6 +41,7 @@ page), ntsysv configures the current runlevel (5 if you're using X). |
| 40 | 40 |
%prep |
| 41 | 41 |
%setup -q |
| 42 | 42 |
%patch0 -p1 |
| 43 |
+%patch1 -p1 |
|
| 43 | 44 |
%build |
| 44 | 45 |
|
| 45 | 46 |
make RPM_OPT_FLAGS="$RPM_OPT_FLAGS" LDFLAGS="$RPM_LD_FLAGS" %{?_smp_mflags}
|
| ... | ... |
@@ -87,6 +89,9 @@ rm -rf %{buildroot}
|
| 87 | 87 |
%{_mandir}/*/ntsysv.8*
|
| 88 | 88 |
|
| 89 | 89 |
%changelog |
| 90 |
+* Tue Dec 01 2015 Mahmoud Bassiouny <mbassiouny@vmware.com> |
|
| 91 |
+- Allowing chkconfing to print service on/off status on the current runlevel. |
|
| 92 |
+ |
|
| 90 | 93 |
* Fri Nov 20 2015 Sharath George <sharathg@vmware.com> |
| 91 | 94 |
- Adding shortopt for add and delete. |
| 92 | 95 |
|
| 93 | 96 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,35 @@ |
| 0 |
+--- a/chkconfig.c 2015-12-01 18:23:52.047031136 +0000 |
|
| 1 |
+@@ -837,17 +837,29 @@ |
|
| 2 |
+ } |
|
| 3 |
+ } |
|
| 4 |
+ rc = readServiceInfo(name, type, &s, 0); |
|
| 5 |
+- if (rc) |
|
| 6 |
++ if (rc) {
|
|
| 7 |
++ fprintf(stderr, "%s: unknown service\n", name); |
|
| 8 |
+ return 1; |
|
| 9 |
++ } |
|
| 10 |
+ if (s.type == TYPE_XINETD) {
|
|
| 11 |
+ if (isOn("xinetd",level))
|
|
| 12 |
+ return !s.levels; |
|
| 13 |
+ else |
|
| 14 |
+ return 1; |
|
| 15 |
+ } else {
|
|
| 16 |
+- if (level == -1) |
|
| 17 |
++ if (level == -1) {
|
|
| 18 |
+ level = currentRunlevel(); |
|
| 19 |
+- return s.currentLevels & (1 << level) ? 0 : 1; |
|
| 20 |
++ if (level == -1) {
|
|
| 21 |
++ fprintf(stderr, "can not detect the current runlevel\n"); |
|
| 22 |
++ return 1; |
|
| 23 |
++ } |
|
| 24 |
++ } |
|
| 25 |
++ if (s.currentLevels & (1 << level)) {
|
|
| 26 |
++ printf("%s on\n", name);
|
|
| 27 |
++ } else {
|
|
| 28 |
++ printf("%s off\n", name);
|
|
| 29 |
++ } |
|
| 30 |
++ return 0; |
|
| 31 |
+ } |
|
| 32 |
+ } else if (!strcmp(state, "on")) {
|
|
| 33 |
+ if (!noRedirectItem) {
|