]> TLD Linux GIT Repositories - rc-scripts.git/blobdiff - lib/functions
- PLD merge: don't delete base pidfile if other pid file was specified
[rc-scripts.git] / lib / functions
index 8f08dc62283bec1b0699c90d08c63f520d60033b..b4c4840aa6dce182ea5b226d74cb07eb01cdb94a 100644 (file)
@@ -59,52 +59,6 @@ CCHARS="$WHITE"              # Color of these characters (look at /etc/sysconfig/init-colors
 [ -r /etc/sysconfig/system ] && . /etc/sysconfig/system
 [ -r /etc/sysconfig/bootsplash ] && . /etc/sysconfig/bootsplash
 
-if [ -z "$VSERVER" -o "$VSERVER" = "detect" ]; then
-       {
-               while read _f _ctx; do
-                       [ "$_f" = "VxID:" -o "$_f" = "s_context:" ] && break
-               done </proc/self/status
-       } 2>/dev/null
-       if [ -z "$_ctx" -o "$_ctx" = "0" ]; then
-               VSERVER=no
-       else
-               VSERVER=yes
-       fi
-       unset _f _ctx
-fi
-
-# VSERVER_ISOLATION_NET = isolation only inside of vserver guests
-if [ -z "$VSERVER_ISOLATION_NET" -o "$VSERVER_ISOLATION_NET" = "detect" ]; then
-       VSERVER_ISOLATION_NET=no
-       if [ "$VSERVER" = "yes" ]; then
-               if [ -f /proc/self/nsproxy ]; then
-                       # older kernels
-                       {
-                               while read _t _data; do
-                                       [ "$_t" = "net:" ] && break
-                               done < /proc/self/nsproxy
-                       } 2> /dev/null
-                       if [ "${_data##*\(}" = "I)" ]; then
-                               VSERVER_ISOLATION_NET=yes
-                       fi
-               elif [ -f /proc/self/ninfo ]; then
-                       # newer kernels
-                       {
-                               while read _t _data; do
-                                       [ "$_t" = "NCaps:" ] && break
-                               done < /proc/self/ninfo
-                       } 2> /dev/null
-                       if [ "${_t}" = "NCaps:" ]; then
-                               VSERVER_ISOLATION_NET=yes
-                       fi
-               else
-                       # assume (very?) old kernel mode
-                       VSERVER_ISOLATION_NET=yes
-               fi
-               unset _f _data
-       fi
-fi
-
 # we need to know in functions if we were called from a terminal
 if [ -z "$ISATTY" ]; then
        [ -t ] && ISATTY=yes || ISATTY=no
@@ -165,11 +119,7 @@ strstr() {
 
 # Apply sysctl settings, including files in /etc/sysctl.d
 apply_sysctl() {
-       local file
-       for file in /etc/sysctl.d/*.conf; do
-               test -f "$file" && sysctl -q -e -p "$file"
-       done
-       sysctl -q -e -p /etc/sysctl.conf
+       sysctl -q -e --system
 }
 
 if is_yes "$FASTRC" || is_yes "$IN_SHUTDOWN"; then
@@ -358,7 +308,7 @@ nls() {
 rc_splash() {
        local action="$1"
 
-       if ! is_no "$BOOT_SPLASH" && ! is_yes "$VSERVER"; then
+       if ! is_no "$BOOT_SPLASH"; then
                [ -x /bin/splash ] && /bin/splash "$action"
        fi
 
@@ -472,7 +422,6 @@ checkpid() {
 # - inside chroot get only those processes, which are inside chroot.
 # - don't filter out pids which do not have corresponding running processes (process died etc)
 # (note: some processes like named are chrooted but run outside chroot)
-# - do nothing inside vserver
 filter_chroot() {
        # no pids, exit early
        [ $# -eq 0 ] && return
@@ -484,11 +433,6 @@ filter_chroot() {
                pids=$(filter_ns "$@") && set -- "$pids"
        fi
 
-       if is_yes "$VSERVER"; then
-               echo $@
-               return
-       fi
-
        if [ $# -lt 1 -o ! -d /proc/1 ]; then
                echo $@
                return
@@ -952,7 +896,11 @@ killproc() {
 
        # Remove pid file if any.
        if [ "$notset" = "1" ]; then
-               rm -f /var/run/${base}.pid
+               if [ -f "${pidfile}" ] ; then
+                       rm -f "$pidfile"
+               else
+                       rm -f /var/run/${base}.pid
+               fi
        fi
 
        return $result
@@ -1080,6 +1028,9 @@ confirm() {
 
 # module is needed (ie. is requested, is available and isn't loaded already)
 is_module() {
+       # fail if /sbin/lsmod does not exists (ex. in containers)
+       [ -x /sbin/lsmod ] || return 1
+
        # module name without .o at end
        if ! lsmod | grep -q "$1"; then
                if ls -1R /lib/modules/$(uname -r)/ 2> /dev/null | grep -q "^${1}.\(\|k\)o\(\|.gz\)"; then