Created
June 4, 2021 23:25
-
-
Save jfinstrom/2d8e17c1c2bf8da07d0a7046382c12e2 to your computer and use it in GitHub Desktop.
Generate a htpasswd file from FreePBX userman group.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
// (c) 2021 James Finstrom | |
// This code is licensed under MIT license | |
include '/etc/freepbx.conf'; | |
$gid = 1; | |
$freepbx = FreePBX::Create(); | |
$group = $freepbx | |
->Userman | |
->getGroupByGID($gid); | |
$users = array_map(function ($u) use ($freepbx) | |
{ | |
$user = $freepbx | |
->Userman | |
->getUserByID($u); | |
return sprintf('%s:%s', $user['username'], $user['password']); | |
} | |
, $group['users']); | |
echo implode(PHP_EOL, $users); ~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment