Skip to content

Instantly share code, notes, and snippets.

@jfinstrom
Created June 4, 2021 23:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfinstrom/2d8e17c1c2bf8da07d0a7046382c12e2 to your computer and use it in GitHub Desktop.
Save jfinstrom/2d8e17c1c2bf8da07d0a7046382c12e2 to your computer and use it in GitHub Desktop.
Generate a htpasswd file from FreePBX userman group.
#!/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