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

(-)a/debian/docs/koha-reset-passwd.xml (-2 / +13 lines)
Lines 23-36 Link Here
23
23
24
  <refsynopsisdiv>
24
  <refsynopsisdiv>
25
    <cmdsynopsis>
25
    <cmdsynopsis>
26
      <command>koha-reset-passwd</command> <arg choice="req" rep="norepeat"><replaceable>instancename</replaceable></arg> <arg choice="req" rep="norepeat">username</arg>
26
      <command>koha-reset-passwd</command> [<arg rep="norepeat">--skip_validation</arg>]<arg choice="req" rep="norepeat"><replaceable>instancename</replaceable></arg> <arg choice="req" rep="norepeat">username</arg>
27
    </cmdsynopsis>
27
    </cmdsynopsis>
28
  </refsynopsisdiv>
28
  </refsynopsisdiv>
29
29
30
  <refsect1><title>Description</title>
30
  <refsect1><title>Description</title>
31
  <para>Reset password for a user in a Koha instance.</para>
31
  <para>Reset password for a user in a Koha instance.</para>
32
  </refsect1>
32
  </refsect1>
33
  
33
34
  <refsect1><title>Options</title>
35
      <variablelist>
36
        <varlistentry>
37
          <term><option>--skip_validation</option></term>
38
          <listitem>
39
            <para>If specified, no password enforcement policies will the applied.</para>
40
          </listitem>
41
        </varlistentry>
42
      </variablelist>
43
  </refsect1>
44
34
  <refsect1><title>See also</title>
45
  <refsect1><title>See also</title>
35
  <simplelist type="inline">
46
  <simplelist type="inline">
36
    <member><command>koha-dump-defaults(8)</command></member>
47
    <member><command>koha-dump-defaults(8)</command></member>
(-)a/debian/scripts/koha-reset-passwd (-3 / +30 lines)
Lines 34-40 usage() Link Here
34
    cat <<EOF
34
    cat <<EOF
35
Resets the password for the specified user on the Koha instance.
35
Resets the password for the specified user on the Koha instance.
36
36
37
Usage: $scriptname instancename userid
37
Usage: $scriptname [options] instancename userid
38
Options:
39
    --help | -h        Display this help message
40
    --skip_validation  Skip the password enforcement policy
38
41
39
Note: The generated password will be printed.
42
Note: The generated password will be printed.
40
EOF
43
EOF
Lines 44-49 set_password() Link Here
44
{
47
{
45
    local instancename=$1
48
    local instancename=$1
46
    local userid=$2
49
    local userid=$2
50
    local skip_validation=$3
47
    local password=$(pwgen 12 1)
51
    local password=$(pwgen 12 1)
48
52
49
    # Optionally use alternative paths for a dev install
53
    # Optionally use alternative paths for a dev install
Lines 55-64 set_password() Link Here
55
        KOHA_BINDIR=$KOHA_HOME/misc
59
        KOHA_BINDIR=$KOHA_HOME/misc
56
    fi
60
    fi
57
61
62
    SET_PASSWORD_OPTS="--userid $userid --password $password"
63
    if [ "$skip_validation" = "yes" ]; then
64
        SET_PASSWORD_OPTS="${SET_PASSWORD_OPTS} --skip_validation"
65
    fi
66
58
    if sudo -u "$instancename-koha" -H \
67
    if sudo -u "$instancename-koha" -H \
59
        env PERL5LIB=$PERL5LIB \
68
        env PERL5LIB=$PERL5LIB \
60
        KOHA_CONF="/etc/koha/sites/$instancename/koha-conf.xml" \
69
        KOHA_CONF="/etc/koha/sites/$instancename/koha-conf.xml" \
61
        $KOHA_BINDIR/admin/set_password.pl --userid $userid --password $password ; then
70
        $KOHA_BINDIR/admin/set_password.pl ${SET_PASSWORD_OPTS} ; then
62
71
63
        echo "$userid $password"
72
        echo "$userid $password"
64
        return 0
73
        return 0
Lines 72-83 if [ $# -lt 2 ]; then Link Here
72
    die "Wrong parameters"
81
    die "Wrong parameters"
73
fi
82
fi
74
83
84
skip_validation="no"
85
86
while [ -n "$*" ]; do
87
    case "$1" in
88
        -h|--help)
89
            usage ; exit 0
90
            ;;
91
        --skip_validation)
92
            skip_validation="yes"
93
            ;;
94
        *)
95
            break
96
            ;;
97
    esac
98
99
    shift
100
done
101
75
instance="$1"
102
instance="$1"
76
shift
103
shift
77
104
78
for userid in "$@"
105
for userid in "$@"
79
do
106
do
80
    set_password $instance $userid
107
    set_password $instance $userid $skip_validation
81
done
108
done
82
109
83
exit 0
110
exit 0
(-)a/misc/admin/set_password.pl (-2 / +4 lines)
Lines 24-35 use Pod::Usage; Link Here
24
use Koha::Patrons;
24
use Koha::Patrons;
25
25
26
my ( $help, $password, $cardnumber, $patron_id, $userid );
26
my ( $help, $password, $cardnumber, $patron_id, $userid );
27
my $skip_validation = 0;
28
27
GetOptions(
29
GetOptions(
28
    'help|?'         => \$help,
30
    'help|?'         => \$help,
29
    'userid=s'       => \$userid,
31
    'userid=s'       => \$userid,
30
    'password=s'     => \$password,
32
    'password=s'     => \$password,
31
    'patron_id=s'    => \$patron_id,
33
    'patron_id=s'    => \$patron_id,
32
    'cardnumber=s'   => \$cardnumber,
34
    'cardnumber=s'   => \$cardnumber,
35
    'skip_validation' => \$skip_validation
33
);
36
);
34
37
35
pod2usage(1) if $help;
38
pod2usage(1) if $help;
Lines 62-68 unless ( $patrons->count > 0 ) { Link Here
62
}
65
}
63
66
64
my $patron = $patrons->next;
67
my $patron = $patrons->next;
65
$patron->set_password({ password => $password, skip_validation => 1 });
68
$patron->set_password({ password => $password, skip_validation => $skip_validation });
66
69
67
=head1 NAME
70
=head1 NAME
68
71
69
- 

Return to bug 21976