Bug 18309: UNIMARC update from IFLA - authority (fr) (PERS)
[koha.git] / debian / scripts / koha-reset-passwd
blob14cfe33f037c71496c6987963cb3c8d286818577
1 #!/bin/sh
3 # koha-reset-passwd -- reset password for a user in a Koha instance
4 # Copyright 2010 Catalyst IT, Ltd
5 # Copyright 2019 Theke Solutions
6 #
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 set -e
23 # include helper functions
24 if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then
25 . "/usr/share/koha/bin/koha-functions.sh"
26 else
27 echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2
28 exit 1
31 usage()
33 local scriptname=$0
34 cat <<EOF
35 Resets the password for the specified user on the Koha instance.
37 Usage: $scriptname instancename userid
39 Note: The generated password will be printed.
40 EOF
43 set_password()
45 local instancename=$1
46 local userid=$2
48 # Optionally use alternative paths for a dev install
49 adjust_paths_dev_install $1
51 if [ "$DEV_INSTALL" = "" ]; then
52 KOHA_BINDIR=$KOHA_HOME/bin
53 else
54 KOHA_BINDIR=$KOHA_HOME/misc
57 if sudo -u "$instancename-koha" -H \
58 env PERL5LIB=$PERL5LIB \
59 KOHA_CONF="/etc/koha/sites/$instancename/koha-conf.xml" \
60 $KOHA_BINDIR/admin/set_password.pl --userid $userid ; then
62 return 0
63 else
64 return 1
68 if [ $# -lt 2 ]; then
69 usage
70 die "Wrong parameters"
73 instance="$1"
74 shift
76 for userid in "$@"
78 set_password $instance $userid
79 done
81 exit 0