diff --git a/cmd/welcome/main.go b/cmd/welcome/main.go index 4b61ffc..84f1ef9 100644 --- a/cmd/welcome/main.go +++ b/cmd/welcome/main.go @@ -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