Instalar Gitea en Raspberry Pi
410 views
Raspberry con raspbian actualizado.
Pasos Previos
sudo apt-get install git mysql-server -y
Creamo un usuario llamado ‘Gitea‘ y deshabilitamos su inicio de sesión:
sudo adduser --disabled-login --gecos 'Gitea' git
Preparación MySQL
Ejecutamos
sudo mysql_secure_installation
Ahora, creamos la base de datos:
sudo mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 21 Server version: 10.1.37-MariaDB-0+deb9u1 Raspbian 9.0 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> CREATE DATABASE gitea; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@'localhost' IDENTIFIED BY 'ENTERPASSWORD'; Query OK, 0 rows affected (0.01 sec) MariaDB [(none)]> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> exit Bye
Instalar Gitea
pi@raspberrypi:~ $ sudo su git git@raspberrypi:/home/pi $ cd ~ git@raspberrypi:~ $ mkdir gitea git@raspberrypi:~ $ cd gitea git@raspberrypi:~/gitea $ wget https://dl.gitea.io/gitea/master/gitea-master-linux-arm-7 --2018-12-03 10:59:07-- https://dl.gitea.io/gitea/master/gitea-master-linux-arm-7 Resolviendo dl.gitea.io (dl.gitea.io)... 104.27.143.155, 104.27.142.155, 2606:4700:30::681b:8f9b, ... Conectando con dl.gitea.io (dl.gitea.io)[104.27.143.155]:443... conectado. Petición HTTP enviada, esperando respuesta... 200 OK Longitud: 54850764 (52M) [application/octet-stream] Grabando a: “gitea-master-linux-arm-7” gitea-master-linux-arm-7 100%[==============================================>] 52,31M 837KB/s in 62s 2018-12-03 11:00:10 (869 KB/s) - “gitea-master-linux-arm-7” guardado [54850764/54850764] git@raspberrypi:~/gitea $ chmod +x gitea-master-linux-arm-7 git@raspberrypi:~/gitea $ mv gitea-master-linux-arm-7 gitea git@raspberrypi:~/gitea $ ./gitea
Ahora, ya podremos acceder a http://IP-DE-LA-RASPBERRY:3000 y veremos la interfaz de gitea.
Pero lo que necesitamos es que se arranque automáticamente al iniciar la raspberry, así que creamos el archivo gitea.service:
sudo nano /etc/systemd/system/gitea.service
Y copiamos las siguientes líneas en el archivo y guardamos:
[Unit] Description=Gitea (Git with a cup of tea) After=syslog.target After=network.target [Service] # Modify these two values and uncomment them if you have # repos with lots of files and get to HTTP error 500 because of that ### # LimitMEMLOCK=infinity # LimitNOFILE=65535 RestartSec=2s Type=simple User=git Group=git WorkingDirectory=/home/git/gitea ExecStart=/home/git/gitea/gitea web Restart=always Environment=USER=git HOME=/home/git [Install] WantedBy=multi-user.target
Luego, habilitamos e iniciamos el servicio:
sudo systemctl enable gitea.service sudo systemctl start gitea.service
Si vamos a la interfaz web http://IP-DE-LA-RASPBERRY:3000 veremos:
Y si hacemos click en «Register» accederemos a la configuración inicial.
En esta configuración incial ya tendremos todas las opciones rellenadas, menos la del password para la base de datos. Ponemos el password que hemos creado en el paso
MariaDB [(none)]> GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@'localhost' IDENTIFIED BY 'ENTERPASSWORD';
de más arriba.
También podemos crear un usuario administrador desde esta pantalla, pero, si no lo hacemos, el primer usuario registrado será el administrador del site.
Si obtenemos el error The database settings are invalid: Error 1071: Specified key was too long; max key length is 767 bytes
Deberemos hacer:
sudo mysql -u root -p MariaDB [(none)]> use gitea; MariaDB [gitea]> ALTER DATABASE gitea CHARACTER SET utf8 COLLATE utf8_unicode_ci; Query OK, 1 row affected (0.00 sec) MariaDB [gitea]> ALTER TABLE user CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci; Query OK, 0 rows affected (8.86 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [gitea]> exit Bye
Ejecutar gitea en el puerto 80
Si intenamos configurar gitea para ejecutarse en el puerto 80, obtendremos errores del tipo:
2018/12/03 13:03:31 [I] Log Mode: File(Info) 2018/12/03 13:03:31 [I] XORM Log Mode: File(Info) 2018/12/03 13:03:31 [I] Cache Service Enabled 2018/12/03 13:03:31 [I] Session Service Enabled 2018/12/03 13:03:32 [I] Git Version: 2.11.0 2018/12/03 13:03:32 [I] SQLite3 Supported 2018/12/03 13:03:32 [I] Run Mode: Production 2018/12/03 13:03:34 [I] Listen: http://0.0.0.0:88 2018/12/03 13:03:34 [I] LFS server enabled 2018/12/03 13:03:34 [....io/gitea/cmd/web.go:211 runWeb()] [E] Failed to start server: listen tcp 0.0.0.0:88: bind: permission denied
Para solucionar el problema, ejecutaremos:
sudo setcap 'cap_net_bind_service=+ep' /home/git/gitea/gitea
Ahora si, si configuramos gitea para ejecutarse en el puerto 80:
sudo nano /home/git/gitea/custom/conf/app.ini ... [server] SSH_DOMAIN = localhost DOMAIN = localhost HTTP_PORT = 80 ROOT_URL = http://localhost:80 ...