|
|
|
|
@ -131,6 +131,16 @@ final class neato { |
|
|
|
|
return $exit_code; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static function groupadd(string $groupname, int $gid = 0) { |
|
|
|
|
$group_id = ($gid > 0) ? "-g {$gid} " : ""; |
|
|
|
|
exec(self::get_super_user_bin . 'groupadd '. $group_id . safe_cmd($groupname), $output, $exit_code); |
|
|
|
|
if ($exit_code === true || $exit_code === 0) { |
|
|
|
|
display(getTermColors("Added new group named: $groupname", ['color'=>'green'])); |
|
|
|
|
} |
|
|
|
|
check_for_error($exit_code, "Unable to add new group: {$groupname}"); |
|
|
|
|
return $exit_code; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static function userdel(string $username) { |
|
|
|
|
exec(self::get_super_user_bin . 'userdel ' . safe_cmd($username), $output, $exit_code); |
|
|
|
|
if ($exit_code === true || $exit_code === 0) { |
|
|
|
|
@ -140,9 +150,13 @@ final class neato { |
|
|
|
|
return $exit_code; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static function useradd(string $username, string $shell="/bin/bash", string $comment = "", string $groups="", string $homedir="") { |
|
|
|
|
public static function useradd(string $username, int $uid = 0, string $shell="/bin/bash", string $comment = "", string $groups="", string $homedir="") { |
|
|
|
|
$user_id = ($uid > 0) ? "-u {$uid} " : ""; |
|
|
|
|
$dir = (empty($homedir)) ? " -m " : " -d " . safe_cmd($homedir); |
|
|
|
|
exec(self::get_super_user_bin . 'useradd -s '. safe_cmd($shell) . $dir . ' -c '. safe_cmd($comment) .'-G'. safe_cmd($groups) . ' ' . safe_cmd($username), $output, $exit_code); |
|
|
|
|
exec(self::get_super_user_bin . 'useradd '. $user_id . '-s '. safe_cmd($shell) . $dir . ' -c '. safe_cmd($comment) .'-G'. safe_cmd($groups) . ' ' . safe_cmd($username), $output, $exit_code); |
|
|
|
|
if ($exit_code === true || $exit_code === 0) { |
|
|
|
|
display(getTermColors("Added new user account named: $username", ['color'=>'green'])); |
|
|
|
|
} |
|
|
|
|
check_for_error($exit_code, "Unable to add new user: {$username}"); |
|
|
|
|
return $exit_code; |
|
|
|
|
} |
|
|
|
|
|