====== Gogs ====== ===== Installation ===== ${shell}:~$ sudo apt-get install postgresql postgresql-contrib ${shell}:~$ sudo apt-get install mercurial git ${shell}:~$ wget https://dl.gogs.io/0.11.66/gogs_0.11.66_linux_amd64.tar.gz ${shell}:~$ tar -zxf gogs_0.11.66_linux_amd64.tar.gz ${shell}:~$ mv gogs* /opt/gogs ${shell}:~$ sudo chown $USER:$USER /opt/gogs -R ## test installation ${shell}:~$ /opt/gogs/gogs web ${shell}:~$ curl localhost:3000 ===== Setup ===== See [[selfhosted:psql|PostgreSQL]] to - install - create user - create databases - grant user privileges to the databases See [[selfhosted:apache|APACHE]] to install, configure, and enable site Configuration file: /etc/apache2/sites-available/gogs.conf http: DocumentRoot /var/www/html/gogs/ ServerName localhost Options +FollowSymLinks AllowOverride All Require all granted Dav off SetEnv HOME /var/www/html/gogs SetEnv HTTP_HOME /var/www/html/gogs ProxyPreserveHost on ProxyRequests off ProxyPass / http://127.0.0.1:3000 ProxyPassReverse / http://127.0.0.1:3000 ErrorLog ${APACHE_LOG_DIR}/gogs_error.log CustomLog ${APACHE_LOG_DIR}/gogs_access.log combined https: DocumentRoot /var/www/html/gogs/ ServerName localhost ErrorLog ${APACHE_LOG_DIR}/gogs_error.log CustomLog ${APACHE_LOG_DIR}/gogs_access.log combined RewriteEngine on RewriteCond %{HTTPS} off RewriteRule (.*) https://${HTTP_HOST}%{REQUEST_URI} [R] DocumentRoot /var/www/html/gogs/ ServerName localhost ErrorLog ${APACHE_LOG_DIR}/gogs_error.log CustomLog ${APACHE_LOG_DIR}/gogs_access.log combined SSLEngine On SSLCertificateFile /etc/apache2/ssl/crt/gogs.crt SSLCertificateKeyFile /etc/apache2/ssl/key/gogs.key SSLRequireSSL On SSLVerifyClient optional SSLVerifyDepth 1 SSLOptions +StdEnvVars +StrictRequire Options +FollowSymLinks AllowOverride All Require all granted Dav off SetEnv HOME /var/www/html/gogs SetEnv HTTP_HOME /var/www/html/gogs ProxyPreserveHost on ProxyRequests off ProxyPass / http://127.0.0.1:3000 ProxyPassReverse / http://127.0.0.1:3000 autostart: ## add init info for LSB tags and overrides $ sudo nano /etc/init.d/gogs < /etc/init.d/gogs > #!/bin/bash ### BEGIN INIT INFO # Provides: gogs # Required-Start: $local_fs $network postgresql # Required-Stop: $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: gogs # Description: gogs pop & imap daemon ### END INIT INFO PID=`id -u user1` PIDFILE=/var/run/gogs.pid WORKDIR="/opt/gogs" CMD=`su $USERNAME - -c "cd $WORKDIR; PATH=$PATH:$WORKDIR gogs web"` case "$1" in start) start-stop-daemon --start --user $PID --pidfile $PIDFILE --chuid $PID --exec $CMD ;; stop) start-stop-daemon --stop --user $PID --pidfile $PIDFILE --chuid $PID ;; esac exit 0 $ sudo chmod +x /etc/init.d/gogs $ sudo nano /lib/systemd/system/gogs.service < /lib/systemd/system/gogs.service > [Unit] Description=Gogs After=postgresql.service [Service] Type=oneshot ExecStart=/etc/init.d/gogs start RemainAfterExit=no User=user1 Group=user1 [Install] WantedBy=multi-user.target $ sudo update-rc.d gogs defaults $ sudo systemctl enable gogs ===== Misc ===== ## backup $ /opt/gogs/gogs backup $ PGPASSWORD="62oCDajIgcjSXgCumh2A" pg_dump -c -d gogs -U gogsuser -h localhost > /home/user1/Documents/Backups/databases/dump_gogs_`date +%Y-%m-%d`.sql ## restore $ /opt/gogs/gogs restore $ psql -d gogs -f /home/user1/Documents/Backups/databases/dump_gogs_`date +%Y-%m-%d`.sql ## $psql gogs < /home/user1/Documents/Backups/databases/dump_gogs_`date +%Y-%m-%d`.sql ===== Errors ===== ## empty repository showing in gogs ## fix: change IS_BARE field of the REPOSITORY table to f $ psql --host=localhost --dbname=gogs --username=gogsuser --password psql~$ \d+ repository psql~$ UPDATE repository SET is_bare = 'f' WHERE is_bare = 't';