Compare commits
2 Commits
4847c19eaf
...
6741079152
Author | SHA1 | Date |
---|---|---|
vilmibm | 6741079152 | |
vilmibm | 3940fe58ae |
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/mail"
|
"net/mail"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -244,12 +245,41 @@ func _main() error {
|
||||||
s = s.SetString("cool, awesome, going to make your account now...")
|
s = s.SetString("cool, awesome, going to make your account now...")
|
||||||
fmt.Println(s)
|
fmt.Println(s)
|
||||||
|
|
||||||
// TODO have enough to make account; can now do that
|
if err = createUser(*data); err != nil {
|
||||||
|
s = s.SetString(fmt.Sprintf(`augh, I'm sorry. the account creation failed.
|
||||||
|
Please email root@tilde.town and paste the following error:
|
||||||
|
|
||||||
|
%s
|
||||||
|
|
||||||
|
Your invite code has not been marked as used and you're welcome to try again, though if there is a system issue you might need to wait for word from an admin.`, err.Error()))
|
||||||
|
fmt.Println(s)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// TODO assuming account creation succeeded, mark invite as used
|
// TODO assuming account creation succeeded, mark invite as used
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
return errors.New("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// TODO friendlier error handling
|
// TODO friendlier error handling
|
||||||
err := _main()
|
err := _main()
|
||||||
|
|
Loading…
Reference in New Issue