allow to run this with args to change the password

This commit is contained in:
Franco Fichtner 2017-07-13 19:28:15 +02:00
parent 5cb149d7fc
commit 76eb058d32

View File

@ -31,6 +31,19 @@
require_once('config.inc');
require_once('auth.inc');
$password = isset($argv[1]) ? $argv[1] : '';
$confirm = isset($argv[2]) ? $argv[2] : '';
if (!empty($password) && $password === $confirm) {
/* the installer needs this code to change the password */
$admin_user = &getUserEntryByUID(0);
if ($admin_user) {
local_user_set_password($admin_user, $password);
write_config('Root user reset from console');
}
exit(0);
}
$fp = fopen('php://stdin', 'r');
echo "The root user login behaviour will be restored to its defaults.\n\nDo you want to proceed? [y/N]: ";
@ -88,6 +101,6 @@ if ($password !== $confirm) {
local_user_set_password($admin_user, $password);
local_user_set($admin_user);
write_config('Root user reset from console menu');
write_config('Root user reset from console');
echo "\nThe root user has been reset successfully.\n";