public void doOperation() throws OpsException {
OpsTarget target = OpsContext.get().getInstance(OpsTarget.class);
// TODO: Only if user not found
{
Command command = Command.build("adduser");
command.addLiteral("--system");
command.addLiteral("--no-create-home");
if (shell != null) {
command.addLiteral("--shell").addFile(shell);
}
if (!Strings.isNullOrEmpty(primaryGroup)) {
command.addLiteral("--ingroup");
command.addQuoted(primaryGroup);
}
command.addQuoted(userName);
target.executeCommand(command);
}
for (String secondaryGroup : secondaryGroups) {
Command command = Command.build("adduser");
command.addQuoted(userName);
command.addQuoted(secondaryGroup);
target.executeCommand(command);
}
}