X-Git-Url: https://git.tld-linux.org/?p=rc-scripts.git;a=blobdiff_plain;f=lib%2Ffunctions;h=8f08dc62283bec1b0699c90d08c63f520d60033b;hp=6d68d96a22c6c6aa69cf751d28946617b73fba1e;hb=5d89b49a413e24dae01d41cdb0d50b919ad4830e;hpb=a50fdc3af84c5a9f83fd4593dc7cdc7efa3a68ef diff --git a/lib/functions b/lib/functions index 6d68d96..8f08dc6 100644 --- a/lib/functions +++ b/lib/functions @@ -5,11 +5,13 @@ # # Author: Miquel van Smoorenburg, # Hacked by: Greg Galloway and Marc Ewing -# Modified for TLD Linux by: +# Modified for PLD Linux by: # Marek Obuchowicz # Arkadiusz Miśkiewicz # Michał Kochanowicz # Łukasz Pawelczyk +# Modified for TLD Linux by: +# Marcin Krol # First set up a default search path. export PATH="/sbin:/usr/sbin:/bin:/usr/bin" @@ -37,7 +39,6 @@ BLUE=4 MAGENTA=5 CYAN=6 WHITE=7 -NORMAL=15 # Bold definition (second parameter to termput setaf) BOLD=1 NOBOLD=0 @@ -51,7 +52,7 @@ CTLD="$GREEN" # "TLD Linux" color CI="$RED" # Capital I color (press I to enter interactive startup) CRESMAN="$GREEN" # "Resource Manager" color CHARS="" # Characters displayed on the beginning of show line -CCHARS="$NORMAL" # Color of these characters (look at /etc/sysconfig/init-colors.gentoo example) +CCHARS="$WHITE" # Color of these characters (look at /etc/sysconfig/init-colors.gentoo example) # Source configuration if available - may override default values [ -r /etc/sysconfig/init-colors ] && . /etc/sysconfig/init-colors @@ -164,21 +165,7 @@ strstr() { # Apply sysctl settings, including files in /etc/sysctl.d apply_sysctl() { - if [ -x /lib/systemd/systemd-sysctl ]; then - /lib/systemd/systemd-sysctl - return - fi - local file - for file in /usr/lib/sysctl.d/*.conf; do - [ -f /run/sysctl.d/${file##*/} ] && continue - [ -f /etc/sysctl.d/${file##*/} ] && continue - test -f "$file" && sysctl -q -e -p "$file" - done - for file in /run/sysctl.d/*.conf; do - [ -f /etc/sysctl.d/${file##*/} ] && continue - test -f "$file" && sysctl -q -e -p "$file" - done for file in /etc/sysctl.d/*.conf; do test -f "$file" && sysctl -q -e -p "$file" done @@ -295,7 +282,7 @@ termput() { is_yes "$COLOR_INIT" && echo -ne "\033[${ISBOLD};3${2}m" ;; op) - termput setaf $NORMAL + echo -ne "\033[0m" ;; esac else @@ -308,7 +295,7 @@ termput() { is_yes "$COLOR_INIT" && tput setaf "$2" ;; op) - termput setaf $NORMAL + tput sgr0 ;; esac fi @@ -617,16 +604,90 @@ _daemon_set_ulimits() { done } +# inner function used by daemon(). +# do not call this directly, as it expects variables being inherited. +# also it expects to be called from subshell as it exports env. +# it expects options parsed by daemon() and command to be executed in "$@". +_daemon_exec() { + local prog="" + umask ${SERVICE_UMASK:-$DEFAULT_SERVICE_UMASK}; + export USER=root HOME=/tmp TMPDIR=/tmp + + nice=${nice:-$DEFAULT_SERVICE_RUN_NICE_LEVEL} + nice=${nice:-0} + + # make nice level absolute, not to be dependant of nice level of shell where service started + nice=$(($nice - $(nice))) + + if [ "$closefds" = 1 ]; then + exec 1>&- + exec 2>&- + exec 0<&- + elif [ "$redirfds" = 1 ]; then + exec 1>/dev/null + exec 2>/dev/null + exec 0&1 + exec 0&1 "/dev/cpuset/${SERVICE_CPUSET}/tasks" - if errors=$( - umask ${SERVICE_UMASK:-$DEFAULT_SERVICE_UMASK}; - export USER=root HOME=/tmp TMPDIR=/tmp - - nice=${nice:-$DEFAULT_SERVICE_RUN_NICE_LEVEL} - nice=${nice:-0} - - # make nice level absolute, not to be dependant of nice level of shell where service started - nice=$(($nice - $(nice))) - - if [ "$closefds" = 1 ]; then - exec 1>&- - exec 2>&- - exec 0<&- - elif [ "$redirfds" = 1 ]; then - exec 1>/dev/null - exec 2>/dev/null - exec 0&1 - exec 0&1