Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60f42c415d | ||
|
|
93c8cbe684 | ||
|
|
386bdf66f9 | ||
|
|
81ab30c51d | ||
|
|
d05c8c2159 | ||
|
|
7850e12071 | ||
|
|
11d3a8bead | ||
|
|
e36e9a30eb | ||
|
|
7da99d77b5 |
314
ChangeLog
314
ChangeLog
@@ -1,112 +1,4 @@
|
|||||||
commit d725410277c04a812bb9df6113c3f58176205f48
|
commit 93c8cbe68428dcf7823a6483d30698ba001f4271
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
supervise-daemon: reap zombies
|
|
||||||
|
|
||||||
We need to make sure to reap zombies so that we can shut down
|
|
||||||
successfully.
|
|
||||||
|
|
||||||
Fixes #252.
|
|
||||||
Possibly related to #250.
|
|
||||||
|
|
||||||
commit d78cd5ce928e30806d0566cdb905a34ebbc01450
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
rc-service: fix help output
|
|
||||||
|
|
||||||
commit 2a9c1a220d73359e69af08193d6d788125b136c4
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
version 0.39.2
|
|
||||||
|
|
||||||
commit 81ce908e420429b18cf31424ec4e4cf6549985e5
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
Update ChangeLog
|
|
||||||
|
|
||||||
commit aa867fd7e3d250aba6132b490350b1a6cb38bc34
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
openrc-shutdown: do not require a time for -w switch
|
|
||||||
|
|
||||||
X-Gentoo-Bug: 669500
|
|
||||||
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=669500
|
|
||||||
|
|
||||||
commit c921a8647bd724934d9a1590d2d14f9fb4a3e084
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
version 0.39.1
|
|
||||||
|
|
||||||
commit 53f7afd3b3daf659d58d6545dc79cd45c4c54277
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
Update ChangeLog
|
|
||||||
|
|
||||||
commit 75e9b66f6ff36d06bf1f8bd4824000f9f26106e0
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
news.md: add information about the modules service changes
|
|
||||||
|
|
||||||
commit d70b1c55b67b44b98c23ceed25bc428481f7e00a
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
modules: Add --first-time switch to modprobe commands
|
|
||||||
|
|
||||||
On Linux, kernel modules should be loaded once during boot, either in an
|
|
||||||
initramfs or by this service.
|
|
||||||
|
|
||||||
This does not change anything other than printing out messages if a
|
|
||||||
module is loaded more than once.
|
|
||||||
|
|
||||||
X-Gentoo-Bug: 659530
|
|
||||||
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=659530
|
|
||||||
|
|
||||||
commit c1e582586d398b4452f568240985247294f645ef
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
supervise-daemon: add health checks
|
|
||||||
|
|
||||||
Health checks are a way to monitor a service and make sure it stays
|
|
||||||
healthy.
|
|
||||||
|
|
||||||
If a service is not healthy, it will be automatically restarted after
|
|
||||||
running the unhealthy() function to clean up.
|
|
||||||
|
|
||||||
commit 7a75bfb00c52687a236c92bec78b5e7ab4844701
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
news.md: add note about scheduled shutdown
|
|
||||||
|
|
||||||
commit aacf841de4983ab33755081a6f69cdf5e3a47007
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
supervise-daemon-guide.md: re-format and add more variables
|
|
||||||
|
|
||||||
commit 3f918161aafa61c1c2005709fda0b9bec4c412d8
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
openrc-shutdown: Add scheduled shutdown and the ability to cancel a shutdown
|
|
||||||
|
|
||||||
You can now schedule a shutdown for a certain time or a cpecific number
|
|
||||||
of minutes into the future.
|
|
||||||
|
|
||||||
When a shutdown is running, you can now cancel it with ^c from the
|
|
||||||
keyboard or by running "openrc-shutdown -c" from another shell.
|
|
||||||
|
|
||||||
commit 710c874e6e3bc57b1561eb8f2108244bf24ed32e
|
|
||||||
Author: Zac Medico <zmedico@gmail.com>
|
Author: Zac Medico <zmedico@gmail.com>
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
@@ -121,55 +13,19 @@ Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|||||||
Fixes: https://github.com/OpenRC/openrc/issues/247
|
Fixes: https://github.com/OpenRC/openrc/issues/247
|
||||||
Fixes: https://github.com/OpenRC/openrc/issues/248
|
Fixes: https://github.com/OpenRC/openrc/issues/248
|
||||||
|
|
||||||
commit 07908be0903229a69b9e0f733ed13eeff0b55a44
|
commit 386bdf66f9622b6a86847ff678077c5c6456d74e
|
||||||
Author: Austin English <austinenglish@gmail.com>
|
|
||||||
Commit: Mike Frysinger <vapier@gmail.com>
|
|
||||||
|
|
||||||
misc: style fixups
|
|
||||||
|
|
||||||
commit 02af093043a7444381b0d8a0a3e8e97247505f95
|
|
||||||
Author: Austin English <austinenglish@gmail.com>
|
|
||||||
Commit: Mike Frysinger <vapier@gmail.com>
|
|
||||||
|
|
||||||
misc: whitespace fixes
|
|
||||||
|
|
||||||
commit 67e2d6033dd7ac6db0269ee060ed20484825ff9f
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
Complete implementation of forever timeout value in stop schedules
|
version 0.38.3
|
||||||
|
|
||||||
commit eca4357892315ca7340bbfc2b373d7660a34142f
|
commit 81ab30c51dba9bfac71dd36c65e96bc1e3e5f2ae
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
supervise-daemon: use nanosleep() instead of sleep()
|
Update ChangeLog
|
||||||
|
|
||||||
We will be using sigalrm in this process for health checking, and
|
commit d05c8c2159a9cbcf9286adbd6cbc3b0d5d2a3b43
|
||||||
sigalrm cannot be used with sleep() safely.
|
|
||||||
|
|
||||||
commit 7ee3e5b2d6dbb9c279011b59ec132d27d04f843e
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
openrc-init: convert sleep() call to nanosleep()
|
|
||||||
|
|
||||||
Nanosleep is the safer call to use in case we need to use alarms
|
|
||||||
eventually.
|
|
||||||
|
|
||||||
commit 7cb8d943236fe651ac54c64f8167f7c4369f649c
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
Stop mounting efivarfs read-only
|
|
||||||
|
|
||||||
We do not need to do this any longer since all supported linux kernels
|
|
||||||
make efivarfs immutable and the tools that manipulate it are aware of
|
|
||||||
this feature.
|
|
||||||
|
|
||||||
This fixes https://github.com/openrc/openrc/issues/238.
|
|
||||||
|
|
||||||
commit 84ed570eaefcbb55b99ba425030bf7d1d1d46137
|
|
||||||
Author: Zac Medico <zmedico@gmail.com>
|
Author: Zac Medico <zmedico@gmail.com>
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
@@ -181,25 +37,19 @@ Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|||||||
Fixes: 37e29442721a ("librc: Add check for crashed state")
|
Fixes: 37e29442721a ("librc: Add check for crashed state")
|
||||||
This fixes #237
|
This fixes #237
|
||||||
|
|
||||||
commit 2eea73bfd5ce2f9993d52293fe7d25c0c804d592
|
commit 7850e12071891321f6564979e4e574eb775bf102
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
rc-functions.sh: Remove addon support
|
version 0.38.2
|
||||||
|
|
||||||
This is an old relic from Gentoo baselayout-1.x which should not be used
|
commit 11d3a8beadc4561e6b5d8f7fd86af39e4caf9d4f
|
||||||
any longer.
|
|
||||||
|
|
||||||
commit a571a42421b337380b6f5751635c55906bb8b508
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
modules: remove the ability to rename modules on the fly
|
Update ChangeLog
|
||||||
|
|
||||||
Kmod doesn't support the -o switch, so if you have been using this your
|
commit e36e9a30eb830ea27b467383fa2ae02cd2b0d9d4
|
||||||
module loads have been failing.
|
|
||||||
|
|
||||||
commit 79648ac1c6355975abca6acf6076e7022037523f
|
|
||||||
Author: Holger Hoffstätte <holger@applied-asynchrony.com>
|
Author: Holger Hoffstätte <holger@applied-asynchrony.com>
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
@@ -207,11 +57,11 @@ Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|||||||
|
|
||||||
This fixes #231.
|
This fixes #231.
|
||||||
|
|
||||||
commit 02af762e83640ec23bf64c5b814f0d3424d90e10
|
commit 7da99d77b5bbd789cb84be347d8b8d96d21f85c4
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
version 0.39
|
version 0.38.1
|
||||||
|
|
||||||
commit 01c34c28e6d6d7bfecc0f88bdf1fb15e97ab8823
|
commit 01c34c28e6d6d7bfecc0f88bdf1fb15e97ab8823
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
@@ -1348,3 +1198,141 @@ Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|||||||
|
|
||||||
X-Gentoo-Bug: 636574
|
X-Gentoo-Bug: 636574
|
||||||
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=636574
|
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=636574
|
||||||
|
|
||||||
|
commit a3d1c8a0e7d5586be13e2cd9b5029fd729bc1594
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
fix issue with --reexec call
|
||||||
|
|
||||||
|
commit 913b2ca53771742385d5c69164aefcaab634f012
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
supervise-daemon: use RC_SVCNAME as the first argument to the daemon
|
||||||
|
|
||||||
|
This makes ps show which service the supervisor is monitoring.
|
||||||
|
|
||||||
|
commit 3fe99c8b8264269dd935d52a1a52581cc0f14e8e
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
supervise-daemon: fix logging for reexec and the child command line
|
||||||
|
|
||||||
|
commit 27b8183de2f2bfd7411c14c1ec28543ca8a36602
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
log as supervise-daemon not the service
|
||||||
|
|
||||||
|
commit f32d8e1bfe16caf233d1180921f4aeed77d7476d
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
supervise-daemon: clarify a log message
|
||||||
|
|
||||||
|
commit d019f34a83b0ad5e890f685b1263b281ab54ce54
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
supervise-daemon: log the command line we run to spawn the child process
|
||||||
|
|
||||||
|
commit bb9c481f02cb1843e00bf32e98caf18b6b56bb4d
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
supervise-daemon: log with the service name instead of "supervise-daemon"
|
||||||
|
|
||||||
|
commit 82da844b42ff83b2ebf944198e56ac2d81851897
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
implement "unsupervised" status
|
||||||
|
|
||||||
|
The unsupervised status is to be used when a supervisor of a supervised
|
||||||
|
service dies but leaves the service daemon itself running.
|
||||||
|
|
||||||
|
commit 667a09983ca5311824aa88c42d39a495c540fc4c
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
supervise-daemon: remove child_pid from saved options during shutdown
|
||||||
|
|
||||||
|
This allows us to detect when the supervisor dies unexpectedly because
|
||||||
|
in that case child_pid will still exist.
|
||||||
|
|
||||||
|
commit cf429ee359356d736c818e8b35db8fca887e7332
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
rc_service_value_set: remove the option if NULL is the value
|
||||||
|
|
||||||
|
This allows the equivalent of "unsetting" a value for a service.
|
||||||
|
|
||||||
|
commit 6f3e2e2d7de61ab28cf03937ccf2e5f80b62190a
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
supervise-daemon.sh: fix status function with no namespaces
|
||||||
|
|
||||||
|
commit 35b88fb42bb8e0a56cdc1947342f1b89c98658bc
|
||||||
|
Author: Patrick McLean <chutzpah@gentoo.org>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
cgroups_cleanup: clean up shutdown signaling
|
||||||
|
|
||||||
|
- do not sleep for the full 90 seconds if processes are dead
|
||||||
|
- re-arrange the order of signals we attempt to send to the processes
|
||||||
|
|
||||||
|
commit a428c325a902bba55a849a07a59c0c1567404db2
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
add "unsupervised" status and return code 64 to supervise-daemon status function
|
||||||
|
|
||||||
|
This is to be used if the service is being supervised and the
|
||||||
|
supervisor is somehow killed.
|
||||||
|
|
||||||
|
Currently, this is very linux specific, but I will expand to other
|
||||||
|
platforms, patches are welcome.
|
||||||
|
|
||||||
|
commit 3219ecd6085231d7cc1268323a5be6a69f8c9143
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
supervise-daemon: fix build issue for >=glibc-2.26
|
||||||
|
|
||||||
|
X-Gentoo-Bug: 635334
|
||||||
|
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=635334
|
||||||
|
|
||||||
|
commit 0d8dc4f798cc0d707fc64e8bffcba4fbceb32935
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
version 0.35
|
||||||
|
|
||||||
|
commit f3c70bf5b5aa18e8dc94d4949f05568e0741c5cb
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
Update ChangeLog
|
||||||
|
|
||||||
|
commit f5acc66db7d1a0bfad6a40eefc0240b80f52df94
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
rc_find_pids: ignore pids that are not in our pid namespace
|
||||||
|
|
||||||
|
X-Gentoo-Bug: 634634
|
||||||
|
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=634634
|
||||||
|
|
||||||
|
commit fdce4769f2e0f4175163ffa181c7b3b2192f7b22
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
supervise-daemon: multiple fixes
|
||||||
|
|
||||||
|
- Harden against dying by handling all signals that would terminate the
|
||||||
|
program and adding --reexec support
|
||||||
|
- factor the supervisor into its own function
|
||||||
|
- fix test for whether we are already running
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
NAME= openrc
|
NAME= openrc
|
||||||
VERSION= 0.39.2
|
VERSION= 0.38.3
|
||||||
PKG= ${NAME}-${VERSION}
|
PKG= ${NAME}-${VERSION}
|
||||||
|
|||||||
28
NEWS.md
28
NEWS.md
@@ -4,34 +4,6 @@ OpenRC NEWS
|
|||||||
This file will contain a list of notable changes for each release. Note
|
This file will contain a list of notable changes for each release. Note
|
||||||
the information in this file is in reverse order.
|
the information in this file is in reverse order.
|
||||||
|
|
||||||
## OpenRC 0.39
|
|
||||||
|
|
||||||
This version removes the support for addons.
|
|
||||||
The only place I know that this was used was Gentoo Baselayout 1.x, so
|
|
||||||
it shouldn't affect anyone since baselayout-1 has been dead for a few
|
|
||||||
years.
|
|
||||||
|
|
||||||
Since all supported Linux kernel versions now make efivarfs immutable
|
|
||||||
and all of the tools that access efivarfs are aware of this, we no
|
|
||||||
longer mount efivarfs read-only. See the following github issue for more
|
|
||||||
information:
|
|
||||||
|
|
||||||
https://github.com/openrc/openrc/issues/238
|
|
||||||
|
|
||||||
This version adds timed shutdown and cancelation of shutdown to
|
|
||||||
openrc-shutdown. Shutdowns can now be delayed for a certain amount of
|
|
||||||
time or scheduled for an exact time.
|
|
||||||
|
|
||||||
supervise-daemon supports health checks, which are a periodic way to make sure a
|
|
||||||
service is healthy. For more information on setting this up, please see
|
|
||||||
supervise-daemon-guide.md.
|
|
||||||
|
|
||||||
The --first-time switch has been added to all modprobe commands in the
|
|
||||||
modules service. This means that, on Linux, you will see failures if a
|
|
||||||
module was loaded by an initramfs or device manager before this service
|
|
||||||
runs. These messages are harmless, but to clean them up, you should adjust your
|
|
||||||
modules autoload configuration.
|
|
||||||
|
|
||||||
## OpenRC 0.37
|
## OpenRC 0.37
|
||||||
|
|
||||||
start-stop-daemon now supports logging stdout and stderr of daemons to
|
start-stop-daemon now supports logging stdout and stderr of daemons to
|
||||||
|
|||||||
@@ -8,6 +8,11 @@
|
|||||||
#modules_2="ipv6"
|
#modules_2="ipv6"
|
||||||
#modules="ohci1394"
|
#modules="ohci1394"
|
||||||
|
|
||||||
|
# Linux users can give modules a different name when they load - the new name
|
||||||
|
# will also be used to pick arguments below.
|
||||||
|
# This is not supported on FreeBSD.
|
||||||
|
#modules="dummy:dummy1"
|
||||||
|
|
||||||
# Linux users can give the modules some arguments if needed, per version
|
# Linux users can give the modules some arguments if needed, per version
|
||||||
# if necessary.
|
# if necessary.
|
||||||
# Again, the most specific versioned variable will take precedence.
|
# Again, the most specific versioned variable will take precedence.
|
||||||
|
|||||||
@@ -56,12 +56,11 @@ load_modules()
|
|||||||
ebegin "Loading module $x"
|
ebegin "Loading module $x"
|
||||||
case "$RC_UNAME" in
|
case "$RC_UNAME" in
|
||||||
FreeBSD) kldload "$x"; rc=$? ;;
|
FreeBSD) kldload "$x"; rc=$? ;;
|
||||||
Linux) modprobe --first-time -q --use-blacklist "$x"; rc=$? ;;
|
Linux) modprobe --use-blacklist -q "$x"; rc=$? ;;
|
||||||
*) ;;
|
*) ;;
|
||||||
esac
|
esac
|
||||||
eend $rc "Failed to load $x"
|
eend $rc "Failed to load $x"
|
||||||
done
|
done
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
modules_load_d()
|
modules_load_d()
|
||||||
@@ -104,7 +103,7 @@ Linux_modules()
|
|||||||
x=${x%.*}
|
x=${x%.*}
|
||||||
done
|
done
|
||||||
|
|
||||||
local list= x= xx= y= args=
|
local list= x= xx= y= args= mpargs= a=
|
||||||
for x in $kv_variant_list ; do
|
for x in $kv_variant_list ; do
|
||||||
eval list=\$modules_$(shell_var "$x")
|
eval list=\$modules_$(shell_var "$x")
|
||||||
[ -n "$list" ] && break
|
[ -n "$list" ] && break
|
||||||
@@ -113,13 +112,24 @@ Linux_modules()
|
|||||||
|
|
||||||
[ -n "$list" ] && ebegin "Loading kernel modules"
|
[ -n "$list" ] && ebegin "Loading kernel modules"
|
||||||
for x in $list; do
|
for x in $list; do
|
||||||
|
a=${x#*:}
|
||||||
|
if [ "$a" = "$x" ]; then
|
||||||
|
unset mpargs
|
||||||
|
else
|
||||||
|
x=${x%%:*}
|
||||||
|
mpargs="-o $a"
|
||||||
|
fi
|
||||||
|
aa=$(shell_var "$a")
|
||||||
xx=$(shell_var "$x")
|
xx=$(shell_var "$x")
|
||||||
for y in $kv_variant_list ; do
|
for y in $kv_variant_list ; do
|
||||||
|
eval args=\$module_${aa}_args_$(shell_var "$y")
|
||||||
|
[ -n "${args}" ] && break
|
||||||
eval args=\$module_${xx}_args_$(shell_var "$y")
|
eval args=\$module_${xx}_args_$(shell_var "$y")
|
||||||
[ -n "${args}" ] && break
|
[ -n "${args}" ] && break
|
||||||
done
|
done
|
||||||
|
[ -z "$args" ] && eval args=\$module_${aa}_args
|
||||||
[ -z "$args" ] && eval args=\$module_${xx}_args
|
[ -z "$args" ] && eval args=\$module_${xx}_args
|
||||||
eval modprobe --first-time --use-blacklist --verbose "$x" "$args"
|
eval modprobe --use-blacklist --verbose "$mpargs" "$x" "$args"
|
||||||
done
|
done
|
||||||
[ -n "$list" ] && eend
|
[ -n "$list" ] && eend
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ mount_misc()
|
|||||||
if [ -d /sys/firmware/efi/efivars ] &&
|
if [ -d /sys/firmware/efi/efivars ] &&
|
||||||
! mountinfo -q /sys/firmware/efi/efivars; then
|
! mountinfo -q /sys/firmware/efi/efivars; then
|
||||||
ebegin "Mounting efivarfs filesystem"
|
ebegin "Mounting efivarfs filesystem"
|
||||||
mount -n -t efivarfs -o ${sysfs_opts} \
|
mount -n -t efivarfs -o ro \
|
||||||
efivarfs /sys/firmware/efi/efivars 2> /dev/null
|
efivarfs /sys/firmware/efi/efivars 2> /dev/null
|
||||||
eend 0
|
eend 0
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
.Nd bring the system down
|
.Nd bring the system down
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl c , -cancel
|
|
||||||
.Op Fl d , -no-write
|
.Op Fl d , -no-write
|
||||||
.Op Fl D , -dry-run
|
.Op Fl D , -dry-run
|
||||||
.Op Fl H , -halt
|
.Op Fl H , -halt
|
||||||
@@ -33,8 +32,6 @@ is the utility that communicates with
|
|||||||
to bring down the system or instruct openrc-init to re-execute itself.
|
to bring down the system or instruct openrc-init to re-execute itself.
|
||||||
It supports the following options:
|
It supports the following options:
|
||||||
.Bl -tag -width "poweroff"
|
.Bl -tag -width "poweroff"
|
||||||
.It Fl c , -cancel
|
|
||||||
Cancel a pending shutdown.
|
|
||||||
.It Fl d , -no-write
|
.It Fl d , -no-write
|
||||||
Do not write the wtmp boot record.
|
Do not write the wtmp boot record.
|
||||||
.It Fl D , -dry-run
|
.It Fl D , -dry-run
|
||||||
|
|||||||
@@ -16,10 +16,6 @@
|
|||||||
.Nd starts a daemon and restarts it if it crashes
|
.Nd starts a daemon and restarts it if it crashes
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Fl a , -healthcheck-timer
|
|
||||||
.Ar seconds
|
|
||||||
.Fl A , -healthcheck-delay
|
|
||||||
.Ar seconds
|
|
||||||
.Fl D , -respawn-delay
|
.Fl D , -respawn-delay
|
||||||
.Ar seconds
|
.Ar seconds
|
||||||
.Fl d , -chdir
|
.Fl d , -chdir
|
||||||
@@ -94,11 +90,6 @@ Print the action(s) that are taken just before doing them.
|
|||||||
.Pp
|
.Pp
|
||||||
The options are as follows:
|
The options are as follows:
|
||||||
.Bl -tag -width indent
|
.Bl -tag -width indent
|
||||||
.Fl a , -healthcheck-timer Ar seconds
|
|
||||||
Run the healthcheck() command, possibly followed by the unhealthy()
|
|
||||||
command every time this number of seconds passes.
|
|
||||||
.Fl A , -healthcheck-delay Ar seconds
|
|
||||||
Wait this long before the first health check.
|
|
||||||
.It Fl D , -respawn-delay Ar seconds
|
.It Fl D , -respawn-delay Ar seconds
|
||||||
wait this number of seconds before restarting a daemon after it crashes.
|
wait this number of seconds before restarting a daemon after it crashes.
|
||||||
The default is 0.
|
The default is 0.
|
||||||
|
|||||||
1
sh/.gitignore
vendored
1
sh/.gitignore
vendored
@@ -1,5 +1,6 @@
|
|||||||
functions.sh
|
functions.sh
|
||||||
gendepends.sh
|
gendepends.sh
|
||||||
|
rc-functions.sh
|
||||||
openrc-run.sh
|
openrc-run.sh
|
||||||
cgroup-release-agent.sh
|
cgroup-release-agent.sh
|
||||||
init.sh
|
init.sh
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
DIR= ${LIBEXECDIR}/sh
|
DIR= ${LIBEXECDIR}/sh
|
||||||
SRCS= init.sh.in functions.sh.in gendepends.sh.in \
|
SRCS= init.sh.in functions.sh.in gendepends.sh.in \
|
||||||
openrc-run.sh.in ${SRCS-${OS}}
|
openrc-run.sh.in rc-functions.sh.in ${SRCS-${OS}}
|
||||||
INC= rc-mount.sh functions.sh rc-functions.sh runit.sh s6.sh \
|
INC= rc-mount.sh functions.sh rc-functions.sh runit.sh s6.sh \
|
||||||
start-stop-daemon.sh supervise-daemon.sh
|
start-stop-daemon.sh supervise-daemon.sh
|
||||||
BIN= gendepends.sh init.sh openrc-run.sh ${BIN-${OS}}
|
BIN= gendepends.sh init.sh openrc-run.sh ${BIN-${OS}}
|
||||||
|
|||||||
@@ -2,6 +2,42 @@
|
|||||||
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
|
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
|
||||||
# Released under the 2-clause BSD license.
|
# Released under the 2-clause BSD license.
|
||||||
|
|
||||||
|
has_addon()
|
||||||
|
{
|
||||||
|
[ -e /@LIB@/rc/addons/"$1".sh -o -e /@LIB@/rcscripts/addons/"$1".sh ]
|
||||||
|
}
|
||||||
|
|
||||||
|
_addon_warn()
|
||||||
|
{
|
||||||
|
eindent
|
||||||
|
ewarn "$RC_SVCNAME uses addon code which is deprecated"
|
||||||
|
ewarn "and may not be available in the future."
|
||||||
|
eoutdent
|
||||||
|
}
|
||||||
|
|
||||||
|
import_addon()
|
||||||
|
{
|
||||||
|
if [ -e /@LIB@/rc/addons/"$1".sh ]; then
|
||||||
|
_addon_warn
|
||||||
|
. /@LIB@/rc/addons/"$1".sh
|
||||||
|
elif [ -e /@LIB@/rcscripts/addons/"$1".sh ]; then
|
||||||
|
_addon_warn
|
||||||
|
. /@LIB@/rcscripts/addons/"$1".sh
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
start_addon()
|
||||||
|
{
|
||||||
|
( import_addon "$1-start" )
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_addon()
|
||||||
|
{
|
||||||
|
( import_addon "$1-stop" )
|
||||||
|
}
|
||||||
|
|
||||||
net_fs_list="afs ceph cifs coda davfs fuse fuse.sshfs gfs glusterfs lustre
|
net_fs_list="afs ceph cifs coda davfs fuse fuse.sshfs gfs glusterfs lustre
|
||||||
ncpfs nfs nfs4 ocfs2 shfs smbfs"
|
ncpfs nfs nfs4 ocfs2 shfs smbfs"
|
||||||
is_net_fs()
|
is_net_fs()
|
||||||
@@ -10,8 +10,6 @@
|
|||||||
# This file may not be copied, modified, propagated, or distributed
|
# This file may not be copied, modified, propagated, or distributed
|
||||||
# except according to the terms contained in the LICENSE file.
|
# except according to the terms contained in the LICENSE file.
|
||||||
|
|
||||||
extra_commands="healthcheck unhealthy ${extra_commands}"
|
|
||||||
|
|
||||||
supervise_start()
|
supervise_start()
|
||||||
{
|
{
|
||||||
if [ -z "$command" ]; then
|
if [ -z "$command" ]; then
|
||||||
@@ -34,8 +32,6 @@ supervise_start()
|
|||||||
${respawn_delay:+--respawn-delay} $respawn_delay \
|
${respawn_delay:+--respawn-delay} $respawn_delay \
|
||||||
${respawn_max:+--respawn-max} $respawn_max \
|
${respawn_max:+--respawn-max} $respawn_max \
|
||||||
${respawn_period:+--respawn-period} $respawn_period \
|
${respawn_period:+--respawn-period} $respawn_period \
|
||||||
${healthcheck_delay:+--healthcheck-delay} $healthcheck_delay \
|
|
||||||
${healthcheck_timer:+--healthcheck-timer} $healthcheck_timer \
|
|
||||||
${command_user+--user} $command_user \
|
${command_user+--user} $command_user \
|
||||||
${umask+--umask} $umask \
|
${umask+--umask} $umask \
|
||||||
${supervise_daemon_args:-${start_stop_daemon_args}} \
|
${supervise_daemon_args:-${start_stop_daemon_args}} \
|
||||||
@@ -102,13 +98,3 @@ supervise_status()
|
|||||||
return 3
|
return 3
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
healthcheck()
|
|
||||||
{
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
unhealthy()
|
|
||||||
{
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ SRCS+= rc-selinux.c
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq (${OS},Linux)
|
ifeq (${OS},Linux)
|
||||||
SRCS+= kill_all.c openrc-init.c openrc-shutdown.c broadcast.c rc-wtmp.c
|
SRCS+= kill_all.c openrc-init.c openrc-shutdown.c rc-wtmp.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CLEANFILES= version.h rc-selinux.o
|
CLEANFILES= version.h rc-selinux.o
|
||||||
@@ -134,7 +134,7 @@ mountinfo: mountinfo.o _usage.o rc-misc.o
|
|||||||
openrc rc: rc.o rc-logger.o rc-misc.o rc-plugin.o _usage.o
|
openrc rc: rc.o rc-logger.o rc-misc.o rc-plugin.o _usage.o
|
||||||
${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
|
${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
|
||||||
|
|
||||||
openrc-shutdown: openrc-shutdown.o rc-misc.o _usage.o broadcast.o rc-wtmp.o
|
openrc-shutdown: openrc-shutdown.o _usage.o rc-wtmp.o
|
||||||
${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
|
${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
|
||||||
|
|
||||||
openrc-run runscript: openrc-run.o _usage.o rc-misc.o rc-plugin.o
|
openrc-run runscript: openrc-run.o _usage.o rc-misc.o rc-plugin.o
|
||||||
@@ -161,7 +161,7 @@ rc-update: rc-update.o _usage.o rc-misc.o
|
|||||||
start-stop-daemon: start-stop-daemon.o _usage.o rc-misc.o rc-pipes.o rc-schedules.o
|
start-stop-daemon: start-stop-daemon.o _usage.o rc-misc.o rc-pipes.o rc-schedules.o
|
||||||
${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
|
${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
|
||||||
|
|
||||||
supervise-daemon: supervise-daemon.o _usage.o rc-misc.o rc-plugin.o rc-schedules.o
|
supervise-daemon: supervise-daemon.o _usage.o rc-misc.o rc-schedules.o
|
||||||
${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
|
${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
|
||||||
|
|
||||||
service_get_value service_set_value get_options save_options: do_value.o rc-misc.o
|
service_get_value service_set_value get_options save_options: do_value.o rc-misc.o
|
||||||
|
|||||||
@@ -1,209 +0,0 @@
|
|||||||
/*
|
|
||||||
* broadcast.c
|
|
||||||
* broadcast a message to every logged in user
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2018 Sony Interactive Entertainment Inc.
|
|
||||||
*
|
|
||||||
* This file is part of OpenRC. It is subject to the license terms in
|
|
||||||
* the LICENSE file found in the top-level directory of this
|
|
||||||
* distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
|
|
||||||
* This file may not be copied, modified, propagated, or distributed
|
|
||||||
* except according to the terms contained in the LICENSE file.
|
|
||||||
*/
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/sysmacros.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <utmpx.h>
|
|
||||||
#include <pwd.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <setjmp.h>
|
|
||||||
#include <paths.h>
|
|
||||||
#include <sys/utsname.h>
|
|
||||||
|
|
||||||
#include "broadcast.h"
|
|
||||||
#include "helpers.h"
|
|
||||||
|
|
||||||
#ifndef _PATH_DEV
|
|
||||||
# define _PATH_DEV "/dev/"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef UT_LINESIZE
|
|
||||||
#define UT_LINESIZE __UT_LINESIZE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static sigjmp_buf jbuf;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Alarm handler
|
|
||||||
*/
|
|
||||||
/*ARGSUSED*/
|
|
||||||
# ifdef __GNUC__
|
|
||||||
static void handler(int arg __attribute__((unused)))
|
|
||||||
# else
|
|
||||||
static void handler(int arg)
|
|
||||||
# endif
|
|
||||||
{
|
|
||||||
siglongjmp(jbuf, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void getuidtty(char **userp, char **ttyp)
|
|
||||||
{
|
|
||||||
struct passwd *pwd;
|
|
||||||
uid_t uid;
|
|
||||||
char *tty;
|
|
||||||
static char uidbuf[32];
|
|
||||||
static char ttynm[UT_LINESIZE + 4];
|
|
||||||
|
|
||||||
uid = getuid();
|
|
||||||
if ((pwd = getpwuid(uid)) != NULL) {
|
|
||||||
uidbuf[0] = 0;
|
|
||||||
strncat(uidbuf, pwd->pw_name, sizeof(uidbuf) - 1);
|
|
||||||
} else {
|
|
||||||
if (uid)
|
|
||||||
sprintf(uidbuf, "uid %d", (int) uid);
|
|
||||||
else
|
|
||||||
sprintf(uidbuf, "root");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((tty = ttyname(0)) != NULL) {
|
|
||||||
const size_t plen = strlen(_PATH_DEV);
|
|
||||||
if (strncmp(tty, _PATH_DEV, plen) == 0) {
|
|
||||||
tty += plen;
|
|
||||||
if (tty[0] == '/')
|
|
||||||
tty++;
|
|
||||||
}
|
|
||||||
snprintf(ttynm, sizeof(ttynm), "(%.*s) ",
|
|
||||||
UT_LINESIZE, tty);
|
|
||||||
} else
|
|
||||||
ttynm[0] = 0;
|
|
||||||
|
|
||||||
*userp = uidbuf;
|
|
||||||
*ttyp = ttynm;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check whether the given filename looks like a tty device.
|
|
||||||
*/
|
|
||||||
static int file_isatty(const char *fname)
|
|
||||||
{
|
|
||||||
struct stat st;
|
|
||||||
int major;
|
|
||||||
|
|
||||||
if (stat(fname, &st) < 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (st.st_nlink != 1 || !S_ISCHR(st.st_mode))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* It would be an impossible task to list all major/minors
|
|
||||||
* of tty devices here, so we just exclude the obvious
|
|
||||||
* majors of which just opening has side-effects:
|
|
||||||
* printers and tapes.
|
|
||||||
*/
|
|
||||||
major = major(st.st_dev);
|
|
||||||
if (major == 1 || major == 2 || major == 6 || major == 9 ||
|
|
||||||
major == 12 || major == 16 || major == 21 || major == 27 ||
|
|
||||||
major == 37 || major == 96 || major == 97 || major == 206 ||
|
|
||||||
major == 230)
|
|
||||||
return 0;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* broadcast function.
|
|
||||||
*/
|
|
||||||
void broadcast(char *text)
|
|
||||||
{
|
|
||||||
char *tty;
|
|
||||||
char *user;
|
|
||||||
struct utsname name;
|
|
||||||
time_t t;
|
|
||||||
char *date;
|
|
||||||
char *p;
|
|
||||||
char *line = NULL;
|
|
||||||
struct sigaction sa;
|
|
||||||
int fd;
|
|
||||||
FILE *tp;
|
|
||||||
int flags;
|
|
||||||
char *term = NULL;
|
|
||||||
struct utmpx *utmp;
|
|
||||||
|
|
||||||
getuidtty(&user, &tty);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get and report current hostname, to make it easier to find out
|
|
||||||
* which machine is being shut down.
|
|
||||||
*/
|
|
||||||
uname(&name);
|
|
||||||
|
|
||||||
/* Get the time */
|
|
||||||
time(&t);
|
|
||||||
date = ctime(&t);
|
|
||||||
p = strchr(date, '\n');
|
|
||||||
if (p)
|
|
||||||
*p = 0;
|
|
||||||
|
|
||||||
xasprintf(&line, "\007\r\nBroadcast message from %s@%s %s(%s):\r\n\r\n",
|
|
||||||
user, name.nodename, tty, date);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Fork to avoid hanging in a write()
|
|
||||||
*/
|
|
||||||
if (fork() != 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
memset(&sa, 0, sizeof(sa));
|
|
||||||
sa.sa_handler = handler;
|
|
||||||
sigemptyset(&sa.sa_mask);
|
|
||||||
sigaction(SIGALRM, &sa, NULL);
|
|
||||||
|
|
||||||
setutxent();
|
|
||||||
|
|
||||||
while ((utmp = getutxent()) != NULL) {
|
|
||||||
if (utmp->ut_type != USER_PROCESS || utmp->ut_user[0] == 0)
|
|
||||||
continue;
|
|
||||||
if (strncmp(utmp->ut_line, _PATH_DEV, strlen(_PATH_DEV)) == 0)
|
|
||||||
xasprintf(&term, "%s", utmp->ut_line);
|
|
||||||
else
|
|
||||||
xasprintf(&term, "%s%s", _PATH_DEV, utmp->ut_line);
|
|
||||||
if (strstr(term, "/../")) {
|
|
||||||
free(term);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Open it non-delay
|
|
||||||
*/
|
|
||||||
if (sigsetjmp(jbuf, 1) == 0) {
|
|
||||||
alarm(2);
|
|
||||||
flags = O_WRONLY|O_NDELAY|O_NOCTTY;
|
|
||||||
if (file_isatty(term) && (fd = open(term, flags)) >= 0) {
|
|
||||||
if (isatty(fd) && (tp = fdopen(fd, "w")) != NULL) {
|
|
||||||
fputs(line, tp);
|
|
||||||
fputs(text, tp);
|
|
||||||
fflush(tp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
alarm(0);
|
|
||||||
if (fd >= 0)
|
|
||||||
close(fd);
|
|
||||||
if (tp != NULL)
|
|
||||||
fclose(tp);
|
|
||||||
free(term);
|
|
||||||
}
|
|
||||||
endutxent();
|
|
||||||
free(line);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2018 Sony Interactive Entertainment Inc.
|
|
||||||
*
|
|
||||||
* This file is part of OpenRC. It is subject to the license terms in
|
|
||||||
* the LICENSE file found in the top-level directory of this
|
|
||||||
* distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
|
|
||||||
* This file may not be copied, modified, propagated, or distributed
|
|
||||||
* except according to the terms contained in the LICENSE file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef BROADCAST_H
|
|
||||||
#define BROADCAST_H
|
|
||||||
|
|
||||||
void broadcast(char *text);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -58,7 +58,7 @@ static int mount_proc(void)
|
|||||||
if (exists("/proc/version"))
|
if (exists("/proc/version"))
|
||||||
return 0;
|
return 0;
|
||||||
pid = fork();
|
pid = fork();
|
||||||
switch (pid) {
|
switch(pid) {
|
||||||
case -1:
|
case -1:
|
||||||
syslog(LOG_ERR, "Unable to fork");
|
syslog(LOG_ERR, "Unable to fork");
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@@ -45,7 +44,7 @@ static pid_t do_openrc(const char *runlevel)
|
|||||||
sigset_t signals;
|
sigset_t signals;
|
||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
switch (pid) {
|
switch(pid) {
|
||||||
case -1:
|
case -1:
|
||||||
perror("fork");
|
perror("fork");
|
||||||
break;
|
break;
|
||||||
@@ -97,15 +96,12 @@ static void handle_reexec(char *my_name)
|
|||||||
static void handle_shutdown(const char *runlevel, int cmd)
|
static void handle_shutdown(const char *runlevel, int cmd)
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
struct timespec ts;
|
|
||||||
|
|
||||||
pid = do_openrc(runlevel);
|
pid = do_openrc(runlevel);
|
||||||
while (waitpid(pid, NULL, 0) != pid);
|
while (waitpid(pid, NULL, 0) != pid);
|
||||||
printf("Sending the final term signal\n");
|
printf("Sending the final term signal\n");
|
||||||
kill(-1, SIGTERM);
|
kill(-1, SIGTERM);
|
||||||
ts.tv_sec = 3;
|
sleep(3);
|
||||||
ts.tv_nsec = 0;
|
|
||||||
nanosleep(&ts, NULL);
|
|
||||||
printf("Sending the final kill signal\n");
|
printf("Sending the final kill signal\n");
|
||||||
kill(-1, SIGKILL);
|
kill(-1, SIGKILL);
|
||||||
sync();
|
sync();
|
||||||
@@ -139,7 +135,7 @@ static void reap_zombies(void)
|
|||||||
|
|
||||||
static void signal_handler(int sig)
|
static void signal_handler(int sig)
|
||||||
{
|
{
|
||||||
switch (sig) {
|
switch(sig) {
|
||||||
case SIGINT:
|
case SIGINT:
|
||||||
handle_shutdown("reboot", RB_AUTOBOOT);
|
handle_shutdown("reboot", RB_AUTOBOOT);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -25,24 +25,20 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <syslog.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
|
||||||
#include "broadcast.h"
|
|
||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
#include "rc.h"
|
#include "rc.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "rc-misc.h"
|
|
||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
#include "rc-wtmp.h"
|
#include "rc-wtmp.h"
|
||||||
|
|
||||||
const char *applet = NULL;
|
const char *applet = NULL;
|
||||||
const char *extraopts = NULL;
|
const char *extraopts = NULL;
|
||||||
const char *getoptstring = "cdDfFHKpRrsw" getoptstring_COMMON;
|
const char *getoptstring = "dDHKpRrsw" getoptstring_COMMON;
|
||||||
const struct option longopts[] = {
|
const struct option longopts[] = {
|
||||||
{ "cancel", no_argument, NULL, 'c'},
|
|
||||||
{ "no-write", no_argument, NULL, 'd'},
|
{ "no-write", no_argument, NULL, 'd'},
|
||||||
{ "dry-run", no_argument, NULL, 'D'},
|
{ "dry-run", no_argument, NULL, 'D'},
|
||||||
{ "halt", no_argument, NULL, 'H'},
|
{ "halt", no_argument, NULL, 'H'},
|
||||||
@@ -55,7 +51,6 @@ const struct option longopts[] = {
|
|||||||
longopts_COMMON
|
longopts_COMMON
|
||||||
};
|
};
|
||||||
const char * const longopts_help[] = {
|
const char * const longopts_help[] = {
|
||||||
"cancel a pending shutdown",
|
|
||||||
"do not write wtmp record",
|
"do not write wtmp record",
|
||||||
"print actions instead of executing them",
|
"print actions instead of executing them",
|
||||||
"halt the system",
|
"halt the system",
|
||||||
@@ -69,12 +64,8 @@ const char * const longopts_help[] = {
|
|||||||
};
|
};
|
||||||
const char *usagestring = NULL;
|
const char *usagestring = NULL;
|
||||||
const char *exclusive = "Select one of "
|
const char *exclusive = "Select one of "
|
||||||
"--cancel, --halt, --kexec, --poweroff, --reexec, --reboot, --single or \n"
|
"--halt, --kexec, --poweroff, --reexec, --reboot, --single or --write-only";
|
||||||
"--write-only";
|
|
||||||
const char *nologin_file = RC_SYSCONFDIR"/nologin";
|
|
||||||
const char *shutdown_pid = "/run/openrc-shutdown.pid";
|
|
||||||
|
|
||||||
static bool do_cancel = false;
|
|
||||||
static bool do_dryrun = false;
|
static bool do_dryrun = false;
|
||||||
static bool do_halt = false;
|
static bool do_halt = false;
|
||||||
static bool do_kexec = false;
|
static bool do_kexec = false;
|
||||||
@@ -85,40 +76,6 @@ static bool do_single = false;
|
|||||||
static bool do_wtmp = true;
|
static bool do_wtmp = true;
|
||||||
static bool do_wtmp_only = false;
|
static bool do_wtmp_only = false;
|
||||||
|
|
||||||
static void cancel_shutdown(void)
|
|
||||||
{
|
|
||||||
pid_t pid;
|
|
||||||
|
|
||||||
pid = get_pid(applet, shutdown_pid);
|
|
||||||
if (pid <= 0)
|
|
||||||
eerrorx("%s: Unable to cancel shutdown", applet);
|
|
||||||
|
|
||||||
if (kill(pid, SIGTERM) != -1)
|
|
||||||
einfo("%s: shutdown canceled", applet);
|
|
||||||
else
|
|
||||||
eerrorx("%s: Unable to cancel shutdown", applet);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create the nologin file.
|
|
||||||
*/
|
|
||||||
static void create_nologin(int mins)
|
|
||||||
{
|
|
||||||
FILE *fp;
|
|
||||||
time_t t;
|
|
||||||
|
|
||||||
time(&t);
|
|
||||||
t += 60 * mins;
|
|
||||||
|
|
||||||
if ((fp = fopen(nologin_file, "w")) != NULL) {
|
|
||||||
fprintf(fp, "\rThe system is going down on %s\r\n", ctime(&t));
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Send a command to our init
|
|
||||||
*/
|
|
||||||
static void send_cmd(const char *cmd)
|
static void send_cmd(const char *cmd)
|
||||||
{
|
{
|
||||||
FILE *fifo;
|
FILE *fifo;
|
||||||
@@ -142,59 +99,16 @@ static void send_cmd(const char *cmd)
|
|||||||
fclose(fifo);
|
fclose(fifo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* sleep without being interrupted.
|
|
||||||
* The idea for this code came from sysvinit.
|
|
||||||
*/
|
|
||||||
static void sleep_no_interrupt(int seconds)
|
|
||||||
{
|
|
||||||
struct timespec duration;
|
|
||||||
struct timespec remaining;
|
|
||||||
|
|
||||||
duration.tv_sec = seconds;
|
|
||||||
duration.tv_nsec = 0;
|
|
||||||
|
|
||||||
while(nanosleep(&duration, &remaining) < 0 && errno == EINTR)
|
|
||||||
duration = remaining;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void stop_shutdown(int sig)
|
|
||||||
{
|
|
||||||
/* use the sig parameter so the compiler will not complain */
|
|
||||||
if (sig == SIGINT)
|
|
||||||
;
|
|
||||||
unlink(nologin_file);
|
|
||||||
unlink(shutdown_pid);
|
|
||||||
einfo("Shutdown canceled");
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *ch = NULL;
|
|
||||||
int opt;
|
int opt;
|
||||||
int cmd_count = 0;
|
int cmd_count = 0;
|
||||||
int hour = 0;
|
|
||||||
int min = 0;
|
|
||||||
int shutdown_delay = 0;
|
|
||||||
struct sigaction sa;
|
|
||||||
struct tm *lt;
|
|
||||||
time_t tv;
|
|
||||||
bool need_warning = false;
|
|
||||||
char *msg = NULL;
|
|
||||||
char *state = NULL;
|
|
||||||
char *time_arg = NULL;
|
|
||||||
FILE *fp;
|
|
||||||
|
|
||||||
applet = basename_c(argv[0]);
|
applet = basename_c(argv[0]);
|
||||||
while ((opt = getopt_long(argc, argv, getoptstring,
|
while ((opt = getopt_long(argc, argv, getoptstring,
|
||||||
longopts, (int *) 0)) != -1)
|
longopts, (int *) 0)) != -1)
|
||||||
{
|
{
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'c':
|
|
||||||
do_cancel = true;
|
|
||||||
cmd_count++;
|
|
||||||
break;
|
|
||||||
case 'd':
|
case 'd':
|
||||||
do_wtmp = false;
|
do_wtmp = false;
|
||||||
break;
|
break;
|
||||||
@@ -203,17 +117,14 @@ int main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
case 'H':
|
case 'H':
|
||||||
do_halt = true;
|
do_halt = true;
|
||||||
xasprintf(&state, "%s", "halt");
|
|
||||||
cmd_count++;
|
cmd_count++;
|
||||||
break;
|
break;
|
||||||
case 'K':
|
case 'K':
|
||||||
do_kexec = true;
|
do_kexec = true;
|
||||||
xasprintf(&state, "%s", "reboot");
|
|
||||||
cmd_count++;
|
cmd_count++;
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
do_poweroff = true;
|
do_poweroff = true;
|
||||||
xasprintf(&state, "%s", "power off");
|
|
||||||
cmd_count++;
|
cmd_count++;
|
||||||
break;
|
break;
|
||||||
case 'R':
|
case 'R':
|
||||||
@@ -222,12 +133,10 @@ int main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
do_reboot = true;
|
do_reboot = true;
|
||||||
xasprintf(&state, "%s", "reboot");
|
|
||||||
cmd_count++;
|
cmd_count++;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
do_single = true;
|
do_single = true;
|
||||||
xasprintf(&state, "%s", "go down for maintenance");
|
|
||||||
cmd_count++;
|
cmd_count++;
|
||||||
break;
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
@@ -237,91 +146,12 @@ int main(int argc, char **argv)
|
|||||||
case_RC_COMMON_GETOPT
|
case_RC_COMMON_GETOPT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (geteuid() != 0)
|
if (geteuid() != 0 && ! do_dryrun)
|
||||||
eerrorx("%s: you must be root\n", applet);
|
eerrorx("%s: you must be root\n", applet);
|
||||||
if (cmd_count != 1) {
|
if (cmd_count != 1) {
|
||||||
eerror("%s: %s\n", applet, exclusive);
|
eerror("%s: %s\n", applet, exclusive);
|
||||||
usage(EXIT_FAILURE);
|
usage(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (do_cancel) {
|
|
||||||
cancel_shutdown();
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
} else if (do_reexec) {
|
|
||||||
send_cmd("reexec");
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
} else if (do_wtmp_only) {
|
|
||||||
log_wtmp("shutdown", "~~", 0, RUN_LVL, "~~");
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (optind >= argc) {
|
|
||||||
eerror("%s: No shutdown time specified", applet);
|
|
||||||
usage(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
time_arg = argv[optind];
|
|
||||||
if (*time_arg == '+')
|
|
||||||
time_arg++;
|
|
||||||
if (strcasecmp(time_arg, "now") == 0)
|
|
||||||
strcpy(time_arg, "0");
|
|
||||||
for (ch=time_arg; *ch; ch++)
|
|
||||||
if ((*ch < '0' || *ch > '9') && *ch != ':') {
|
|
||||||
eerror("%s: invalid time %s", applet, time_arg);
|
|
||||||
usage(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
if (strchr(time_arg, ':')) {
|
|
||||||
if ((sscanf(time_arg, "%2d:%2d", &hour, &min) != 2) ||
|
|
||||||
(hour > 23) || (min > 59)) {
|
|
||||||
eerror("%s: invalid time %s", applet, time_arg);
|
|
||||||
usage(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
time(&tv);
|
|
||||||
lt = localtime(&tv);
|
|
||||||
shutdown_delay = (hour * 60 + min) - (lt->tm_hour * 60 + lt->tm_min);
|
|
||||||
if (shutdown_delay < 0)
|
|
||||||
shutdown_delay += 1440;
|
|
||||||
} else {
|
|
||||||
shutdown_delay = atoi(time_arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
fp = fopen(shutdown_pid, "w");
|
|
||||||
if (!fp)
|
|
||||||
eerrorx("%s: fopen `%s': %s", applet, shutdown_pid, strerror(errno));
|
|
||||||
fprintf(fp, "%d\n", getpid());
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
openlog(applet, LOG_PID, LOG_DAEMON);
|
|
||||||
memset(&sa, 0, sizeof(sa));
|
|
||||||
sa.sa_handler = stop_shutdown;
|
|
||||||
sigemptyset(&sa.sa_mask);
|
|
||||||
sigaction(SIGINT, &sa, NULL);
|
|
||||||
sigaction(SIGTERM, &sa, NULL);
|
|
||||||
while (shutdown_delay > 0) {
|
|
||||||
need_warning = false;
|
|
||||||
if (shutdown_delay > 180)
|
|
||||||
need_warning = (shutdown_delay % 60 == 0);
|
|
||||||
else if (shutdown_delay > 60)
|
|
||||||
need_warning = (shutdown_delay % 30 == 0);
|
|
||||||
else if (shutdown_delay > 10)
|
|
||||||
need_warning = (shutdown_delay % 15 == 0);
|
|
||||||
else
|
|
||||||
need_warning = true;
|
|
||||||
if (shutdown_delay <= 5)
|
|
||||||
create_nologin(shutdown_delay);
|
|
||||||
if (need_warning) {
|
|
||||||
xasprintf(&msg, "\rThe system will %s in %d minutes\r\n",
|
|
||||||
state, shutdown_delay);
|
|
||||||
broadcast(msg);
|
|
||||||
free(msg);
|
|
||||||
}
|
|
||||||
sleep_no_interrupt(60);
|
|
||||||
shutdown_delay--;
|
|
||||||
}
|
|
||||||
xasprintf(&msg, "\rThe system will %s now\r\n", state);
|
|
||||||
broadcast(msg);
|
|
||||||
syslog(LOG_NOTICE, "The system will %s now", state);
|
|
||||||
unlink(nologin_file);
|
|
||||||
unlink(shutdown_pid);
|
|
||||||
if (do_halt)
|
if (do_halt)
|
||||||
send_cmd("halt");
|
send_cmd("halt");
|
||||||
else if (do_kexec)
|
else if (do_kexec)
|
||||||
@@ -330,6 +160,10 @@ int main(int argc, char **argv)
|
|||||||
send_cmd("poweroff");
|
send_cmd("poweroff");
|
||||||
else if (do_reboot)
|
else if (do_reboot)
|
||||||
send_cmd("reboot");
|
send_cmd("reboot");
|
||||||
|
else if (do_reexec)
|
||||||
|
send_cmd("reexec");
|
||||||
|
else if (do_wtmp_only)
|
||||||
|
log_wtmp("shutdown", "~~", 0, RUN_LVL, "~~");
|
||||||
else if (do_single)
|
else if (do_single)
|
||||||
send_cmd("single");
|
send_cmd("single");
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -351,9 +351,8 @@ int run_stop_schedule(const char *applet,
|
|||||||
|
|
||||||
tkilled += nkilled;
|
tkilled += nkilled;
|
||||||
break;
|
break;
|
||||||
case SC_FOREVER:
|
|
||||||
case SC_TIMEOUT:
|
case SC_TIMEOUT:
|
||||||
if (item->type == SC_TIMEOUT && item->value < 1) {
|
if (item->value < 1) {
|
||||||
item = NULL;
|
item = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -361,7 +360,7 @@ int run_stop_schedule(const char *applet,
|
|||||||
ts.tv_sec = 0;
|
ts.tv_sec = 0;
|
||||||
ts.tv_nsec = POLL_INTERVAL;
|
ts.tv_nsec = POLL_INTERVAL;
|
||||||
|
|
||||||
for (nsecs = 0; item->type == SC_FOREVER || nsecs < item->value; nsecs++) {
|
for (nsecs = 0; nsecs < item->value; nsecs++) {
|
||||||
for (nloops = 0;
|
for (nloops = 0;
|
||||||
nloops < ONE_SECOND / POLL_INTERVAL;
|
nloops < ONE_SECOND / POLL_INTERVAL;
|
||||||
nloops++)
|
nloops++)
|
||||||
|
|||||||
@@ -49,12 +49,10 @@ const char * const longopts_help[] = {
|
|||||||
"set xtrace when running the command",
|
"set xtrace when running the command",
|
||||||
"ignore dependencies",
|
"ignore dependencies",
|
||||||
"tests if the service exists or not",
|
"tests if the service exists or not",
|
||||||
"if the service is crashed run the command",
|
"if the service is crashed then run the command",
|
||||||
"if the service exists run the command",
|
"if the service exists then run the command",
|
||||||
"if the service is inactive run the command",
|
"if the service is inactive then run the command",
|
||||||
"if the service is not started run the command",
|
"if the service is not started then run the command",
|
||||||
"if the service is started run the command",
|
|
||||||
"if the service is stopped run the command",
|
|
||||||
"list all available services",
|
"list all available services",
|
||||||
"resolve the service name to an init script",
|
"resolve the service name to an init script",
|
||||||
"dry run (show what would happen)",
|
"dry run (show what would happen)",
|
||||||
|
|||||||
@@ -61,18 +61,15 @@ static struct pam_conv conv = { NULL, NULL};
|
|||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "rc.h"
|
#include "rc.h"
|
||||||
#include "rc-misc.h"
|
#include "rc-misc.h"
|
||||||
#include "rc-plugin.h"
|
|
||||||
#include "rc-schedules.h"
|
#include "rc-schedules.h"
|
||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
const char *applet = NULL;
|
const char *applet = NULL;
|
||||||
const char *extraopts = NULL;
|
const char *extraopts = NULL;
|
||||||
const char *getoptstring = "A:a:D:d:e:g:H:I:Kk:m:N:p:R:r:Su:1:2:3" \
|
const char *getoptstring = "D:d:e:g:I:Kk:m:N:p:R:r:Su:1:2:3" \
|
||||||
getoptstring_COMMON;
|
getoptstring_COMMON;
|
||||||
const struct option longopts[] = {
|
const struct option longopts[] = {
|
||||||
{ "healthcheck-timer", 1, NULL, 'a'},
|
|
||||||
{ "healthcheck-delay", 1, NULL, 'A'},
|
|
||||||
{ "respawn-delay", 1, NULL, 'D'},
|
{ "respawn-delay", 1, NULL, 'D'},
|
||||||
{ "chdir", 1, NULL, 'd'},
|
{ "chdir", 1, NULL, 'd'},
|
||||||
{ "env", 1, NULL, 'e'},
|
{ "env", 1, NULL, 'e'},
|
||||||
@@ -94,8 +91,6 @@ const struct option longopts[] = {
|
|||||||
longopts_COMMON
|
longopts_COMMON
|
||||||
};
|
};
|
||||||
const char * const longopts_help[] = {
|
const char * const longopts_help[] = {
|
||||||
"set an initial health check delay",
|
|
||||||
"set a health check timer",
|
|
||||||
"Set a respawn delay",
|
"Set a respawn delay",
|
||||||
"Change the PWD",
|
"Change the PWD",
|
||||||
"Set an environment string",
|
"Set an environment string",
|
||||||
@@ -118,9 +113,6 @@ const char * const longopts_help[] = {
|
|||||||
};
|
};
|
||||||
const char *usagestring = NULL;
|
const char *usagestring = NULL;
|
||||||
|
|
||||||
static int healthcheckdelay = 0;
|
|
||||||
static int healthchecktimer = 0;
|
|
||||||
static volatile sig_atomic_t do_healthcheck = 0;
|
|
||||||
static int nicelevel = 0;
|
static int nicelevel = 0;
|
||||||
static int ionicec = -1;
|
static int ionicec = -1;
|
||||||
static int ioniced = 0;
|
static int ioniced = 0;
|
||||||
@@ -191,22 +183,6 @@ static void handle_signal(int sig)
|
|||||||
re_exec_supervisor();
|
re_exec_supervisor();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void healthcheck(int sig)
|
|
||||||
{
|
|
||||||
if (sig == SIGALRM)
|
|
||||||
do_healthcheck = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void reap_zombies(int sig)
|
|
||||||
{
|
|
||||||
int serrno;
|
|
||||||
(void) sig;
|
|
||||||
|
|
||||||
serrno = errno;
|
|
||||||
while (waitpid((pid_t)(-1), NULL, WNOHANG) > 0) {}
|
|
||||||
errno = serrno;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char * expand_home(const char *home, const char *path)
|
static char * expand_home(const char *home, const char *path)
|
||||||
{
|
{
|
||||||
char *opath, *ppath, *p, *nh;
|
char *opath, *ppath, *p, *nh;
|
||||||
@@ -447,14 +423,10 @@ static void child_process(char *exec, char **argv)
|
|||||||
static void supervisor(char *exec, char **argv)
|
static void supervisor(char *exec, char **argv)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
pid_t wait_pid;
|
|
||||||
int i;
|
int i;
|
||||||
int nkilled;
|
int nkilled;
|
||||||
struct timespec ts;
|
|
||||||
time_t respawn_now= 0;
|
time_t respawn_now= 0;
|
||||||
time_t first_spawn= 0;
|
time_t first_spawn= 0;
|
||||||
pid_t health_pid;
|
|
||||||
int health_status;
|
|
||||||
|
|
||||||
#ifndef RC_DEBUG
|
#ifndef RC_DEBUG
|
||||||
signal_setup_restart(SIGHUP, handle_signal);
|
signal_setup_restart(SIGHUP, handle_signal);
|
||||||
@@ -467,7 +439,6 @@ static void supervisor(char *exec, char **argv)
|
|||||||
signal_setup_restart(SIGPIPE, handle_signal);
|
signal_setup_restart(SIGPIPE, handle_signal);
|
||||||
signal_setup_restart(SIGALRM, handle_signal);
|
signal_setup_restart(SIGALRM, handle_signal);
|
||||||
signal_setup(SIGTERM, handle_signal);
|
signal_setup(SIGTERM, handle_signal);
|
||||||
signal_setup(SIGCHLD, reap_zombies);
|
|
||||||
signal_setup_restart(SIGUSR1, handle_signal);
|
signal_setup_restart(SIGUSR1, handle_signal);
|
||||||
signal_setup_restart(SIGUSR2, handle_signal);
|
signal_setup_restart(SIGUSR2, handle_signal);
|
||||||
signal_setup_restart(SIGBUS, handle_signal);
|
signal_setup_restart(SIGBUS, handle_signal);
|
||||||
@@ -516,60 +487,17 @@ static void supervisor(char *exec, char **argv)
|
|||||||
* Supervisor main loop
|
* Supervisor main loop
|
||||||
*/
|
*/
|
||||||
i = 0;
|
i = 0;
|
||||||
if (healthcheckdelay) {
|
|
||||||
signal_setup(SIGALRM, healthcheck);
|
|
||||||
alarm(healthcheckdelay);
|
|
||||||
} else if (healthchecktimer) {
|
|
||||||
signal_setup(SIGALRM, healthcheck);
|
|
||||||
alarm(healthchecktimer);
|
|
||||||
}
|
|
||||||
while (!exiting) {
|
while (!exiting) {
|
||||||
wait_pid = wait(&i);
|
wait(&i);
|
||||||
if (wait_pid == -1) {
|
if (exiting) {
|
||||||
if (do_healthcheck) {
|
signal_setup(SIGCHLD, SIG_IGN);
|
||||||
do_healthcheck = 0;
|
|
||||||
alarm(0);
|
|
||||||
syslog(LOG_DEBUG, "running health check for %s", svcname);
|
|
||||||
health_pid = exec_service(svcname, "healthcheck");
|
|
||||||
health_status = rc_waitpid(health_pid);
|
|
||||||
if (WIFEXITED(health_status) && !WEXITSTATUS(health_status)) {
|
|
||||||
alarm(healthchecktimer);
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
syslog(LOG_WARNING, "health check for %s failed", svcname);
|
|
||||||
health_pid = exec_service(svcname, "unhealthy");
|
|
||||||
rc_waitpid(health_pid);
|
|
||||||
syslog(LOG_INFO, "stopping %s, pid %d", exec, child_pid);
|
|
||||||
nkilled = run_stop_schedule(applet, NULL, NULL, child_pid, 0,
|
|
||||||
false, false, true);
|
|
||||||
if (nkilled > 0)
|
|
||||||
syslog(LOG_INFO, "killed %d processes", nkilled);
|
|
||||||
else if (errno != 0)
|
|
||||||
syslog(LOG_INFO, "Unable to kill %d: %s",
|
|
||||||
child_pid, strerror(errno));
|
|
||||||
}
|
|
||||||
} else if (exiting ) {
|
|
||||||
alarm(0);
|
|
||||||
syslog(LOG_INFO, "stopping %s, pid %d", exec, child_pid);
|
syslog(LOG_INFO, "stopping %s, pid %d", exec, child_pid);
|
||||||
nkilled = run_stop_schedule(applet, exec, NULL, child_pid, 0,
|
nkilled = run_stop_schedule(applet, exec, NULL, child_pid, 0,
|
||||||
false, false, true);
|
false, false, true);
|
||||||
if (nkilled > 0)
|
if (nkilled > 0)
|
||||||
syslog(LOG_INFO, "killed %d processes", nkilled);
|
syslog(LOG_INFO, "killed %d processes", nkilled);
|
||||||
continue;
|
} else {
|
||||||
}
|
sleep(respawn_delay);
|
||||||
} else if (wait_pid == child_pid) {
|
|
||||||
if (WIFEXITED(i))
|
|
||||||
syslog(LOG_WARNING, "%s, pid %d, exited with return code %d",
|
|
||||||
exec, child_pid, WEXITSTATUS(i));
|
|
||||||
else if (WIFSIGNALED(i))
|
|
||||||
syslog(LOG_WARNING, "%s, pid %d, terminated by signal %d",
|
|
||||||
exec, child_pid, WTERMSIG(i));
|
|
||||||
} else
|
|
||||||
continue;
|
|
||||||
|
|
||||||
ts.tv_sec = respawn_delay;
|
|
||||||
ts.tv_nsec = 0;
|
|
||||||
nanosleep(&ts, NULL);
|
|
||||||
if (respawn_max > 0 && respawn_period > 0) {
|
if (respawn_max > 0 && respawn_period > 0) {
|
||||||
respawn_now = time(NULL);
|
respawn_now = time(NULL);
|
||||||
if (first_spawn == 0)
|
if (first_spawn == 0)
|
||||||
@@ -586,18 +514,17 @@ static void supervisor(char *exec, char **argv)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
alarm(0);
|
if (WIFEXITED(i))
|
||||||
|
syslog(LOG_WARNING, "%s, pid %d, exited with return code %d",
|
||||||
|
exec, child_pid, WEXITSTATUS(i));
|
||||||
|
else if (WIFSIGNALED(i))
|
||||||
|
syslog(LOG_WARNING, "%s, pid %d, terminated by signal %d",
|
||||||
|
exec, child_pid, WTERMSIG(i));
|
||||||
child_pid = fork();
|
child_pid = fork();
|
||||||
if (child_pid == -1)
|
if (child_pid == -1)
|
||||||
eerrorx("%s: fork: %s", applet, strerror(errno));
|
eerrorx("%s: fork: %s", applet, strerror(errno));
|
||||||
if (child_pid == 0)
|
if (child_pid == 0)
|
||||||
child_process(exec, argv);
|
child_process(exec, argv);
|
||||||
if (healthcheckdelay) {
|
|
||||||
signal_setup(SIGALRM, healthcheck);
|
|
||||||
alarm(healthcheckdelay);
|
|
||||||
} else if (healthchecktimer) {
|
|
||||||
signal_setup(SIGALRM, healthcheck);
|
|
||||||
alarm(healthchecktimer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -682,16 +609,6 @@ int main(int argc, char **argv)
|
|||||||
while ((opt = getopt_long(argc, argv, getoptstring, longopts,
|
while ((opt = getopt_long(argc, argv, getoptstring, longopts,
|
||||||
(int *) 0)) != -1)
|
(int *) 0)) != -1)
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'a': /* --healthcheck-timer <time> */
|
|
||||||
if (sscanf(optarg, "%d", &healthchecktimer) != 1 || healthchecktimer < 1)
|
|
||||||
eerrorx("%s: invalid health check timer %s", applet, optarg);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'A': /* --healthcheck-delay <time> */
|
|
||||||
if (sscanf(optarg, "%d", &healthcheckdelay) != 1 || healthcheckdelay < 1)
|
|
||||||
eerrorx("%s: invalid health check delay %s", applet, optarg);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'D': /* --respawn-delay time */
|
case 'D': /* --respawn-delay time */
|
||||||
n = sscanf(optarg, "%d", &respawn_delay);
|
n = sscanf(optarg, "%d", &respawn_delay);
|
||||||
if (n != 1 || respawn_delay < 1)
|
if (n != 1 || respawn_delay < 1)
|
||||||
@@ -748,11 +665,6 @@ int main(int argc, char **argv)
|
|||||||
gid = gr->gr_gid;
|
gid = gr->gr_gid;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'H': /* --healthcheck-timer <minutes> */
|
|
||||||
if (sscanf(optarg, "%d", &healthchecktimer) != 1 || healthchecktimer < 1)
|
|
||||||
eerrorx("%s: invalid health check timer %s", applet, optarg);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'k':
|
case 'k':
|
||||||
if (parse_mode(&numask, optarg))
|
if (parse_mode(&numask, optarg))
|
||||||
eerrorx("%s: invalid mode `%s'",
|
eerrorx("%s: invalid mode `%s'",
|
||||||
|
|||||||
@@ -7,109 +7,44 @@ terminates unexpectedly.
|
|||||||
|
|
||||||
The following is a brief guide on using this capability.
|
The following is a brief guide on using this capability.
|
||||||
|
|
||||||
* Use Default start, stop and status functions
|
## Use Default start, stop and status functions
|
||||||
If you write your own start, stop and status functions in your service
|
|
||||||
script, none of this will work. You must allow OpenRC to use the default
|
|
||||||
functions.
|
|
||||||
|
|
||||||
* Daemons must not fork
|
If you write your own start, stop and status functions in your service
|
||||||
Any deamon that you would like to have monitored by supervise-daemon
|
script, none of this will work. You must allow OpenRC to use the default
|
||||||
must not fork. Instead, it must stay in the foreground. If the daemon
|
functions.
|
||||||
forks, the supervisor will be unable to monitor it.
|
|
||||||
|
|
||||||
If the daemon can be configured to not fork, this should be done in the
|
## Daemons must not fork
|
||||||
daemon's configuration file, or by adding a command line option that
|
|
||||||
instructs it not to fork to the command_args_foreground variable shown
|
|
||||||
below.
|
|
||||||
|
|
||||||
# Health Checks
|
Any deamon that you would like to have monitored by supervise-daemon
|
||||||
|
must not fork. Instead, it must stay in the foreground. If the daemon
|
||||||
|
itself forks, the supervisor will be unable to monitor it.
|
||||||
|
|
||||||
Health checks are a way to make sure a service monitored by
|
If the daemon can be configured to not fork, this should be done in the
|
||||||
supervise-daemon stays healthy. To configure a health check for a
|
daemon's configuration file, or by adding a command line option that
|
||||||
service, you need to write a healthcheck() function, and optionally an
|
instructs it not to fork to the command_args_foreground variable shown
|
||||||
unhealthy() function in the service script. Also, you will need to set
|
below.
|
||||||
the healthcheck_timer and optionally healthcheck_delay variables.
|
|
||||||
|
|
||||||
## healthcheck() function
|
## Variable Settings
|
||||||
|
|
||||||
The healthcheck() function is run repeatedly based on the settings of
|
|
||||||
the healthcheck_* variables. This function should return zero if the
|
|
||||||
service is currently healthy or non-zero otherwise.
|
|
||||||
|
|
||||||
## unhealthy() function
|
|
||||||
|
|
||||||
If the healthcheck() function returns non-zero, the unhealthy() function
|
|
||||||
is run, then the service is restarted. Since the service will be
|
|
||||||
restarted by the supervisor, the unhealthy function should not try to
|
|
||||||
restart it; the purpose of the function is to allow any cleanup tasks
|
|
||||||
other than restarting the service to be run.
|
|
||||||
|
|
||||||
# Variable Settings
|
|
||||||
|
|
||||||
The most important setting is the supervisor variable. At the top of
|
The most important setting is the supervisor variable. At the top of
|
||||||
your service script, you should set this variable as follows:
|
your service script, you should set this variable as follows:
|
||||||
|
|
||||||
``` sh
|
|
||||||
supervisor=supervise-daemon
|
supervisor=supervise-daemon
|
||||||
```
|
|
||||||
|
|
||||||
Several other variables affect the way services behave under
|
Several other variables affect the way services behave under
|
||||||
supervise-daemon. They are documented on the openrc-run man page, but I
|
supervise-daemon. They are documented on the openrc-run man page, but I
|
||||||
will list them here for convenience:
|
will list them here for convenience:
|
||||||
|
|
||||||
``` sh
|
|
||||||
pidfile=/pid/of/supervisor.pid
|
pidfile=/pid/of/supervisor.pid
|
||||||
```
|
|
||||||
|
|
||||||
If you are using start-stop-daemon to monitor your scripts, the pidfile
|
If you are using start-stop-daemon to monitor your scripts, the pidfile
|
||||||
is the path to the pidfile the daemon creates. If, on the other hand,
|
is the path to the pidfile the daemon creates. If, on the other hand,
|
||||||
you are using supervise-daemon, this is the path to the pidfile the
|
you are using supervise-daemon, this is the path to the pidfile the
|
||||||
supervisor creates.
|
supervisor creates.
|
||||||
|
|
||||||
``` sh
|
command_args_foreground should be used if the daemon you want to monitor
|
||||||
command_args_foreground="arguments"
|
|
||||||
```
|
|
||||||
|
|
||||||
This should be used if the daemon you want to monitor
|
|
||||||
forks and goes to the background by default. This should be set to the
|
forks and goes to the background by default. This should be set to the
|
||||||
command line option that instructs the daemon to stay in the foreground.
|
command line option that instructs the daemon to stay in the foreground.
|
||||||
|
|
||||||
``` sh
|
This is very early support, so feel free to file bugs if you have
|
||||||
healthcheck_delay=seconds
|
issues.
|
||||||
```
|
|
||||||
|
|
||||||
This is the delay, in seconds, before the first health check is run.
|
|
||||||
If it is not set, we use the value of healthcheck_timer.
|
|
||||||
|
|
||||||
``` sh
|
|
||||||
healthcheck_timer=seconds
|
|
||||||
```
|
|
||||||
|
|
||||||
This is the number of seconds between health checks. If it is not set,
|
|
||||||
no health checks will be run.
|
|
||||||
|
|
||||||
``` sh
|
|
||||||
respawn_delay
|
|
||||||
```
|
|
||||||
|
|
||||||
This is the number of seconds to delay before attempting to respawn a
|
|
||||||
supervised process after it dies unexpectedly.
|
|
||||||
The default is to respawn immediately.
|
|
||||||
|
|
||||||
``` sh
|
|
||||||
respawn_max=x
|
|
||||||
```
|
|
||||||
|
|
||||||
This is the maximum number of times to respawn a supervised process
|
|
||||||
during the given respawn period. The default is unlimited.
|
|
||||||
|
|
||||||
``` sh
|
|
||||||
respawn_period=seconds
|
|
||||||
```
|
|
||||||
|
|
||||||
This works in conjunction with respawn_max and respawn_delay above to
|
|
||||||
decide if a process should not be respawned for some reason.
|
|
||||||
|
|
||||||
For example, if respawn_period is 60, respawn_max is 2 and respawn_delay
|
|
||||||
is 3 and a process dies more than 4 times, the process will not be
|
|
||||||
respawned and the supervisor will terminate.
|
|
||||||
|
|||||||
Reference in New Issue
Block a user