call adduser, usermod

trunk
vilmibm 2023-03-03 21:39:36 +00:00
parent 3940fe58ae
commit 6741079152
1 changed files with 14 additions and 3 deletions

View File

@ -5,6 +5,7 @@ import (
"fmt"
"net/mail"
"os"
"os/exec"
"regexp"
"strings"
@ -260,9 +261,19 @@ Your invite code has not been marked as used and you're welcome to try again, th
return nil
}
func createUser(data newUserData) error {
// TODO adduser
// TODO add to town group
// TODO add logging like the signup tool has
func createUser(data newUserData) (err error) {
cmd := exec.Command("sudo", "/usr/sbin/adduser", "--quiet", "--disabled-password", data.Username)
if err = cmd.Run(); err != nil {
return fmt.Errorf("adduser failed: %w", err)
}
cmd = exec.Command("sudo", "/usr/sbin/usermod", "-a", "-G", "town", data.Username)
if err = cmd.Run(); err != nil {
return fmt.Errorf("usermod failed: %w", err)
}
// TODO create keyfile by running helper (helper should also make ~/.ssh)
// TODO generate welcome gift
// TODO any alerts