View | Details | Raw Unified | Return to bug 17717
Collapse All | Expand All

(-)a/debian/docs/koha-foreach.xml (-2 / +15 lines)
Lines 23-29 Link Here
23
23
24
  <refsynopsisdiv>
24
  <refsynopsisdiv>
25
    <cmdsynopsis>
25
    <cmdsynopsis>
26
      <command>koha-foreach</command> <arg><option>--enabled</option></arg> <arg><option>--email</option>|<option>--noemail</option></arg> <arg><option>command</option></arg>
26
      <command>koha-foreach</command> <arg><option>--chdir</option></arg> <arg><option>--enabled</option></arg> <arg><option>--email</option>|<option>--noemail</option></arg> <arg><option>command</option></arg>
27
    </cmdsynopsis>
27
    </cmdsynopsis>
28
  </refsynopsisdiv>
28
  </refsynopsisdiv>
29
29
Lines 31-37 Link Here
31
  <para>Run a command for each Koha instance. Takes the same arguments as koha-list.</para>
31
  <para>Run a command for each Koha instance. Takes the same arguments as koha-list.</para>
32
  <para>The string "__instancename__" is replaced in the argument list with the name of the Koha instance in each iteration.</para>
32
  <para>The string "__instancename__" is replaced in the argument list with the name of the Koha instance in each iteration.</para>
33
  </refsect1>
33
  </refsect1>
34
  
34
35
  <refsect1>
36
    <title>Options</title>
37
      <variablelist>
38
      <varlistentry>
39
        <term><option>--chdir</option></term>
40
        <listitem>
41
          <para>This option makes the command jump into the instance's home directory before running the required command. This prevents
42
            directory traversal permissions issues.</para>
43
        </listitem>
44
      </varlistentry>
45
    </variablelist>
46
  </refsect1>
47
35
  <refsect1><title>See also</title>
48
  <refsect1><title>See also</title>
36
  <simplelist type="inline">
49
  <simplelist type="inline">
37
    <member><command>koha-create-dirs(8)</command></member>
50
    <member><command>koha-create-dirs(8)</command></member>
(-)a/debian/scripts/koha-foreach (-1 / +11 lines)
Lines 28-37 else Link Here
28
    exit 1
28
    exit 1
29
fi
29
fi
30
30
31
chdir="no"
32
starting_dir=$(pwd)
33
31
listopts=""
34
listopts=""
32
while [ ! -z "$1" ]
35
while [ ! -z "$1" ]
33
do
36
do
34
    case "$1" in
37
    case "$1" in
38
        --chdir) chdir="yes";;
35
        --email) listopts="$listopts --email";;
39
        --email) listopts="$listopts --email";;
36
      --noemail) listopts="$listopts --noemail";;
40
      --noemail) listopts="$listopts --noemail";;
37
      --enabled) listopts="$listopts --enabled";;
41
      --enabled) listopts="$listopts --enabled";;
Lines 53-58 do Link Here
53
    cmd=`echo "$@" | sed -e s/__instancename__/${name}/g`
57
    cmd=`echo "$@" | sed -e s/__instancename__/${name}/g`
54
58
55
    if [ "${cmd}" != "" ]; then
59
    if [ "${cmd}" != "" ]; then
60
61
        # Change to the instance's home dir if required
62
        [ "chdir" != "no" ] && eval cd ~$name"-koha"
63
56
        koha-shell ${name} -c "${cmd}"
64
        koha-shell ${name} -c "${cmd}"
65
66
        # Go back to the original dir if required
67
        [ "chdir" != "no" ] && cd $starting_dir
57
    fi
68
    fi
58
done
69
done
59
- 

Return to bug 17717