mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2024-09-19 19:22:14 +02:00
Better arguments management
This commit is contained in:
parent
9be8c8082f
commit
ab10c9b49a
@ -22,7 +22,7 @@ All my tests are performed using $CONF['encrypt'] = 'md5crypt';
|
||||
|
||||
**If you are using Roundcube's password plugin, you should also adapt the $config['password_query'] value.
|
||||
I recommend to use:
|
||||
$config['password_query'] = 'UPDATE mailbox SET password=%c, modified=now(),pw_expires_on=now() + interval 90 day, thirty=0,fourteen=0,seven=0 where username=%u';
|
||||
$config['password_query'] = 'UPDATE mailbox SET password=%c, modified=now(),pw_expires_on=now() + interval 90 day';
|
||||
of cource you may adapt to the expected expiration value
|
||||
|
||||
All my tests are performed using $config['password_algorithm'] = 'md5-crypt';
|
||||
|
@ -5,29 +5,25 @@ POSTFIX_DB="postfix_test"
|
||||
MYSQL_CREDENTIALS_FILE="postfixadmin.my.cnf"
|
||||
|
||||
#All the rest should be OK
|
||||
QUERY30DAYS="SELECT username,pw_expires_on FROM mailbox WHERE pw_expires_on > now() + interval 29 DAY AND pw_expires_on < now() + interval 30 day AND thirty = false;"
|
||||
QUERY14DAYS="SELECT username,pw_expires_on FROM mailbox WHERE pw_expires_on > now() + interval 13 DAY AND pw_expires_on < now() + interval 14 day AND fourteen = false;"
|
||||
QUERY7DAYS="SELECT username,pw_expires_on FROM mailbox WHERE pw_expires_on > now() + interval 6 DAY AND pw_expires_on < now() + interval 7 day AND seven = false;"
|
||||
QUERY30DAYS="SELECT username,pw_expires_on FROM mailbox WHERE pw_expires_on > now() + interval 29 DAY AND pw_expires_on < now() + interval 30 day"
|
||||
QUERY14DAYS="SELECT username,pw_expires_on FROM mailbox WHERE pw_expires_on > now() + interval 13 DAY AND pw_expires_on < now() + interval 14 day"
|
||||
QUERY7DAYS="SELECT username,pw_expires_on FROM mailbox WHERE pw_expires_on > now() + interval 6 DAY AND pw_expires_on < now() + interval 7 day"
|
||||
|
||||
function notifyThirtyDays() {
|
||||
mysql -B --defaults-extra-file="$MYSQL_CREDENTIALS_FILE" "$POSTFIX_DB" -e "$QUERY30DAYS" | while read -a RESULT; do
|
||||
echo -e "Dear User, \n Your password will expire on ${RESULT[1]}" | mail -s "Password 30 days before expiration notication" -r noreply@eyetech.fr ${RESULT[0]}
|
||||
echo "UPDATE mailbox SET thirty = true WHERE username = '${RESULT[0]}';" | mysql --defaults-extra-file="$MYSQL_CREDENTIALS_FILE" "$POSTFIX_DB" ; done
|
||||
mysql --defaults-extra-file="$MYSQL_CREDENTIALS_FILE" "$POSTFIX_DB" -B -e "$QUERY30DAYS" | while read -a RESULT ; do
|
||||
echo -e "Dear User, \n Your password will expire on ${RESULT[1]}" | mail -s "Password 30 days before expiration notication" -r noreply@eyetech.fr ${RESULT[0]} ; done
|
||||
}
|
||||
|
||||
function notifyFourteenDays() {
|
||||
mysql -B --defaults-extra-file="$MYSQL_CREDENTIALS_FILE" "$POSTFIX_DB" -e "$QUERY14DAYS" | while read -a RESULT; do
|
||||
echo -e "Dear User, \n Your password will expire on ${RESULT[1]}" | mail -s "Password 14 days before expiration notication" -r noreply@eyetech.fr ${RESULT[0]}
|
||||
echo "UPDATE mailbox SET fourteen = true WHERE username = '${RESULT[0]}';" | mysql --defaults-extra-file="$MYSQL_CREDENTIALS_FILE" "$POSTFIX_DB" ; done
|
||||
mysql --defaults-extra-file="$MYSQL_CREDENTIALS_FILE" "$POSTFIX_DB" -B -e "$QUERY14DAYS" | while read -a RESULT ; do
|
||||
echo -e "Dear User, \n Your password will expire on ${RESULT[1]}" | mail -s "Password 14 days before expiration notication" -r noreply@eyetech.fr ${RESULT[0]} ; done
|
||||
}
|
||||
|
||||
function notifySevenDays() {
|
||||
mysql -B --defaults-extra-file="$MYSQL_CREDENTIALS_FILE" "$POSTFIX_DB" -e "$QUERY7DAYS" | while read -a RESULT; do
|
||||
echo -e "Dear User, \n Your password will expire on ${RESULT[1]}" | mail -s "Password 7 days before expiraiton notication" -r noreply@eyetech.fr ${RESULT[0]}
|
||||
echo "UPDATE mailbox SET seven = true WHERE username = '${RESULT[0]}';" | mysql --defaults-extra-file="$MYSQL_CREDENTIALS_FILE" "$POSTFIX_DB" ; done
|
||||
mysql --defaults-extra-file="$MYSQL_CREDENTIALS_FILE" "$POSTFIX_DB" -B -e "$QUERY7DAYS" | while read -a RESULT ; do
|
||||
echo -e "Dear User, \n Your password will expire on ${RESULT[1]}" | mail -s "Password 7 days before expiraiton notication" -r noreply@eyetech.fr ${RESULT[0]} ; done
|
||||
}
|
||||
|
||||
notifyThirtyDays # Execute the function for 30 day notices
|
||||
notifyFourteenDays # Execute the function for 14 day notices
|
||||
notifySevenDays # Execute the function for 7 day notices
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
ALTER TABLE mailbox ADD COLUMN pw_expires_on TIMESTAMP DEFAULT now() not null;
|
||||
ALTER TABLE mailbox ADD COLUMN thirty boolean not null DEFAULT false;
|
||||
ALTER TABLE mailbox ADD COLUMN fourteen boolean not null DEFAULT false;
|
||||
ALTER TABLE mailbox ADD COLUMN seven boolean not null DEFAULT false;
|
||||
UPDATE mailbox set pw_expires_on = now() + interval 90 day;
|
||||
ALTER TABLE domain ADD COLUMN password_expiration_value int DEFAULT null;
|
||||
|
Loading…
Reference in New Issue
Block a user