Document how to create initial admin user #22

Closed
opened 2021-07-15 14:17:39 +00:00 by 3wordchant · 9 comments
Owner
No description provided.
Contributor

Hello,
I juste deployed gitea, unfortunately I don't know how to create the first user. Could you provide some instructionns on how to proceed?
Thank you in advance.

Hello, I juste deployed gitea, unfortunately I don't know how to create the first user. Could you provide some instructionns on how to proceed? Thank you in advance.
Author
Owner

Hey @aileoia, welcome, and thank you for the question!

I had a look at the Gitea command-line documentation, and I think something like this should work:

abra app run git_coopcloud_tech app gitea admin user create --name admin --username admin --password mysecretpassword

(replace git_coopcloud_tech with your app name)

Hey @aileoia, welcome, and thank you for the question! I had a look at the [Gitea command-line documentation](https://docs.gitea.io/en-us/command-line/), and I think something like this should work: `abra app run git_coopcloud_tech app gitea admin user create --name admin --username admin --password mysecretpassword` (replace `git_coopcloud_tech` with your app name)
Contributor

Hello @3wordchant , thanks for the reply.
In the mean time I had the chance to dig a bit and I came up with roughly the same command as the one you suggest and I run into the next problems:
It fails with

2021/12/28 19:19:50 ...s/setting/setting.go:1164:CreateOrAppendToCustomConf() [F] failed to create '/var/lib/gitea/custom/conf/app.ini': mkdir /var/lib/gitea/custom/conf: permission denied

Indeed, if I look at the permissions, I see

$ abra app run <my app name> app ls -l /var/lib/gitea
total 12
dr-x------    2 git      git           4096 Dec 28 19:19 custom
drwxr-xr-x   11 git      git           4096 Dec 28 19:19 data
drwx------    3 git      git           4096 Dec 28 19:19 git

So the folder custom is not writable which is the reason why it is not possible to create the folder above.

If I change the permissions with abra run ... chmod +w /var/lib/gitea/custom and rerun the gitea create ... command, I get

2021/12/28 19:31:14 main.go:117:main() [F] Failed to run app with [gitea admin user create --username xxx --admin --random-password --email xxx]: models.SetEngine: Failed to connect to database: Unknown database type: 
FATA[0005] Status: , Code: 1

I'm not sure what's the issue. I remember I had managed to serve a gitea with a simple compose file and it had worked... maybe something with the compose-file?

Thank you so much for developping all this! If I can help, I'd be glad to!

Hello @3wordchant , thanks for the reply. In the mean time I had the chance to dig a bit and I came up with roughly the same command as the one you suggest and I run into the next problems: It fails with ``` 2021/12/28 19:19:50 ...s/setting/setting.go:1164:CreateOrAppendToCustomConf() [F] failed to create '/var/lib/gitea/custom/conf/app.ini': mkdir /var/lib/gitea/custom/conf: permission denied ``` Indeed, if I look at the permissions, I see ``` $ abra app run <my app name> app ls -l /var/lib/gitea total 12 dr-x------ 2 git git 4096 Dec 28 19:19 custom drwxr-xr-x 11 git git 4096 Dec 28 19:19 data drwx------ 3 git git 4096 Dec 28 19:19 git ``` So the folder `custom` is not writable which is the reason why it is not possible to create the folder above. If I change the permissions with `abra run ... chmod +w /var/lib/gitea/custom` and rerun the `gitea create ...` command, I get ``` 2021/12/28 19:31:14 main.go:117:main() [F] Failed to run app with [gitea admin user create --username xxx --admin --random-password --email xxx]: models.SetEngine: Failed to connect to database: Unknown database type: FATA[0005] Status: , Code: 1 ``` I'm not sure what's the issue. I remember I had managed to serve a gitea with a simple compose file and it had worked... maybe something with the compose-file? Thank you so much for developping all this! If I can help, I'd be glad to!
Author
Owner

@aileoia you are definitely helping already 😁 Thank you!

It looks like it's necessary to provide the path to the Gitea config, maybe it's non-standard? This indeed doesn't work for me:

bash-5.1$ gitea admin user list
2021/12/29 09:22:29 ...s/setting/setting.go:569:NewContext() [W] Custom config '/var/lib/gitea/custom/conf/app.ini' not found, ignore this if you're running first time
2021/12/29 09:22:29 ...s/setting/setting.go:1164:CreateOrAppendToCustomConf() [F] failed to create '/var/lib/gitea/custom/conf/app.ini': mkdir /var/lib/gitea/custom/conf: permission denied

but this does:

bash-5.1$ gitea -c /etc/gitea/app.ini admin user list
2021/12/29 09:23:11 models/user.go:236:GetAllUsers() [I] [SQL] SELECT `id`, `lower_name`, `name`, `full_name`, `email`, `keep_email_private`, `email_notifications_preference`, `passwd`, `passwd_hash_algo`, `must_change_password`, `login_type`, `login_source`, `login_name`, `type`, `location`, `website`, `rands`, `salt`, `language`, `description`, `created_unix`, `updated_unix`, `last_login_unix`, `last_repo_visibility`, `max_repo_creation`, `is_active`, `is_admin`, `is_restricted`, `allow_git_hook`, `allow_import_local`, `allow_create_organization`, `prohibit_login`, `avatar`, `avatar_email`, `use_custom_avatar`, `num_followers`, `num_following`, `num_stars`, `num_repos`, `num_teams`, `num_members`, `visibility`, `repo_admin_change_team_access`, `diff_view_style`, `theme`, `keep_activity_private` FROM `user` WHERE (type = ?) ORDER BY id [0] - 4.737154ms
ID   Username      Email                        IsActive IsAdmin
1    coopcloud     helo@autonomic.zone          true     true

Does adding -c /etc/gitea/app.ini work for you too?

@aileoia you are definitely helping already 😁 Thank you! It looks like it's necessary to provide the path to the Gitea config, maybe it's non-standard? This indeed doesn't work for me: ``` bash-5.1$ gitea admin user list 2021/12/29 09:22:29 ...s/setting/setting.go:569:NewContext() [W] Custom config '/var/lib/gitea/custom/conf/app.ini' not found, ignore this if you're running first time 2021/12/29 09:22:29 ...s/setting/setting.go:1164:CreateOrAppendToCustomConf() [F] failed to create '/var/lib/gitea/custom/conf/app.ini': mkdir /var/lib/gitea/custom/conf: permission denied ``` but this does: ``` bash-5.1$ gitea -c /etc/gitea/app.ini admin user list 2021/12/29 09:23:11 models/user.go:236:GetAllUsers() [I] [SQL] SELECT `id`, `lower_name`, `name`, `full_name`, `email`, `keep_email_private`, `email_notifications_preference`, `passwd`, `passwd_hash_algo`, `must_change_password`, `login_type`, `login_source`, `login_name`, `type`, `location`, `website`, `rands`, `salt`, `language`, `description`, `created_unix`, `updated_unix`, `last_login_unix`, `last_repo_visibility`, `max_repo_creation`, `is_active`, `is_admin`, `is_restricted`, `allow_git_hook`, `allow_import_local`, `allow_create_organization`, `prohibit_login`, `avatar`, `avatar_email`, `use_custom_avatar`, `num_followers`, `num_following`, `num_stars`, `num_repos`, `num_teams`, `num_members`, `visibility`, `repo_admin_change_team_access`, `diff_view_style`, `theme`, `keep_activity_private` FROM `user` WHERE (type = ?) ORDER BY id [0] - 4.737154ms ID Username Email IsActive IsAdmin 1 coopcloud helo@autonomic.zone true true ``` Does adding `-c /etc/gitea/app.ini` work for you too?
Contributor

I confirm that it works:

$ abra app run git app gitea -c /etc/gitea/app.ini admin user list
ID   Username Email IsActive IsAdmin

I'll now try to create an admin user.

I confirm that it works: ``` $ abra app run git app gitea -c /etc/gitea/app.ini admin user list ID Username Email IsActive IsAdmin ``` I'll now try to create an admin user.
Contributor

worked, with the -c /etc/gitea/app.ini

Thanks!

worked, with the `-c /etc/gitea/app.ini` Thanks!
Contributor

Does it mean something for this repo?
Should I make a PR updating at least the README?
Is there a way to easily create a new user with abra? Or maybe generate the password for the first user along with the other secrets, as for nextcloud?

Does it mean something for this repo? Should I make a PR updating at least the README? Is there a way to easily create a new user with `abra`? Or maybe generate the password for the first user along with the other secrets, as for nextcloud?
Author
Owner

Incredible, thank you! I'll review the PR soon. I do half-remember something about creating an initial user using an environment variable, I'll do some research unless you beat me to it 💪

Incredible, thank you! I'll review the PR soon. I do half-remember something about creating an initial user using an environment variable, I'll do some research unless you beat me to it 💪
Contributor

I think this issue can be closed :)

I think this issue can be closed :)
Sign in to join this conversation.
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: coop-cloud/gitea#22
No description provided.