mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 13:33:09 +07:00
Lots of cleanup and simplification of the main code in this commit. Most notably libev has been added to take care of the main loop and monitor services. Still TODO is migrating to use the libev signal handling. Convert initctl.c:listen_initctl() to a plugin instead. This also meant introducing a new form of I/O plugin to finit, also handled by libev. Load plugins *after* we've setup the base filesystem (BASEFS) in case plugins reside on a filesystem not reachable before "mount -a" has run. This also has the side effect of lining up nicely with the first level plugin hooks. If a plugin wants to hook up with a loded service we connect them by their respective numeric IDs in plugin_register(). I.e., the service monitor checks if a service has a registered callback, which in turn decides if a service should be started, stopped or reloaded. Rip out old EeePC distribution defines from finit.h, none of it really applies anymore. If you need distribution specific settings this is the place to put them. Make hookpoint names (#defines) clearer: after BASEFS, after networking, after all setup, etc. Use #inlude_next <signal.h> in signal.h to include system header file! Simplify service monitor: move essential code to svc.c and rip out the TIPC dependency. Write your own service.so plugin, or wait for a more complete example of how to extend service monitoring using the primitives in svc.c Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
67 lines
1.9 KiB
C
67 lines
1.9 KiB
C
/* Save and restore ALSA sound settings using alsactl
|
|
*
|
|
* Copyright (c) 2012 Joachim Nilsson <troglobit@gmail.com>
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
* THE SOFTWARE.
|
|
*/
|
|
|
|
#include "finit.h"
|
|
#include "helpers.h"
|
|
#include "plugin.h"
|
|
|
|
static void save(void *UNUSED(arg))
|
|
{
|
|
_d("Saving system clock to RTC ...");
|
|
run_interactive("/usr/sbin/alsactl store > /dev/null 2>&1", "Saving sound settings");
|
|
}
|
|
|
|
static void restore(void *UNUSED(arg))
|
|
{
|
|
_d("Restoring system clock from RTC ...");
|
|
run_interactive("/usr/sbin/alsactl restore > /dev/null 2>&1", "Restoring sound settings");
|
|
}
|
|
|
|
static plugin_t plugin = {
|
|
.hook[HOOK_BASEFS_UP] = {
|
|
.cb = restore
|
|
},
|
|
.hook[HOOK_SHUTDOWN] = {
|
|
.cb = save
|
|
}
|
|
};
|
|
|
|
PLUGIN_INIT(plugin_init)
|
|
{
|
|
plugin_register(&plugin);
|
|
}
|
|
|
|
PLUGIN_EXIT(plugin_exit)
|
|
{
|
|
plugin_unregister(&plugin);
|
|
}
|
|
|
|
|
|
/**
|
|
* Local Variables:
|
|
* version-control: t
|
|
* indent-tabs-mode: t
|
|
* c-file-style: "linux"
|
|
* End:
|
|
*/
|