aboutsummaryrefslogtreecommitdiff
path: root/functions
AgeCommit message (Collapse)AuthorFiles
2011-07-10functions/rc.sysinit: Refactor fsck-redirection to prevent breakageKurt J. Bosch1
$FSCK_OUT/$FSCK_ERR might not be set when: * unset in some custom sysinit_prefsck hook * calling fsck() from a shutdown hook
2011-07-10Refactor kill_everything, fsck_all and mount_all codeKurt J. Bosch1
Genaral scheme for hook positions is now: run_hook pre_foo if [[$WE_WANT_TO_DO_FOO]]]; then stat_busy "Doing foo" if [[$PRECONDITIONS_FOR_FOO_NOT_SATISFIED]]; then stat_fail else ... stat_done fi fi run hook post_foo rc.sysinit ----------- run_hook pre_foo [[$WE_WANT_TO_DO_FOO]] && status "Doing foo" foo run hook post_foo functions ------------ foo() { [[$PRECONDITIONS_FOR_FOO_NOT_SATISFIED]] && return 1 ... } Rationale Following this scheme as close as possible (without duplicating code and status messages) makes stuff more readable and uniform. Splitting kill_everything() into two new functions stop_all_daemons() and kill_all() also allows customization of either daemons stopping or process killing in an easy way. Suggested-by: Tom Gundersen <teg@jklm.no>
2011-07-10functions/rc.multi: Strip paths from binariesKurt J. Bosch1
Now that we set PATH in functions, we can use is everywhere.
2011-07-10functions: Add missing quotes in mount_all()Kurt J. Bosch1
Prevent any word splitting where not intended.
2011-07-10functions: Get rid of superfluous braces in udevd_modprobe()Kurt J. Bosch1
Braces are not needed in this case as a variable name can not begin with a number.
2011-07-02functions/rc.single: Clean up whitespaceKurt J. Bosch1
2011-06-28Move export PATH into functionsKurt J. Bosch1
Also sanitze the PATH for rc.single, rc.multi, rc.local and daemons.
2011-06-28functions: Make activate_vgs return 0 if noop for consistencyKurt J. Bosch1
2011-06-28Move activate_vgs and crypt stat_busy to the top for consistencyKurt J. Bosch1
2011-06-28Move fsck executable check into fsck_all() for consistencyKurt J. Bosch1
2011-06-28Refactor to get rid of simple if-constuctsKurt J. Bosch1
2011-06-28functions: Simplify kill_everything() omit_pid handlingKurt J. Bosch1
All credits go to: Dave Reisner <d@falconindy.com>
2011-06-28functions: Simplify ck_depends() for statementKurt J. Bosch1
2011-06-28Add some commentsKurt J. Bosch1
2011-06-28functions: Define $fsckret read-only because exposed to hookKurt J. Bosch1
2011-06-28Fix local statements missing in ck_depends, ck_pidfile, do_unlock, ↵Kurt J. Bosch1
kill_everything
2011-06-28Fix '>|' not used allways when redirecting to filesKurt J. Bosch1
This avoids errors if one should set the noclobber shell option somewhere (within a daemon script or some custom function). We already had this, but it seems gone lost mostly.
2011-06-28functions: Fix indentationKurt J. Bosch1
2011-06-24rc.multi/rc.single: Merge duplicated bootlogd stop code into a functionKurt J. Bosch1
2011-06-24rc.sysinit/rc.single: Merge UDev stuff into a functionKurt J. Bosch1
rc.single changes (when coming from multi-user): * avoid settling UDev quietly as in rc.sysinit * modules defined in rc.conf are loaded if missing * minilogd is started before udevd as in rc.sysinit rc.sysinit behaviour is unchanged
2011-06-24Simplify in_array functionKurt J. Bosch1
2011-06-24Some more cosmeticsKurt J. Bosch1
2011-06-24Some cosmeticsKurt J. Bosch1
2011-06-23functions: warn if daemons are started recursivelyTom Gundersen1
In particular, recomend against using ck_depends. Signed-off-by: Tom Gundersen <teg@jklm.no>
2011-06-23added get_pid() and ck_pidfile() (FS#18654)Andrwe Lord Weber1
Implemented suggestions of Dave. get_pid: Arguments: programname Returns: PID of program ck_pidfile: Arguments: PID-file programname Returns: 0 - PID in PID-file is of program 1 - PID in PID-file is not of program Signed-off-by: Andrwe Lord Weber <archlinux@andrwe.org> Signed-off-by: Tom Gundersen <teg@jklm.no>
2011-06-22Move mount -a into functions to allow custom override (fsck on loop)Kurt J. Bosch1
2011-06-22Allow custom fsck on shutdown via hook (FS#18736)Kurt J. Bosch1
2011-06-22Simplify fsck functionsKurt J. Bosch1
2011-06-22Move fsck stuff into functions to allow custom overrides (FS#18736)Kurt J. Bosch1
2011-06-20status: adjust number of columns after loading modulesTom Gundersen1
In case loading modules enables a frambuffer with higher resolution than the standard 80 columns, we recalculate the number of columns after all modules have been loaded. Original-patch-by: Aaron Griffin <aaronmgriffin@gmail.com> Original-patch-by: Søren Poulsen <nikorpoulsen@gmail.com> Signed-off-by: Tom Gundersen <teg@jklm.no>
2011-06-19Adding hook sysinit_postmountjofko1
In some cases is good to know when rc.sysinit is going to use /usr See FS#24712 Signed-off-by: jofko <joffko@gmail.com> [tomegun: added comment to 'functions' and changed name of hook] Signed-off-by: Tom Gundersen <teg@jklm.no>
2011-06-18Ensure rc.d scripts are run as rootSebastien Luttringer1
By default all script should be run as root. If NEED_ROOT=0 is set before loading /etc/rc.d/functions in a rc.d scripts, this will not apply. This allow script with only some part which require root level to call need_root() function at beginning of those parts. Close FS#24095 Signed-off-by: Sebastien Luttringer <seblu@seblu.net>
2011-06-08Removed superfluous dollar signEric Bélanger1
Signed-off-by: Eric Bélanger <snowmaniscool@gmail.com> Signed-off-by: Tom Gundersen <teg@jklm.no>
2011-05-21Improve coloring on light and transparent termSebastien Luttringer1
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 Pozzi1
(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 Luttringer1
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 Luttringer1
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 Luttringer1
Signed-off-by: Sebastien Luttringer <seblu@seblu.net> Signed-off-by: Tom Gundersen <teg@jklm.no>
2011-03-29whitespace cleanupDave Reisner1
* 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élanger1
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ächler1
been activated.
2011-01-27Fix crypttab option column processing.Thomas Bächler1
2011-01-27Fix run_hook and add_hook definitions.Thomas Bächler1
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ächler1
This is configurable by the new rc.conf option DAEMON_LOCALE.
2010-12-06lvm: run vgchange in sysinit modeTom Gundersen1
This avoids problems with lack of rw filesystems. Solves: #FS18153.
2010-07-23Rewrite /etc/crypttab processing.Victor Lowther1
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 Lowther1
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 Lowther1
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 Lowther1
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 Lowther1
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.