Commit 76eb058d authored by Franco Fichtner's avatar Franco Fichtner

allow to run this with args to change the password

parent 5cb149d7
...@@ -31,6 +31,19 @@ ...@@ -31,6 +31,19 @@
require_once('config.inc'); require_once('config.inc');
require_once('auth.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'); $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]: "; 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) { ...@@ -88,6 +101,6 @@ if ($password !== $confirm) {
local_user_set_password($admin_user, $password); local_user_set_password($admin_user, $password);
local_user_set($admin_user); 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"; echo "\nThe root user has been reset successfully.\n";
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment