On 4/3/20 1:44 PM, Thomas Trepl wrote:
Am Freitag, den 03.04.2020, 12:38 -0400 schrieb Scott Andrews:
On 4/3/20 12:21 PM, Thomas Trepl wrote:
Am Freitag, den 03.04.2020, 10:42 -0400 schrieb Scott Andrews via
blfs-support:
Any interest in adding chkconfig to the system V book?
I have successfully added it to my systems.
I also have a script that starts and stop daemon and will tell you all
the daemons present on the system and the status running or stopped.
Any interest in that?
I think for the SysV guys it might be of interest.
Is there a link to the package/script?
--
Thomas
https://github.com/fedora-sysv/chkconfig
I use this package chkconfig-1.11.tar.gz.
I use rpm and I can attach the spec file for this
This is the service script
cat > /usr/sbin/service << EOF
#! /bin/sh
VERSION="$(basename $0) ver. 0.92"
USAGE="Usage: $(basename $0) < option > | --status-all | [ service_name
[ command | --full-restart ] ]"
SERVICE=
SERVICEDIR="/etc/rc.d/init.d"
OPTIONS=
if [ $# -eq 0 ]; then
echo "${USAGE}" >&2
exit 1
fi
cd /
while [ $# -gt 0 ]; do
case "${1}" in
--help | -h | --h* )
echo "${USAGE}" >&2
exit 0
;;
--version | -V )
echo "${VERSION}" >&2
exit 0
;;
*)
if [ -z "${SERVICE}" -a $# -eq 1 -a "${1}" = "--status-all"
]; then
cd ${SERVICEDIR}
for SERVICE in * ; do
case "${SERVICE}" in
checkfs ) ;;
localnet) ;;
mountvirtfs) ;;
rc) ;;
sendsignals) ;;
swap) ;;
udev_retry) ;;
cleanfs) ;;
modules) ;;
network) ;;
reboot) ;;
setclock) ;;
template) ;;
console) ;;
halt) ;;
mountfs) ;;
sysctl) ;;
udev) ;;
*)
if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
env -i PATH="$PATH" TERM="$TERM"
"${SERVICEDIR}/${SERVICE}" status
fi
;;
esac
done
exit 0
elif [ $# -eq 2 -a "${2}" = "--full-restart" ]; then
SERVICE="${1}"
if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
env -i PATH="$PATH" TERM="$TERM"
"${SERVICEDIR}/${SERVICE}" stop
env -i PATH="$PATH" TERM="$TERM"
"${SERVICEDIR}/${SERVICE}" start
exit $?
fi
elif [ -z "${SERVICE}" ]; then
SERVICE="${1}"
else
OPTIONS="${OPTIONS} ${1}"
fi
shift
;;
esac
done
if [ -f "${SERVICEDIR}/${SERVICE}" ]; then
env -i PATH="$PATH" TERM="$TERM" "${SERVICEDIR}/${SERVICE}" ${OPTIONS}
else
echo $"${SERVICE}: unrecognized service" >&2
exit 1
fi
EOF
chmod +x /usr/sbin/service
Thanks!
Well, strange version numbering ... but more difficult is that they refer to
SElinux stuff which is AFAIK not available on a LFS system. So to use it on a
LFS system, SElinux must be patched out or add a lot more to the book (SElinux)
than just this package.
--
Thomas
This is how I build it, I have it operating on a raspberry pi 3 that I
built from LFS 9.0 and BLFS 9.0.
It really isn't difficult to build LFS on an ARM platform.
I don't know why LFS is so adverse to adding it as a platform, being all
the schools and instuitions that use the Raspberry pi as a learning
platform.
I would have thought it would be a shoe in, but I digress.......
Summary='A system tool for maintaining the /etc/rc*.d hierarchy'
Name='chkconfig'
Version='1.11'
Release='1'
License='LGPLv2+'
Url='https://github.com/fedora-sysv/chkconfig'
Group='LFS/Base'
Source='chkconfig-1.11.tar.gz'
Patch='chkconfig-1.11-no_selinux-1.patch'
Description='Chkconfig is a basic system utility. It updates and
queries runlevel
information for system services. Chkconfig manipulates the numerous
symbolic links in /etc/rc.d, to relieve system administrators of some
of the drudgery of manually editing the symbolic links.'
Prep="%setup -q -n %{name}-%{version}
%patch0 -p1"
Build='%{make_build}'
Install='%{make_install} DESTDIR=%{buildroot} MANDIR=/usr/share/man
SBINDIR=/usr/sbin
install -vdm 755 %{buildroot}/etc
ln -vsf rc.d/rc0.d %{buildroot}/etc
ln -vsf rc.d/rc1.d %{buildroot}/etc
ln -vsf rc.d/rc2.d %{buildroot}/etc
ln -vsf rc.d/rc3.d %{buildroot}/etc
ln -vsf rc.d/rc4.d %{buildroot}/etc
ln -vsf rc.d/rc5.d %{buildroot}/etc
ln -vsf rc.d/rc6.d %{buildroot}/etc
ln -vsf rc.d/rcS.d %{buildroot}/etc'
Install+='
install -vdm 755 %{buildroot}/usr/sbin
cat > %{buildroot}/usr/sbin/service << EOF
#! /bin/sh
VERSION="\$(basename \$0) ver. 0.92"
USAGE="Usage: \$(basename \$0) < option > | --status-all | [
service_name [ command | --full-restart ] ]"
SERVICE=
SERVICEDIR="/etc/rc.d/init.d"
OPTIONS=
if [ \$# -eq 0 ]; then
echo "\${USAGE}" >&2
exit 1
fi
cd /
while [ \$# -gt 0 ]; do
case "\${1}" in
--help | -h | --h* )
echo "\${USAGE}" >&2
exit 0
;;
--version | -V )
echo "\${VERSION}" >&2
exit 0
;;
*)
if [ -z "\${SERVICE}" -a \$# -eq 1 -a "\${1}" =
"--status-all" ]; then
cd \${SERVICEDIR}
for SERVICE in * ; do
case "\${SERVICE}" in
checkfs ) ;;
fake-hwclock) ;;
localnet) ;;
mountvirtfs) ;;
rc) ;;
sendsignals) ;;
swap) ;;
udev_retry) ;;
cleanfs) ;;
modules) ;;
network) ;;
reboot) ;;
setclock) ;;
switch_cpu_governor) ;;
template) ;;
console) ;;
halt) ;;
mountfs) ;;
sysctl) ;;
udev) ;;
*)
if [ -x "\${SERVICEDIR}/\${SERVICE}" ]; then
env -i PATH="\$PATH" TERM="\$TERM"
"\${SERVICEDIR}/\${SERVICE}" status
fi
;;
esac
done
exit 0
elif [ \$# -eq 2 -a "\${2}" = "--full-restart" ]; then
SERVICE="\${1}"
if [ -x "\${SERVICEDIR}/\${SERVICE}" ]; then
env -i PATH="\$PATH" TERM="\$TERM"
"\${SERVICEDIR}/\${SERVICE}" stop
env -i PATH="\$PATH" TERM="\$TERM"
"\${SERVICEDIR}/\${SERVICE}" start
exit \$?
fi
elif [ -z "\${SERVICE}" ]; then
SERVICE="\${1}"
else
OPTIONS="\${OPTIONS} \${1}"
fi
shift
;;
esac
done
if [ -f "\${SERVICEDIR}/\${SERVICE}" ]; then
env -i PATH="\$PATH" TERM="\$TERM" "\${SERVICEDIR}/\${SERVICE}"
\${OPTIONS}
else
echo \$"\${SERVICE}: unrecognized service" >&2
exit 1
fi
EOF
chmod +x %{buildroot}/usr/sbin/service'
Files='%defattr(-,root,root)'
Here is the patch:
diff -u -r chkconfig-1.11.orig/leveldb.c chkconfig-1.11.jmp/leveldb.c
--- chkconfig-1.11.orig/leveldb.c 2018-09-10 09:28:29.000000000 -0400
+++ chkconfig-1.11.jmp/leveldb.c 2019-01-08 23:21:49.025831135 -0500
@@ -22,8 +22,6 @@
#include <libgen.h>
#include <libintl.h>
#include <locale.h>
-#include <selinux/label.h>
-#include <selinux/selinux.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -41,47 +39,6 @@
#include "leveldb.h"
-int selinux_restore(const char *name) {
- struct selabel_handle *hnd = NULL;
- struct stat buf;
- security_context_t newcon = NULL;
- int r = -1;
-
- hnd = selabel_open(SELABEL_CTX_FILE, NULL, 0);
- if (hnd == NULL)
- goto out;
-
- r = stat(name, &buf);
- if (r < 0)
- goto out;
-
- r = selabel_lookup_raw(hnd, &newcon, name, buf.st_mode);
- if (r < 0)
- goto out;
-
- r = setfilecon_raw(name, newcon);
- if (r < 0)
- goto out;
-
- r = 0;
-
-out:
- if (hnd)
- selabel_close(hnd);
- if (newcon)
- freecon(newcon);
-
- /* Lets ignore any errors when selinux is disabled.
- * We still want to run the previous code though,
- * since we only need selinux policy.
- * Selinux itself can be turned off.
- */
- if (!is_selinux_enabled())
- return 0;
-
- return r;
-}
-
int parseLevels(char *str, int emptyOk) {
char *chptr = str;
int rc = 0;
@@ -897,9 +854,6 @@
close(newfd);
unlink(oldfname);
r = rename(newfname, oldfname);
- if (selinux_restore(oldfname) != 0)
- fprintf(stderr, _("Unable to set selinux context for %s: %s\n"),
- oldfname, strerror(errno));
return (r);
}
diff -u -r chkconfig-1.11.orig/Makefile chkconfig-1.11.jmp/Makefile
--- chkconfig-1.11.orig/Makefile 2018-09-10 09:28:29.000000000 -0400
+++ chkconfig-1.11.jmp/Makefile 2019-01-08 23:26:38.372102345 -0500
@@ -15,7 +15,7 @@
OBJS=chkconfig.o leveldb.o
NTOBJS=ntsysv.o leveldb.o
-all: subdirs $(PROG) ntsysv alternatives
+all: subdirs $(PROG)
subdirs:
for d in $(SUBDIRS); do \
@@ -24,7 +24,7 @@
done && test -z "$$fail"
chkconfig: $(OBJS)
- $(CC) $(LDFLAGS) -o chkconfig $(OBJS) -lpopt -lselinux -lsepol
+ $(CC) $(LDFLAGS) -o chkconfig $(OBJS) -lpopt
alternatives: alternatives.o
@@ -56,14 +56,8 @@
[ -d $(DESTDIR)/$(MANDIR)/man5 ] || mkdir -p $(DESTDIR)/$(MANDIR)/man5
[ -d $(DESTDIR)/$(ALTDIR) ] || mkdir -p -m 755 $(DESTDIR)/$(ALTDIR)
[ -d $(DESTDIR)/$(ALTDATADIR) ] || mkdir -p -m 755
$(DESTDIR)/$(ALTDATADIR)
- [ -d $(DESTDIR)/usr/lib/systemd ] || mkdir -p -m 755
$(DESTDIR)/usr/lib/systemd
install -m 755 $(PROG) $(DESTDIR)/$(BINDIR)/$(PROG)
- ln -s ../../../$(BINDIR)/$(PROG)
$(DESTDIR)/usr/lib/systemd/systemd-sysv-install
-
- install -m 755 ntsysv $(DESTDIR)/$(SBINDIR)/ntsysv
- install -m 755 alternatives $(DESTDIR)/$(SBINDIR)/alternatives
- ln -s alternatives $(DESTDIR)/$(SBINDIR)/update-alternatives
for i in $(MAN); do \
install -m 644 $$i $(DESTDIR)/$(MANDIR)/man`echo $$i | sed
"s/.*\.//"`/$$i ; \
--
http://lists.linuxfromscratch.org/listinfo/blfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page