Non-interactive installs


Is it possible to install gogs non-interactively? That is, without the initial database settings needing to be manually entered. I notice that there’s a mysql.sql template in the scripts directory, but it doesn’t contain any table definitions.


The closest I’ve come with is building a git repo to build gogs and golang from source, however it installs gogs so far as the initial installation screen to make you setup/finalize gogs with your username and password settings.

If you are interested give it a try:

It sets up nginx(on port 80 and 443) in front of gogs(which is listening on localhost port 3000 only) with a self-signed ssl certificate.

Build time roughly 8-10 minutes on Digitalocean’s $5/m plan.


I’m thinking of the final stage where you enter database password and such. If there’s a command where those options can be set then this will make self-hosted installs simpler and reduce the chance of user errors.

I suppose an alternative might be to make a default mysql database, and then change the admin user details with a query.


I am interested on this subject also. The outcome of the non-interactive install (script) can be reused in a post-install action like rpm pkg. I tried out “gogs dump” the other day on my test gogs. It does have sql part to describe existing gogs db and its tables. This can be cleanup to be a template sql( (mysql-default-install.sql)) for fresh install.


I might try modifying install.go to see if I can turn it into a command or accept options.


pls turn install.go into command line code. Currently it is for use with webGUI.


You can generate custom/conf/app.ini directly, that is the file Gogs recognizes if show install page or not.


You can, but the install page remains and it looks like the database has no tables.


Looks like I was just modifying the wrong app.ini. I’ll still need to create an initial admin user though. Presumably passwd in the user table is hashed (and salted?). What algorithm is used for hashing?


The first record in database automatically becomes admin.


Indeed, but how to get that first record non-interactively? Is there any command to add users?


Hmm, no. You would have to hack the database. But have a command to add user can be a feature request to report on GitHub.


I’ve just ran a new install(Gogs Version: on a throwaway Debian 8 with mysql and here are the Database logs(/home/git/go/src/

raw paste:

Database name:


Database user:

Database password:
This seems to be it. Looks like md5 hashing.


[xorm] [info] 2016/05/12 14:57:49.944033 [sql] BEGIN TRANSACTION
[xorm] [info] 2016/05/12 14:57:49.944219 [sql] INSERT INTO user (lower_name,name,full_name,email,passwd,login_type,login_source,login_name,type,location,website,rands,salt,created_unix,updated_unix,last_repo_visibility,max_repo_creation,is_active,is_admin,allow_git_hook,allow_import_local,avatar,avatar_email,use_custom_avatar,num_followers,num_following,num_stars,num_repos,description,num_teams,num_members) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [args] [asd asd asd@asd.asd ff68487527398465ac68ae3db4d806d2eddd78c91573818d3d8dc3b557d4747fa232cc05738af8be36a8f18fb4e4960160fe 0 0 0 mci2niuf5E mJfUIraaL9 1463079469 1463079469 false -1 true true false false 6f370c8c7109534c3d5c394123a477d7 asd@asd.asd false 0 0 0 0 0 0]
[xorm] [info] 2016/05/12 14:57:49.945167 [sql] COMMIT


You’ll have to wade through the junk to see the user creaton part. I’m blind to sql.


Removed junk from here.

Mysql select * from gogs_production.user; (or something like that):


With bash, it would be rather easy.

As root(let’s assume you have root access with ~/.my.cnf file) to mysql:

mysql <<-EOF
use gogs_production;
mysql command here;


That’s ok, but I’d need to generate the password hash, rather than using a fixed default password. For deploying self-hosted systems each has unique passwords generated on first boot, since default passwords are a security risk.


tr -d -c “a-zA-Z0-9” < /dev/urandom | head -c 20 | md5sum | awk ‘{print $1}’

For password generation, I use in my git repo:

tr -d -c “a-zA-Z0-9” < /dev/urandom | head -c 20

You can pipe it into md5sum and just get the first part with awk.


Does Gogs use md5 hashes? It doesn’t look like it from the code. Md5 is weak and was considered broken in 2012.


Hm more likely no, seems the hash is a lot longer than the md5sums generated.

The lead dev have to confirm what it used.


I think I’ve found what mysql queries are used for new user creation and making them admins.

Of course, the question remains how the hash is created. It’s clear it has a salt value.

See my comment here: