# Gogs

_The lightweigth github clone_


## Resources

Use command `./gogs help` to list gogs commands.

[Official Gogs documentation](https://gogs.io/docs)

## PostgreSQL setup

### Create gogs user

`$ sudo -u postgres psql`

`postgres=# CREATE ROLE gogs_app WITH CREATEDB LOGIN PASSWORD 'VerySecretPassword';`

### Create gogs database

`postgres=# CREATE DATABASE gogs_db OWNER gogs_app;`

Check database creation : `postgres=# \l`

## Gogs unix user setup

Create _gituser_ :
`$ sudo adduser gituser`

## Start gogs

### Install binaries

The binary of gogs is unziped in `/home/gituser/`

[Download gogs binaries](https://gogs.io/docs/installation/install_from_binary)

### Manually start gogs

Please launch gogs as gituser.

`$ sudo su gituser`

`$ /home/gituser/gogs/gogs web`

### Automate gogs start when computer boots

Find the script to start gogs programmatically in `Install/Templates/startgogs` in this repository. Put at the root of your gogs installation. Then, as _gituser_ :

`$ crontab -e`

And add the line : `@reboot /home/gituser/gogs/startgogs`

### Configure Gogs

When you start Gogs for the first time, Gogs shows a landing page when you can configure your installation.

Then, if you want to tweak your installation, you can do so by modifying the file `custom/conf/app.ini`. For example, you can disable registration by modifying this line to `DISABLE_REGISTRATION   = true`. Then restart the server to reload configuration changes.

## Use ssh

### Add ssh key

Use the gui to add the public ssh key. Go to settings.

### Repository url

Example of repository url using SSH :

`ssh://gituser@192.168.1.35:6666/DricomDragon/CodingGameSolver.git`

## Migrate

### Backup

Gogs natively manages backups. Prefer to use gogs tools instead of _squared wheels_.

`$ ./gogs backup --help`

`$ ./gogs restore --help`

### Repositories

`/home/gituser/gogs/gogs-repositories/`

### Gogs configuration

Your previous installation is marked as old :

`$ mv gogs gogs_old`

Three folders matter :

`$ cp -R gogs_old/{custom,data,log} gogs`

### Database

Backup the `gogs_db` from PostgreSQL.