Skip to content

Commit 83bd13f

Browse files
committed
Password matrix and password lenght can now be overided in vesta.conf
1 parent fa57d05 commit 83bd13f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

func/main.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ BACKUP_DISK_LIMIT=95
1919
BACKUP_LA_LIMIT=5
2020
RRD_STEP=300
2121
RRD_IFACE_EXCLUDE=lo
22-
22+
PW_MATRIX='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
23+
PW_LENGHT='10'
2324
BIN=$VESTA/bin
2425
USER_DATA=$VESTA/data/users/$user
2526
WEBTPL=$VESTA/data/templates/web
@@ -128,10 +129,10 @@ is_package_full() {
128129

129130
# Random password generator
130131
gen_password() {
131-
matrix='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
132-
lenght=10
133-
while [ ${n:=1} -le $lenght ]; do
134-
pass="$pass${matrix:$(($RANDOM%${#matrix})):1}"
132+
pw_matrix=${1-$PW_MATRIX}
133+
pw_lenght=${2-$PW_LENGHT}
134+
while [ ${n:=1} -le $pw_lenght ]; do
135+
pass="$pass${pw_matrix:$(($RANDOM%${#pw_matrix})):1}"
135136
let n+=1
136137
done
137138
echo "$pass"

0 commit comments

Comments
 (0)