forked from tildetown/town
call adduser, usermod
parent
3940fe58ae
commit
6741079152
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/mail"
|
"net/mail"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -260,9 +261,19 @@ Your invite code has not been marked as used and you're welcome to try again, th
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func createUser(data newUserData) error {
|
// TODO add logging like the signup tool has
|
||||||
// TODO adduser
|
|
||||||
// TODO add to town group
|
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 create keyfile by running helper (helper should also make ~/.ssh)
|
||||||
// TODO generate welcome gift
|
// TODO generate welcome gift
|
||||||
// TODO any alerts
|
// TODO any alerts
|
||||||
|
|
Loading…
Reference in New Issue