Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
53f7afd3b3 | ||
|
|
75e9b66f6f | ||
|
|
d70b1c55b6 | ||
|
|
c1e582586d | ||
|
|
7a75bfb00c | ||
|
|
aacf841de4 | ||
|
|
3f918161aa | ||
|
|
710c874e6e | ||
|
|
07908be090 | ||
|
|
02af093043 | ||
|
|
67e2d6033d | ||
|
|
eca4357892 | ||
|
|
7ee3e5b2d6 | ||
|
|
7cb8d94323 | ||
|
|
84ed570eae | ||
|
|
2eea73bfd5 | ||
|
|
a571a42421 | ||
|
|
79648ac1c6 | ||
|
|
02af762e83 |
644
ChangeLog
644
ChangeLog
@@ -1,3 +1,173 @@
|
|||||||
|
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>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
supervise-daemon: fix respawn_max off by one
|
||||||
|
|
||||||
|
Fix the comparison between respawn_count and respawn_max so that
|
||||||
|
respawn_max = 1 will allow for one respawn. Since respawn_count is
|
||||||
|
incremented before the comparison, use a 'greater than' comparison
|
||||||
|
so that respawn will be triggered when respawn_count is equal to
|
||||||
|
respawn_max.
|
||||||
|
|
||||||
|
Fixes: https://github.com/OpenRC/openrc/issues/247
|
||||||
|
Fixes: https://github.com/OpenRC/openrc/issues/248
|
||||||
|
|
||||||
|
commit 07908be0903229a69b9e0f733ed13eeff0b55a44
|
||||||
|
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>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
Complete implementation of forever timeout value in stop schedules
|
||||||
|
|
||||||
|
commit eca4357892315ca7340bbfc2b373d7660a34142f
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
supervise-daemon: use nanosleep() instead of sleep()
|
||||||
|
|
||||||
|
We will be using sigalrm in this process for health checking, and
|
||||||
|
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>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
librc: fix EACCES errno false-positive crash
|
||||||
|
|
||||||
|
Use errno != EACCES to fix false-positive for non-root users
|
||||||
|
with grsecurity kernels.
|
||||||
|
|
||||||
|
Fixes: 37e29442721a ("librc: Add check for crashed state")
|
||||||
|
This fixes #237
|
||||||
|
|
||||||
|
commit 2eea73bfd5ce2f9993d52293fe7d25c0c804d592
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
rc-functions.sh: Remove addon support
|
||||||
|
|
||||||
|
This is an old relic from Gentoo baselayout-1.x which should not be used
|
||||||
|
any longer.
|
||||||
|
|
||||||
|
commit a571a42421b337380b6f5751635c55906bb8b508
|
||||||
|
Author: 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
|
||||||
|
|
||||||
|
Kmod doesn't support the -o switch, so if you have been using this your
|
||||||
|
module loads have been failing.
|
||||||
|
|
||||||
|
commit 79648ac1c6355975abca6acf6076e7022037523f
|
||||||
|
Author: Holger Hoffstätte <holger@applied-asynchrony.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
rc-status: initialize uptime pointer to prevent memory corruption
|
||||||
|
|
||||||
|
This fixes #231.
|
||||||
|
|
||||||
|
commit 02af762e83640ec23bf64c5b814f0d3424d90e10
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
version 0.39
|
||||||
|
|
||||||
|
commit 01c34c28e6d6d7bfecc0f88bdf1fb15e97ab8823
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
Update ChangeLog
|
||||||
|
|
||||||
commit 56ddda54b5aa01474bf563d5a662075c35152858
|
commit 56ddda54b5aa01474bf563d5a662075c35152858
|
||||||
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>
|
||||||
@@ -1265,477 +1435,3 @@ Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|||||||
program and adding --reexec support
|
program and adding --reexec support
|
||||||
- factor the supervisor into its own function
|
- factor the supervisor into its own function
|
||||||
- fix test for whether we are already running
|
- fix test for whether we are already running
|
||||||
|
|
||||||
commit 35b1996704f6635bb29ea3604410e133209e6432
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
supervise-daemon: elevate some log messages to warnings
|
|
||||||
|
|
||||||
Prior to this change, we were logging unexpected terminations of daemons
|
|
||||||
we were supervising at the info level. This change moves the logs to
|
|
||||||
warnings.
|
|
||||||
|
|
||||||
commit 3c8e7ed255edb8df0d548d6ce514544d5422cbf0
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
version 0.34
|
|
||||||
|
|
||||||
commit acaed1f910a2a00fdd5b6aeab752c552075a7292
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
Update ChangeLog
|
|
||||||
|
|
||||||
commit 91109e31d81ecd48f5690ad6f63103fca545dec7
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
update news
|
|
||||||
|
|
||||||
commit 2b6eeea01d1c64d58929788f4bfa0758393885bf
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
man: remove service(8) man page
|
|
||||||
|
|
||||||
commit a15de23e5713d840d871c526b46050983dc6ea1e
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
typo fix
|
|
||||||
|
|
||||||
commit efa9ba485d9328f780f3e60dc18339c75974c6c6
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
init.d/sysfs.in: fix reference to RC_LIBEXECDIR
|
|
||||||
|
|
||||||
The sysfs init script referred to @LIBEXECDIR@ before this change, but
|
|
||||||
it is better to refer to RC_LIBEXECDIR so that we get rid of a sed
|
|
||||||
substitution.
|
|
||||||
|
|
||||||
commit d4ddd72701ff5533a1ba07b1da60806859c63d88
|
|
||||||
Author: Chris Cromer <chris@cromer.cl>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
add option to make agetty startup quiet
|
|
||||||
|
|
||||||
This fixes #150
|
|
||||||
|
|
||||||
commit 1e9af2cd421423404ffe1491bd35af76c2885f1f
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
fix compiler warning
|
|
||||||
|
|
||||||
commit 3c05db74f6e733890e9035c183a774db3d512512
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
remove service binary
|
|
||||||
|
|
||||||
The service binary was just a synonym for rc-service, so use rc-service
|
|
||||||
instead of service. If you want a "service" binary, it should be
|
|
||||||
something that can determine which service manager you are running and
|
|
||||||
run the appropriate service manager commands.
|
|
||||||
|
|
||||||
commit edc54b03770d5f58d1a4969d06c28660003dfb04
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
version 0.33
|
|
||||||
|
|
||||||
commit 8e53a3fa8a33fb714064ddbe38bff2213fcf6837
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
Update ChangeLog
|
|
||||||
|
|
||||||
commit 7f3b41311119e3a96a15b0fb473b44f422e903e9
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
use printf consistently in cgroups handling
|
|
||||||
|
|
||||||
This makes the cgroups handling consistent between cgroups v1 and v2.
|
|
||||||
Also, it fixes #167.
|
|
||||||
|
|
||||||
commit 1ccba056584ee1a8e09fb1d5eebd988b47912c06
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
sh/rc-functions.sh: add need_if_exists convenience function
|
|
||||||
|
|
||||||
commit c46adf14343df3a74aef7e4ae5be175ae5fa7a01
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
man/openrc-run.8: Clarify the explanation of the need dependency
|
|
||||||
|
|
||||||
commit 1cac8b080c16f9aab19c7a3ae1ca155c20dfa14d
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
ignore sigchld when shutting down the supervised process
|
|
||||||
|
|
||||||
We need to do this to skip the zombie state for the child process since
|
|
||||||
we are not easily able to wait() for it.
|
|
||||||
|
|
||||||
commit b58194ef63ec8c0a7e0ea3c291da9c19aa83cb1a
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
typo fix
|
|
||||||
|
|
||||||
commit b28c0d6f66e42b1e6d2a39c286a18c8d92881790
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
typo fix
|
|
||||||
|
|
||||||
commit 3cf19b0f30a90157d23d09ded304439f1eb42d4a
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
supervise-daemon: code cleanup
|
|
||||||
|
|
||||||
Clean up the process for killing an active supervisor when stopping.
|
|
||||||
|
|
||||||
commit 0eb47b9af340dd07209a3920944ed085fe7bd359
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
initialize the stop schedule
|
|
||||||
|
|
||||||
commit 4ab60ff10935122277bbaed437f82a765279cd19
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
rc-schedules.c: pass the correct pid to rc_find_pids
|
|
||||||
|
|
||||||
This is for #163.
|
|
||||||
|
|
||||||
commit db4a578273dbfa15b8b96686391bcc9ecc04b646
|
|
||||||
Author: Jason Zaman <jason@perfinion.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
selinux: fix const qualifier warning
|
|
||||||
|
|
||||||
rc-selinux.c: In function ‘selinux_setup’:
|
|
||||||
rc-selinux.c:361:9: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
|
|
||||||
curr_t = context_type_get(curr_con);
|
|
||||||
^
|
|
||||||
|
|
||||||
commit b1c3422f453921e838d419640fe39144dbf8d13d
|
|
||||||
Author: Jason Zaman <jason@perfinion.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
selinux: use openrc contexts path to get contexts
|
|
||||||
|
|
||||||
The minimum requirement for libselinux is now >=2.6
|
|
||||||
The refpolicy and the gentoo policy contain the
|
|
||||||
contexts since version 2.20170204-r4
|
|
||||||
|
|
||||||
commit 3fafd7a76e6adf15ec72a7ba5f44583eff8fab7a
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
sysfs: fix cgroup hybrid mode
|
|
||||||
|
|
||||||
In hybrid mode, we should not try to mount cgroup2 if it is not
|
|
||||||
available in the kernel.
|
|
||||||
|
|
||||||
This fixes #164.
|
|
||||||
|
|
||||||
commit cd5722aca50f0eaddde7ce04ee00da53c313ba7d
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
cgroup2_find_path: use legacy mode if cgroup2 is not in the kernel
|
|
||||||
|
|
||||||
This is related to #164.
|
|
||||||
|
|
||||||
commit dcb4a4d2613a1fdf85651b32e5b7a87528f487bc
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
version 0.32
|
|
||||||
|
|
||||||
commit e312e569970c74cf52e255da67034391b68dafac
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
Update ChangeLog
|
|
||||||
|
|
||||||
commit 2f60a959b442866b0e879d83f2732c4fa3ed3f7d
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
update news file
|
|
||||||
|
|
||||||
commit 25b45a5a239318fb57c405c3fe64e53b0738ad68
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
cgroup_cleanup: try to remove the cgroup version 2 cgroup
|
|
||||||
|
|
||||||
If we were able to kill all the processes in the cgroup, it should be
|
|
||||||
removed.
|
|
||||||
|
|
||||||
commit 4651b8c7e9e2ef9c1ea1fb8d174d1ca4693627af
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
rc-cgroup.sh: cgroup_cleanup fix error handling
|
|
||||||
|
|
||||||
cgroup_cleanup should warn if it is unable to clean up all processes in
|
|
||||||
the control group, but it will always return success.
|
|
||||||
|
|
||||||
commit 50608b54ed98acb54fec5fe3323909ea684d3af9
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
rc-cgroup.sh: fix signal names
|
|
||||||
|
|
||||||
The "SIG" prefix on signal names passed to kill -s isn't portable.
|
|
||||||
|
|
||||||
commit b0a077a35f85e266fdb82a245dcbda18664a8567
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
add quiet switch to do_stop in src-schedules.c
|
|
||||||
|
|
||||||
This allows supervise-daemon to run this code without attempting to
|
|
||||||
print some status messages used by start-stop-daemon.
|
|
||||||
|
|
||||||
commit 6a5ca2ab368d0a85f51bb559672dba2e3ffcc6be
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
make the procedure for killing child processes of services configurable
|
|
||||||
|
|
||||||
commit 2b0345165e5af57ca61a4000c3671bbe6d677cf9
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
Make cgroup_cleanup send only one sigterm and sigkill
|
|
||||||
|
|
||||||
Instead of looping and sending multiple signals to child processes in
|
|
||||||
cgroup_cleanup, we send sigterm followed by sleeping one second then
|
|
||||||
sigkill.
|
|
||||||
|
|
||||||
This brings us more in line with systemd's "control group" killmode
|
|
||||||
setting.
|
|
||||||
|
|
||||||
Also, this commit includes several shellcheck cleanups.
|
|
||||||
|
|
||||||
commit 8885580986ab8adc951fe32b9323c8b16130fb4f
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
rc-cgroup.sh: move cgroup_cleanup to the end of the file
|
|
||||||
|
|
||||||
commit 6d7713a758b7e78f05e6a3cc101f862d28d778ab
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
guide.md: clarify cgroups documentation
|
|
||||||
|
|
||||||
Update the documentation to reflect cgroups version 2 support.
|
|
||||||
Also, add a section on dealing with orphaned service processes.
|
|
||||||
|
|
||||||
This fixes #94.
|
|
||||||
|
|
||||||
commit 457f928e793cb1f6ef254935ad07f58b8762c72f
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
add support for control groups version 2
|
|
||||||
|
|
||||||
This is for #94.
|
|
||||||
|
|
||||||
commit a71a461e452a98554346c47411e9c9012023c201
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
version 0.31
|
|
||||||
|
|
||||||
commit a09b8af3f98c0700a9b838b7f3683ee58eecc912
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
Update ChangeLog
|
|
||||||
|
|
||||||
commit 382efdbfcb99703d03211efacd800c9575e64230
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
add quiet parameter to run_stop_schedule
|
|
||||||
|
|
||||||
commit 17b5cc78d35dc5fe4904e5951715c3e0d07d6343
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
add retry option to supervise-daemon
|
|
||||||
|
|
||||||
The --retry option for supervise-daemon defines how the supervisor will
|
|
||||||
attempt to stop the child process it is monitoring. It is defined when
|
|
||||||
the supervisor is started since stopping the supervisor just sends a
|
|
||||||
signal to the active supervisor.
|
|
||||||
|
|
||||||
This fixes #160.
|
|
||||||
|
|
||||||
commit 36a0ab9054512ade413226fb8e8b28060045e9a4
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
make run_stop_schedule accept a pid instead of a pid file
|
|
||||||
|
|
||||||
commit 27c2bd997d5173aa30844a16bc22dc8caab09f8c
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
version 0.30
|
|
||||||
|
|
||||||
commit d7938f54f29193251e083ad35a7d464949829096
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
start-stop-daemon: move --retry processing code to a shared module
|
|
||||||
|
|
||||||
This was part of start-stop-daemon; however, it needs to be shared in
|
|
||||||
order to be used by supervise-daemon.
|
|
||||||
|
|
||||||
commit cfbe9c2ede24dac530ef58e5c35bd57f22a788a3
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
move get_pid function to a shared file
|
|
||||||
|
|
||||||
commit df28002b728b033c00c2da64dedf2bcd4ab5e11b
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
Update ChangeLog
|
|
||||||
|
|
||||||
commit 66ed8082d0c865a0b4f4cc436cf9e13351e3d6fe
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
sh/openrc-run: source service script before ulimit is processed
|
|
||||||
|
|
||||||
This is needed to allow the service script author to set a default for
|
|
||||||
rc_ulimit inside the service script.
|
|
||||||
|
|
||||||
commit c2d256bafb9d1dfafbfd0846c035c5d26f7449c8
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
man/openrc-run.8: document fstabinfo and mountinfo
|
|
||||||
|
|
||||||
X-Gentoo-Bug: 592374
|
|
||||||
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=592374
|
|
||||||
|
|
||||||
commit f48d9c33a5c708c871d6657a39485d1c0c735548
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
man/openrc-run.8: document _pre and _post functions
|
|
||||||
|
|
||||||
Fixes https://github.com/openrc/openrc/issues/155.
|
|
||||||
|
|
||||||
commit 6d4e8433974fd8567885635ae0454031290f96b1
|
|
||||||
Author: Jason Graham <jgraha8@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
fix ENT macro usage
|
|
||||||
|
|
||||||
X-Gentoo-Bug: 624796
|
|
||||||
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=624796
|
|
||||||
|
|
||||||
commit 0513cd3964a9564e0ba39b50aa8ebd3d7e9a3920
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
version 0.29
|
|
||||||
|
|
||||||
commit 72bb2e57de935ab46ad000f97a5720265bed9342
|
|
||||||
Author: John R. Graham <john_r_graham@gentoo.org>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
Typo fix
|
|
||||||
|
|
||||||
X-Gentoo-Bug: 624908
|
|
||||||
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=624908
|
|
||||||
|
|
||||||
commit 84c5da30695db89d686d3c28c7cacdf172cbf429
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
Update ChangeLog
|
|
||||||
|
|
||||||
commit b35099cb707e333b6b8d30d956ffa93bcd2da0ab
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
Add comment about overriding the default efivars mount in fstab to news
|
|
||||||
|
|
||||||
commit 3fd3bfc76dccc3752f4af949ad4076dab26357fb
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
add link to efivars issue to news file
|
|
||||||
|
|
||||||
commit 492a6303cb8314263bfd3631e3b0de5a9df178da
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
Update ChangeLog
|
|
||||||
|
|
||||||
commit e7807b3136d8993805082320784460f5059e6275
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
fix sysvinit compatibility for shutdown wrapper
|
|
||||||
|
|
||||||
commit 03a461ac0ee34b7900868cdea624c6fd868b1656
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
fix sysvinit compatibility for reboot wrapper
|
|
||||||
|
|
||||||
commit 7e0f76e0adc545c74a8332a6ef0811d2aa62cb81
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
fix sysvinit compatibility for poweroff wrapper
|
|
||||||
|
|
||||||
commit 9812ce5b8dc22fe36cc7bf75cf6e62db204ece3d
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
fix halt wrapper so it is sysvinit compatible
|
|
||||||
|
|
||||||
This makes the halt wrapper sysvinit compatible. It ignores several
|
|
||||||
command line switches which are not currently implemented; however,
|
|
||||||
those can be implemented if we need to do so.
|
|
||||||
|
|
||||||
This fixes https://github.com/openrc/openrc/issues/146.
|
|
||||||
|
|
||||||
commit 12f75e4167f84a9a85f69924ebdb28ad36c085cb
|
|
||||||
Author: Adam Borowski <kilobyte@angband.pl>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
man: fix an unclosed .Bl/.El warning
|
|
||||||
|
|
||||||
This fixes #151.
|
|
||||||
|
|
||||||
commit 260368e0103e95625c29760f2c2ec89143e5a233
|
|
||||||
Author: Adam Borowski <kilobyte@angband.pl>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
man: fix missing .Pp warnings
|
|
||||||
|
|
||||||
This fixes #151.
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
NAME= openrc
|
NAME= openrc
|
||||||
VERSION= 0.38
|
VERSION= 0.39
|
||||||
PKG= ${NAME}-${VERSION}
|
PKG= ${NAME}-${VERSION}
|
||||||
|
|||||||
28
NEWS.md
28
NEWS.md
@@ -4,6 +4,34 @@ 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,11 +8,6 @@
|
|||||||
#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,11 +56,12 @@ 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 --use-blacklist -q "$x"; rc=$? ;;
|
Linux) modprobe --first-time -q --use-blacklist "$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()
|
||||||
@@ -103,7 +104,7 @@ Linux_modules()
|
|||||||
x=${x%.*}
|
x=${x%.*}
|
||||||
done
|
done
|
||||||
|
|
||||||
local list= x= xx= y= args= mpargs= a=
|
local list= x= xx= y= args=
|
||||||
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
|
||||||
@@ -112,24 +113,13 @@ 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 --use-blacklist --verbose "$mpargs" "$x" "$args"
|
eval modprobe --first-time --use-blacklist --verbose "$x" "$args"
|
||||||
done
|
done
|
||||||
[ -n "$list" ] && eend
|
[ -n "$list" ] && eend
|
||||||
}
|
}
|
||||||
@@ -137,7 +127,7 @@ Linux_modules()
|
|||||||
start()
|
start()
|
||||||
{
|
{
|
||||||
case "$RC_UNAME" in
|
case "$RC_UNAME" in
|
||||||
FreeBSD|Linux)
|
FreeBSD|Linux)
|
||||||
modules_load_d
|
modules_load_d
|
||||||
${RC_UNAME}_modules
|
${RC_UNAME}_modules
|
||||||
;;
|
;;
|
||||||
|
|||||||
@@ -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 ro \
|
mount -n -t efivarfs -o ${sysfs_opts} \
|
||||||
efivarfs /sys/firmware/efi/efivars 2> /dev/null
|
efivarfs /sys/firmware/efi/efivars 2> /dev/null
|
||||||
eend 0
|
eend 0
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
.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
|
||||||
@@ -32,6 +33,8 @@ 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,6 +16,10 @@
|
|||||||
.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
|
||||||
@@ -90,6 +94,11 @@ 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,6 +1,5 @@
|
|||||||
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 rc-functions.sh.in ${SRCS-${OS}}
|
openrc-run.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}}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ cgroup_set_values()
|
|||||||
while [ -n "$1" ] && [ "$controller" != "cpuacct" ]; do
|
while [ -n "$1" ] && [ "$controller" != "cpuacct" ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
$controller.*)
|
$controller.*)
|
||||||
if [ -n "${name}" ] && [ -w "${cgroup}/${name}" ] &&
|
if [ -n "${name}" ] && [ -w "${cgroup}/${name}" ] &&
|
||||||
[ -n "${val}" ]; then
|
[ -n "${val}" ]; then
|
||||||
veinfo "$RC_SVCNAME: Setting $cgroup/$name to $val"
|
veinfo "$RC_SVCNAME: Setting $cgroup/$name to $val"
|
||||||
printf "%s" "$val" > "$cgroup/$name"
|
printf "%s" "$val" > "$cgroup/$name"
|
||||||
|
|||||||
@@ -2,42 +2,6 @@
|
|||||||
# 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()
|
||||||
2
sh/s6.sh
2
sh/s6.sh
@@ -57,7 +57,7 @@ s6_stop()
|
|||||||
ebegin "Stopping ${name:-$RC_SVCNAME}"
|
ebegin "Stopping ${name:-$RC_SVCNAME}"
|
||||||
s6-svc -d -wD -T ${s6_service_timeout_stop:-60000} "${s6_service_link}"
|
s6-svc -d -wD -T ${s6_service_timeout_stop:-60000} "${s6_service_link}"
|
||||||
set -- $(s6-svstat "${s6_service_link}")
|
set -- $(s6-svstat "${s6_service_link}")
|
||||||
[ "$1" = "up" ] &&
|
[ "$1" = "up" ] &&
|
||||||
yesno "${s6_force_kill:-yes}" &&
|
yesno "${s6_force_kill:-yes}" &&
|
||||||
_s6_force_kill "$@"
|
_s6_force_kill "$@"
|
||||||
set -- $(s6-svstat "${s6_service_link}")
|
set -- $(s6-svstat "${s6_service_link}")
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ ssd_start()
|
|||||||
service_inactive && _inactive=true
|
service_inactive && _inactive=true
|
||||||
mark_service_inactive
|
mark_service_inactive
|
||||||
fi
|
fi
|
||||||
[ -n "$output_logger" ] &&
|
[ -n "$output_logger" ] &&
|
||||||
output_logger_arg="--stdout-logger \"$output_logger\""
|
output_logger_arg="--stdout-logger \"$output_logger\""
|
||||||
[ -n "$error_logger" ] &&
|
[ -n "$error_logger" ] &&
|
||||||
error_logger_arg="--stderr-logger \"$error_logger\""
|
error_logger_arg="--stderr-logger \"$error_logger\""
|
||||||
#the eval call is necessary for cases like:
|
#the eval call is necessary for cases like:
|
||||||
# command_args="this \"is a\" test"
|
# command_args="this \"is a\" test"
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
# 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
|
||||||
@@ -32,6 +34,8 @@ 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}} \
|
||||||
@@ -98,3 +102,13 @@ supervise_status()
|
|||||||
return 3
|
return 3
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
healthcheck()
|
||||||
|
{
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
unhealthy()
|
||||||
|
{
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|||||||
@@ -850,7 +850,7 @@ rc_service_state(const char *service)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (state & RC_SERVICE_STARTED) {
|
if (state & RC_SERVICE_STARTED) {
|
||||||
if (rc_service_daemons_crashed(service))
|
if (rc_service_daemons_crashed(service) && errno != EACCES)
|
||||||
state |= RC_SERVICE_CRASHED;
|
state |= RC_SERVICE_CRASHED;
|
||||||
}
|
}
|
||||||
if (state & RC_SERVICE_STOPPED) {
|
if (state & RC_SERVICE_STOPPED) {
|
||||||
|
|||||||
@@ -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 rc-wtmp.c
|
SRCS+= kill_all.c openrc-init.c openrc-shutdown.c broadcast.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 _usage.o rc-wtmp.o
|
openrc-shutdown: openrc-shutdown.o rc-misc.o _usage.o broadcast.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-schedules.o
|
supervise-daemon: supervise-daemon.o _usage.o rc-misc.o rc-plugin.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
|
||||||
|
|||||||
209
src/rc/broadcast.c
Normal file
209
src/rc/broadcast.c
Normal file
@@ -0,0 +1,209 @@
|
|||||||
|
/*
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
16
src/rc/broadcast.h
Normal file
16
src/rc/broadcast.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
@@ -248,7 +248,7 @@ int main(int argc, char **argv)
|
|||||||
usage(EXIT_FAILURE);
|
usage(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
openlog(applet, LOG_CONS|LOG_PID, LOG_DAEMON);
|
openlog(applet, LOG_CONS|LOG_PID, LOG_DAEMON);
|
||||||
if (mount_proc() != 0) {
|
if (mount_proc() != 0) {
|
||||||
rc_stringlist_free(omits);
|
rc_stringlist_free(omits);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#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>
|
||||||
@@ -44,7 +45,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;
|
||||||
@@ -96,12 +97,15 @@ 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);
|
||||||
sleep(3);
|
ts.tv_sec = 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();
|
||||||
@@ -135,7 +139,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,20 +25,24 @@
|
|||||||
#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 = "dDHKpRrsw" getoptstring_COMMON;
|
const char *getoptstring = "cdDfFHKpRrsw" 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'},
|
||||||
@@ -51,6 +55,7 @@ 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",
|
||||||
@@ -64,8 +69,12 @@ 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 "
|
||||||
"--halt, --kexec, --poweroff, --reexec, --reboot, --single or --write-only";
|
"--cancel, --halt, --kexec, --poweroff, --reexec, --reboot, --single or \n"
|
||||||
|
"--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;
|
||||||
@@ -76,6 +85,40 @@ 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;
|
||||||
@@ -99,16 +142,59 @@ 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;
|
||||||
@@ -117,14 +203,17 @@ 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':
|
||||||
@@ -133,10 +222,12 @@ 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':
|
||||||
@@ -146,12 +237,88 @@ int main(int argc, char **argv)
|
|||||||
case_RC_COMMON_GETOPT
|
case_RC_COMMON_GETOPT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (geteuid() != 0 && ! do_dryrun)
|
if (geteuid() != 0)
|
||||||
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
@@ -160,11 +327,9 @@ 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");
|
||||||
|
else if (do_wtmp_only)
|
||||||
|
log_wtmp("shutdown", "~~", 0, RUN_LVL, "~~");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -351,8 +351,9 @@ int run_stop_schedule(const char *applet,
|
|||||||
|
|
||||||
tkilled += nkilled;
|
tkilled += nkilled;
|
||||||
break;
|
break;
|
||||||
|
case SC_FOREVER:
|
||||||
case SC_TIMEOUT:
|
case SC_TIMEOUT:
|
||||||
if (item->value < 1) {
|
if (item->type == SC_TIMEOUT && item->value < 1) {
|
||||||
item = NULL;
|
item = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -360,7 +361,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; nsecs < item->value; nsecs++) {
|
for (nsecs = 0; item->type == SC_FOREVER || nsecs < item->value; nsecs++) {
|
||||||
for (nloops = 0;
|
for (nloops = 0;
|
||||||
nloops < ONE_SECOND / POLL_INTERVAL;
|
nloops < ONE_SECOND / POLL_INTERVAL;
|
||||||
nloops++)
|
nloops++)
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ static char *get_uptime(const char *service)
|
|||||||
time_t diff_hours = (time_t) 0;
|
time_t diff_hours = (time_t) 0;
|
||||||
time_t diff_mins = (time_t) 0;
|
time_t diff_mins = (time_t) 0;
|
||||||
time_t diff_secs = (time_t) 0;
|
time_t diff_secs = (time_t) 0;
|
||||||
char *uptime;
|
char *uptime = NULL;
|
||||||
|
|
||||||
if (state & RC_SERVICE_STARTED) {
|
if (state & RC_SERVICE_STARTED) {
|
||||||
start_count = rc_service_value_get(service, "start_count");
|
start_count = rc_service_value_get(service, "start_count");
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ void log_wtmp(const char *user, const char *id, pid_t pid, int type,
|
|||||||
strncpy(utmp.ut_name, user, sizeof(utmp.ut_name));
|
strncpy(utmp.ut_name, user, sizeof(utmp.ut_name));
|
||||||
strncpy(utmp.ut_id , id , sizeof(utmp.ut_id ));
|
strncpy(utmp.ut_id , id , sizeof(utmp.ut_id ));
|
||||||
strncpy(utmp.ut_line, line, sizeof(utmp.ut_line));
|
strncpy(utmp.ut_line, line, sizeof(utmp.ut_line));
|
||||||
|
|
||||||
/* Put the OS version in place of the hostname */
|
/* Put the OS version in place of the hostname */
|
||||||
if (uname(&uname_buf) == 0)
|
if (uname(&uname_buf) == 0)
|
||||||
strncpy(utmp.ut_host, uname_buf.release, sizeof(utmp.ut_host));
|
strncpy(utmp.ut_host, uname_buf.release, sizeof(utmp.ut_host));
|
||||||
|
|||||||
@@ -61,15 +61,18 @@ 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 = "D:d:e:g:I:Kk:m:N:p:R:r:Su:1:2:3" \
|
const char *getoptstring = "A:a:D:d:e:g:H: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'},
|
||||||
@@ -91,6 +94,8 @@ 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",
|
||||||
@@ -113,6 +118,9 @@ 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;
|
||||||
@@ -183,6 +191,12 @@ static void handle_signal(int sig)
|
|||||||
re_exec_supervisor();
|
re_exec_supervisor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void healthcheck(int sig)
|
||||||
|
{
|
||||||
|
if (sig == SIGALRM)
|
||||||
|
do_healthcheck = 1;
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
@@ -423,10 +437,14 @@ 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);
|
||||||
@@ -487,44 +505,88 @@ 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(&i);
|
wait_pid = wait(&i);
|
||||||
if (exiting) {
|
if (wait_pid == -1) {
|
||||||
signal_setup(SIGCHLD, SIG_IGN);
|
if (do_healthcheck) {
|
||||||
syslog(LOG_INFO, "stopping %s, pid %d", exec, child_pid);
|
do_healthcheck = 0;
|
||||||
nkilled = run_stop_schedule(applet, exec, NULL, child_pid, 0,
|
alarm(0);
|
||||||
false, false, true);
|
syslog(LOG_DEBUG, "running health check for %s", svcname);
|
||||||
if (nkilled > 0)
|
health_pid = exec_service(svcname, "healthcheck");
|
||||||
syslog(LOG_INFO, "killed %d processes", nkilled);
|
health_status = rc_waitpid(health_pid);
|
||||||
} else {
|
if (WIFEXITED(health_status) && !WEXITSTATUS(health_status)) {
|
||||||
sleep(respawn_delay);
|
alarm(healthchecktimer);
|
||||||
if (respawn_max > 0 && respawn_period > 0) {
|
|
||||||
respawn_now = time(NULL);
|
|
||||||
if (first_spawn == 0)
|
|
||||||
first_spawn = respawn_now;
|
|
||||||
if (respawn_now - first_spawn > respawn_period) {
|
|
||||||
respawn_count = 0;
|
|
||||||
first_spawn = 0;
|
|
||||||
} else
|
|
||||||
respawn_count++;
|
|
||||||
if (respawn_count >= respawn_max) {
|
|
||||||
syslog(LOG_WARNING,
|
|
||||||
"respawned \"%s\" too many times, exiting", exec);
|
|
||||||
exiting = true;
|
|
||||||
continue;
|
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);
|
||||||
|
nkilled = run_stop_schedule(applet, exec, NULL, child_pid, 0,
|
||||||
|
false, false, true);
|
||||||
|
if (nkilled > 0)
|
||||||
|
syslog(LOG_INFO, "killed %d processes", nkilled);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
} else if (wait_pid == child_pid) {
|
||||||
if (WIFEXITED(i))
|
if (WIFEXITED(i))
|
||||||
syslog(LOG_WARNING, "%s, pid %d, exited with return code %d",
|
syslog(LOG_WARNING, "%s, pid %d, exited with return code %d",
|
||||||
exec, child_pid, WEXITSTATUS(i));
|
exec, child_pid, WEXITSTATUS(i));
|
||||||
else if (WIFSIGNALED(i))
|
else if (WIFSIGNALED(i))
|
||||||
syslog(LOG_WARNING, "%s, pid %d, terminated by signal %d",
|
syslog(LOG_WARNING, "%s, pid %d, terminated by signal %d",
|
||||||
exec, child_pid, WTERMSIG(i));
|
exec, child_pid, WTERMSIG(i));
|
||||||
child_pid = fork();
|
} else
|
||||||
if (child_pid == -1)
|
continue;
|
||||||
eerrorx("%s: fork: %s", applet, strerror(errno));
|
|
||||||
if (child_pid == 0)
|
ts.tv_sec = respawn_delay;
|
||||||
child_process(exec, argv);
|
ts.tv_nsec = 0;
|
||||||
|
nanosleep(&ts, NULL);
|
||||||
|
if (respawn_max > 0 && respawn_period > 0) {
|
||||||
|
respawn_now = time(NULL);
|
||||||
|
if (first_spawn == 0)
|
||||||
|
first_spawn = respawn_now;
|
||||||
|
if (respawn_now - first_spawn > respawn_period) {
|
||||||
|
respawn_count = 0;
|
||||||
|
first_spawn = 0;
|
||||||
|
} else
|
||||||
|
respawn_count++;
|
||||||
|
if (respawn_count > respawn_max) {
|
||||||
|
syslog(LOG_WARNING,
|
||||||
|
"respawned \"%s\" too many times, exiting", exec);
|
||||||
|
exiting = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
alarm(0);
|
||||||
|
child_pid = fork();
|
||||||
|
if (child_pid == -1)
|
||||||
|
eerrorx("%s: fork: %s", applet, strerror(errno));
|
||||||
|
if (child_pid == 0)
|
||||||
|
child_process(exec, argv);
|
||||||
|
if (healthcheckdelay) {
|
||||||
|
signal_setup(SIGALRM, healthcheck);
|
||||||
|
alarm(healthcheckdelay);
|
||||||
|
} else if (healthchecktimer) {
|
||||||
|
signal_setup(SIGALRM, healthcheck);
|
||||||
|
alarm(healthchecktimer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -609,6 +671,16 @@ 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)
|
||||||
@@ -665,6 +737,11 @@ 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'",
|
||||||
@@ -832,7 +909,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (respawn_delay * respawn_max > respawn_period)
|
if (respawn_delay * respawn_max > respawn_period)
|
||||||
ewarn("%s: Please increase the value of --respawn-period to more "
|
ewarn("%s: Please increase the value of --respawn-period to more "
|
||||||
"than %d to avoid infinite respawning", applet,
|
"than %d to avoid infinite respawning", applet,
|
||||||
respawn_delay * respawn_max);
|
respawn_delay * respawn_max);
|
||||||
|
|
||||||
if (retry) {
|
if (retry) {
|
||||||
|
|||||||
@@ -7,44 +7,109 @@ 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.
|
||||||
|
|
||||||
If you write your own start, stop and status functions in your service
|
* Daemons must not fork
|
||||||
script, none of this will work. You must allow OpenRC to use the default
|
Any deamon that you would like to have monitored by supervise-daemon
|
||||||
functions.
|
must not fork. Instead, it must stay in the foreground. If the daemon
|
||||||
|
forks, the supervisor will be unable to monitor it.
|
||||||
|
|
||||||
## Daemons must not fork
|
If the daemon can be configured to not fork, this should be done in the
|
||||||
|
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.
|
||||||
|
|
||||||
Any deamon that you would like to have monitored by supervise-daemon
|
# Health Checks
|
||||||
must not fork. Instead, it must stay in the foreground. If the daemon
|
|
||||||
itself forks, the supervisor will be unable to monitor it.
|
|
||||||
|
|
||||||
If the daemon can be configured to not fork, this should be done in the
|
Health checks are a way to make sure a service monitored by
|
||||||
daemon's configuration file, or by adding a command line option that
|
supervise-daemon stays healthy. To configure a health check for a
|
||||||
instructs it not to fork to the command_args_foreground variable shown
|
service, you need to write a healthcheck() function, and optionally an
|
||||||
below.
|
unhealthy() function in the service script. Also, you will need to set
|
||||||
|
the healthcheck_timer and optionally healthcheck_delay variables.
|
||||||
|
|
||||||
## Variable Settings
|
## healthcheck() function
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
command_args_foreground should be used if the daemon you want to monitor
|
``` sh
|
||||||
|
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.
|
||||||
|
|
||||||
This is very early support, so feel free to file bugs if you have
|
``` sh
|
||||||
issues.
|
healthcheck_delay=seconds
|
||||||
|
```
|
||||||
|
|
||||||
|
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