|
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 |