summaryrefslogtreecommitdiff
path: root/functions
AgeCommit message (Collapse)Author
2011-05-21Improve coloring on light and transparent termSebastien Luttringer
This patch improve coloring in light and transparent term. It uses tput if available or default color code. It remplace \033 by \e. It's a kind of rollback from commit 65f410, because initscripts are now in bash, and argument "\e isn't recongized in all shells" is not an issue anymore. This is not done in locale.sh script which can be sourced by others shell, so we try to be the more compliant as possible Signed-off-by: Sebastien Luttringer <seblu@seblu.net>
2011-05-19add killall5 omit pid functionalityGerardo Exequiel Pozzi
(me) Update the offsets so can be merged now without any issues and respect the indentation. Implements FS#10536 - [initscripts] internal: save a pid from killall5 All credits to: Kurt J. Bosch Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar> Signed-off-by: Tom Gundersen <teg@jklm.no>
2011-04-16Add an rc helperSebastien Luttringer
This is allow a quick calling to /etc/rc.d scripts by calling a shell command. By example, starting sshd and gpm can be done by typing: rc start sshd gpm rc can also list available scripts and show which is started/stopped in DAEMONS [tomegun: fixed detection of autostart of background services] Signed-off-by: Sebastien Luttringer <seblu@seblu.net> Signed-off-by: Tom Gundersen <teg@jklm.no>
2011-04-15Fix incomplete daemon detection in have_daemonSebastien Luttringer
A daemon is an executable _file_ in /etc/rc.d. Directory like functions.d is not a daemon. Signed-off-by: Sebastien Luttringer <seblu@seblu.net>
2011-04-13Move /var/run/daemons to /run/daemonsSebastien Luttringer
Signed-off-by: Sebastien Luttringer <seblu@seblu.net> Signed-off-by: Tom Gundersen <teg@jklm.no>
2011-03-29whitespace cleanupDave Reisner
* adhere to a consistant vim modeline * use top-right/bottom-left braces for functions Signed-off-by: Dave Reisner <d@falconindy.com> Signed-off-by: Tom Gundersen <teg@jklm.no>
2011-02-10Added missing else clause in set_consolefont functionEric Bélanger
The else clause was missing in the return value test. This caused the status to remain at BUSY instead of being changed to DONE for systems where CONSOLEMAP was not used. Signed-off-by: Eric Bélanger <snowmaniscool@gmail.com>
2011-01-28Only call activate_vgs a second time if any logical volumes have actually ↵Thomas Bächler
been activated.
2011-01-27Fix crypttab option column processing.Thomas Bächler
2011-01-27Fix run_hook and add_hook definitions.Thomas Bächler
This patch does 3 things: 1) Use declare -fr instead of -r, as -r does not affect functions. 2) Make sure everything is only defined once, as you cannot redefine a read-only function. 3) Fix indentation.
2011-01-27Allow setting the locale during boot and daemon startup.Thomas Bächler
This is configurable by the new rc.conf option DAEMON_LOCALE.
2010-12-06lvm: run vgchange in sysinit modeTom Gundersen
This avoids problems with lack of rw filesystems. Solves: #FS18153.
2010-07-23Rewrite /etc/crypttab processing.Victor Lowther
Split out reading /etc/crypttab and procssing the individual lines into their own helper functions, and bashify the resulting shorter code. Processing this file is still ugly, though. :(
2010-07-11Both rc.single and rc.shutdown use the same code to kill everything.Victor Lowther
Simplify it, and move that shared code into functions. Parsing the output of ls is Bad, especially when globbing works just as well and does not get confused by odd characters in filenames. bash has arithemetic for loops. Use them instead of while loops for iterating over arrays.
2010-07-11Finish bashifying functions.Victor Lowther
Slightly simplify hook-running infrastructure. Go ahead and declare add_hook and run_hook as readonly functions to prevent hooks from overwriting them. Too bad bash does not have lexically scoped variables -- if it does, we could do the same with the hook_funcs associative array. If $CONSOLEFONT is not declared, then just return out of set_consolefont. We do this early so that the entire body of the function is not in an if block. Replace trivial use of grep with bash regex conditional. Bash has regex support, and it allows us to replace most trivial uses of sed, grep, and awk. The fewer processes we create, the faster we go, and every little bit helps. I also think it is more readable to use a bash regex for the trivial stuff. Replace if statement with parameter expansion. ${foo:+-p ${foo}} expands to nothing if foo is not set, -p $foo if foo is set. Replace slightly too long echo staement with a here document. This adds a line, but making things more readable is worth it. Make sourcing functions.d files a tiny bit shorter and faster.
2010-07-11Simplify in_array.Victor Lowther
All that extra checking for the first character being @ is not needed, simple parameter expansion will trim it off if it is there.
2010-07-11Clean up status() function.Victor Lowther
Calling your args with $* will do nasty things if any of your args has a space in it. "$@" will always do The Right Thing. Just test the command directly, don't run it and then grab its exit value.
2010-07-11A little creative parameter expansion simplifies stat_die().Victor Lowther
2010-07-11Bashify initscripts.Victor Lowther
We rely on bash specific features (arrays and associative arrays). Trying to maintain POSIX compatibility is a net performancle loss, since native bash constructs tend to perform better and lend themselves to less buggy code. Start off by adding #!/bin/bash to the top of functions to make it clear that we are not POSIX, and to help text editors perform appropriate syntax highlighting. Tighten up the console size finding code a bit, and simplify the code that clears USECOLOR. Use [[ ]] instead of [ ] for conditional checking when running in bash. It is worth 10 - 30% speedup whenever you want to compare something. Instead of calling a command and then testing for nonzero exit status, just test the command exit status directly.
2010-05-04Bring back \e(K to locale.shRoman Kyrylych
See FS#18759 for more details. Signed-off-by: Roman Kyrylych <roman@archlinux.org>
2010-03-20Remove obsolete consolemap activation escape sequencesKurt J. Bosch
2010-02-16Make consolefont code deferrable to avoid destroying splashKurt J. Bosch
2009-09-24Fix stty/tput usage for columns againJim Pryor
Cleans up double application of earlier fixes for this issue. Instead of calling $(tput cols 2>/dev/null), we now try tput cols silently to see whether it complains. If not, then we call $(tput cols) with no redirection of stderr. This way, we can get results other than 80. eliminate color when stdout is not terminal Signed-off-by: Jim Pryor <profjim@jimpryor.net> Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2009-08-26Make the hook-system a bit more usableThomas Bächler
This patch makes the hook names unique, prefixing them all with the script name (without the 'rc.') It also removes the explicit declarations of all elements of the array, bash assumes "" if they are uninitialized
2009-08-25Implement a hook-system that allows to add custom code to the initscripts at ↵Thomas Bächler
certain places A function add_hook can be called from functions.d to register a hook function. The existing hooks are based on suggestions from Michael Towers (larch) and on the implementation of initscripts-extras-fbsplash which currently uses the strings passed to stat_busy and stat_done for this. More hooks can be added if requested. The implementation uses associative arrays and will thus only work with bash 4 or later
2009-08-22Fix in_array function2009.08-1Thomas Bächler
In in_array a check might look like [ "!" = "@" ], which will fail because of the !, so make this check look like [ "x!" = "x@" ]. Also, when an entry is prefixed with !, it should be handled as if it was not in the array.
2009-08-05Enable in_array for prefixed daemonsAaron Griffin
Previous code has issues with ! and @ prefixed DAEMONS Original-by: Florian Pritz <bluewind@xssn.at> Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2009-08-05Revert previous commit chunk: in_array fixesAaron Griffin
Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2009-08-05Fix stty/tput usage for columnsJim Pryor
This corrects the usage of stty and tput under various non-TTY conditions such as under cron and redirected output. [Aaron: Also corrected my USECOLOR bug I introduced last patch] Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2009-07-30functions: refactor for non-tty outputAaron Griffin
This commit should allow rc.d scripts to be run from non-tty's, such as a cron job Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2009-07-30Shutdown non-rc.conf daemons firstAaron Griffin
Flip the order in which daemons are shutdown. First we scan for all daemons that are NOT in rc.conf and shut those down (order is based on ls, so it is dependent on LC_COLLATE). Afterwards, we shut down all daemons in rc.conf, in order Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2009-07-29functions: Add -- to stat_append printfJacob Winther
printf causes scripts to fail when argument starts with a dash Calling stat_append "- hello" causes the following error: /etc/rc.d/functions: line 99: printf: - : invalid option printf: usage: printf [-v var] format [arguments] [FAIL] Ref: FS#15713 Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2009-04-02Make sure functions ends cleanlyAaron Griffin
When errexit was set, sourcing functions caused a script to exit. Fix this by using a real 'if' instead of the [ a ] && b syntax. Also, fix the vim modeline :) Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2009-03-09Fix status display functionsAllan McRae
The status display functions were returning the opposite of what they should have been. Also made cosmetic changes to the output. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2008-12-23Add some simple status display functionsAaron Griffin
This is useful for displaying daemon status in functions like /etc/rc.d/$DAEMON status Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2008-12-04unset the TZ envvar in 'functions'Aaron Griffin
This prevents a local TZ variable from breaking daemon's when started by root. Daemon's should always respect the system's /etc/localtime Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2008-09-18Fix bug #112292008.09-2Thomas Bächler
2008-06-20Minor simplication for /etc/rc.d/functions.d/Natanael Copa
Trivial simplification to make code more readable. Removes one fork so booting should be "faster". Probably not mesureable Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2008-05-27Allow users to ovverride daemon start and stop in rc.multi and rc.shutdownAnton Fiuman
Signed-off-by: Anton Fiuman <llexiw@gmail.com>
2008-05-22Remove source_functions in favor of always sourcing the dirAaron Griffin
This is an obvious oversight on my part - this change allows the overridden functions to work in daemon scripts and anything else that uses /etc/rc.d/functions by itself. Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2008-03-08Add basic support for dependencies in rc.d scriptsRoman Kyrylych
Example of use: DEPENDS=('dbus' 'acpid') . . . ck_depends ${DEPENDS[@]} and those daemons will be started if not running already Signed-off-by: Roman Kyrylych <roman@archlinux.org>
2008-03-08Use full path to binaries everywhereRoman Kyrylych
Signed-off-by: Roman Kyrylych <roman@archlinux.org>
2008-03-08Fix indentation in rc.d/functionsRoman Kyrylych
Signed-off-by: Roman Kyrylych <roman@archlinux.org>
2008-02-14Merge branch 'posix' into workingDan McGee
2008-02-14functions:source_functions(): don't fail on empty dirDan McGee
Instead of using globbing which will fail on an empty directory, use an ls call similar to other places in the initscripts which is not prone to failure. (See rc.single in the daemon shutdown for example.) Signed-off-by: Dan McGee <dan@archlinux.org>
2008-02-14Make functions sh compatibleDan McGee
There is no reason to use bashisms in functions, so eliminate any and use printf instead of echo options which are not guaranteed to be implemented in a POSIX sh. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-02-14Don't assume sh == bashDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-20Make the background black on all status textSimo Leone
This is the easiest way to cleanup the script output on white terminals without resorting to shutting off color. It won't make everyone happy, though. Ref: FS#1186 Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2007-12-13Fix FS#8843 (no colors in rc.sysinit output with separate /usr)Roman Kyrylych
when tput returns exit code 3 - assume it output '8' (as written in the /usr/share/terminfo/l/linux file) Signed-off-by: Roman Kyrylych <roman@archlinux.org> Converted to if/elsif form Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2007-11-28Source /etc/rc.d/functions.d/ for additional initscript functionsAaron Griffin
Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>