initSync(): fixed parameter naming
[util-vserver.git] / util-vserver / scripts / functions
index 017bb07..cd6a955 100644 (file)
@@ -70,9 +70,9 @@ function findAndCopy
 ## Usage: isRegularFile <filename> [<mod>]
 function isRegularFile
 {
-    test ${mod:--f} "$1" || return 1
+    test ${2:--f} "$1" || return 1
 
-    case $file in
+    case $1 in
        (*.rpmsave|*.rpmnew|*.rpmorig|*.cfsaved*|*.~*~) return 1;;
     esac
 
@@ -140,6 +140,22 @@ function isNumber
     return 0
 }
 
+## Usage: hasSubstring <haystack> <needle>+
+function hasSubstring
+{
+    local pat=$1
+    local i
+    
+    shift
+
+    for i; do
+       test x"${pat/*$i*/$i}" = x"$i" || continue
+       return 0
+    done
+
+    return 1
+}
+
 ## Usage: colorize <style> <command>
 function colorize
 {
@@ -436,8 +452,8 @@ function getAllVservers
        case ${2:-ALL} in
            (MARKED)    test   -s "$_ga_markfile" || _ga_doadd=;;
            (UNMARKED)  test ! -s "$_ga_markfile" || _ga_doadd=;;
-           (STOPPED)   ! $_VSERVER "$_ga_i" runnning &>/dev/null || _ga_doadd=;;
-           (RUNNING)     $_VSERVER "$_ga_i" runnning &>/dev/null || _ga_doadd=;;
+           (STOPPED)   ! $_VSERVER "$_ga_i" running &>/dev/null || _ga_doadd=;;
+           (RUNNING)     $_VSERVER "$_ga_i" running &>/dev/null || _ga_doadd=;;
            (ALL)       ;;
            (*)         panic $"Unknown vserver tagging '$2'";;
        esac
@@ -776,7 +792,7 @@ To fix this, you can:"
 
        test -x "$solution_sysctl" || warning $"\
 * configure the util-vserver vshelper script, e.g. by adding
-  | kernel.vshelper = \"$_VSHELPER\"
+  | kernel.vshelper = $_VSHELPER
   to /etc/sysctl.conf and rebooting the machine, or by executing
   | echo \"$_VSHELPER\" >$proc_file"
 
@@ -914,7 +930,7 @@ function vshelper.initSync
 
     local _vis_fifo="$_vis_tmpdir"/pipe
     $_MKFIFO -m700 "$_vis_fifo"
-    vshelper.doInit "$1" "${method:-sync}" "$_vis_fifo"
+    vshelper.doInit "$1" "${3:-sync}" "$_vis_fifo"
     eval $2=\$_vis_fifo
 }