Starting migration from gogs to gitea

Gitea is a more trustable project.
This commit is contained in:
Philippe Caseiro 2018-10-30 14:50:33 +01:00
parent 40547fc477
commit 7ef72a70df
14 changed files with 303 additions and 167 deletions

View File

@ -2,9 +2,9 @@
# Makefile pour eole-gogs
################################
SOURCE=eole-gogs
VERSION=0.6.1
EOLE_VERSION=2.4
SOURCE=eole-gitea
VERSION=1.5.2
EOLE_VERSION=2.6.2
PKGAPPS=non
#FLASK_MODULE=<APPLICATION>

109
dicos/50_gitea.xml Normal file
View File

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8"?>
<creole>
<files>
<!-- Je suis un commentaire -->
<file filelist='gitea-nginx' name='/etc/nginx/sites-available/gitea' source='gitea.nginx' mkdir='True' rm='True'/>
<file filelist='gitea' name='/usr/share/eole/bastion/data/51-gitea-nat_rules' mkdir='True' rm='True' mode='0755'/>
<file filelist='gitea' name='/usr/share/eole/mysql/eole-gitea/gen/00-create-gitea-db.sql' mkdir='True' rm='True'/>
<service_access service='gitea_with_nginx'>
<port service_accesslist="gitea_with_nginx">443</port>
</service_access>
</files>
<containers>
<container name='forge' id='101'>
<package>apt-transport-https</package>
<package>git-core</package>
<!-- FIXME this have to be installed <package>gitea</package> -->
<file filelist='gitea' name='/etc/gitea/conf/app.ini' source='gitea.conf' mkdir='True' rm='True'/>
<!-- <service servicelist='xxxx'>nom-du-service-a-lancer-dans-le-conteneur</service> -->
<service servicelist='gitea'>forge</service>
<service_access service='gitea_without_nginx'>
<port service_accesslist="gitea_without_nginx" port_type="SymLinkOption">gitea_http_port</port>
</service_access>
<service_access service='gitea_ssh'>
<tcpwrapper>sshd</tcpwrapper>
</service_access>
</container>
</containers>
<variables>
<family name='services'>
<variable name='activer_gitea' type='oui/non' description='Activer la forge Gitea'>
<value>non</value>
</variable>
</family>
<family name='forge'>
<variable name='gitea_name' type='string' description='Nom de la forge' mandatory='True'>
<value>Forge Numérique EOLE</value>
</variable>
<variable name='gitea_mail' type='oui/non' description="Activer l'envois de courriels">
<value>non</value>
</variable>
<variable name='gitea_mail_from' type='string' description="Adresse courriel a l'origine des messages de la forge"/>
<variable name='gitea_mail_auth' type='oui/non' description="Utiliser un compte pour le serveur smtp">
<value>non</value>
</variable>
<variable name='gitea_email_user' type='string' description="Nom de l'utilisateur SMTP"/>
<variable name='gitea_email_password' type='string' description="Mot de passe de l'utilisateur"/>
<variable name='gitea_web_name' type='string' description='Nom DNS de la forge' mandatory='True'/>
<variable name='git_root' type='string' description='Repertoire des dépôts git' mandatory='True'>
<value>/var/db/gitea/repo</value>
</variable>
<variable name='gitea_registration' type='oui/non' description="Les utilisateurs peuvent s'enregistrer">
<value>non</value>
</variable>
<variable name='gitea_http_port' type='string' description='Port HTTP pour la forge' mode='expert'>
<value>6000</value>
</variable>
<variable name='gitea_ssh_port' type='string' description='Port SSH pour la forge' mode='expert'>
<value>2222</value>
</variable>
<variable name='gitea_db_file' type='string' description='Fichier de base de données' mode='expert'>
<value>/var/db/gitea/gitea.db</value>
</variable>
<variable name='gitea_domain' type='string' description='Domaine git ... fixme ...' mode='expert'>
<value>localhost</value>
</variable>
<variable name='gitea_nginx' type='oui/non' hidden='True'/>
</family>
</variables>
<constraints>
<condition name='hidden_if_in' source='gitea_mail'>
<param>non</param>
<target type='variable'>gitea_mail_from</target>
</condition>
<condition name='disabled_if_in' source='activer_gitea'>
<param>non</param>
<target type='filelist'>gitea</target>
<target type='filelist'>gitea-nginx</target>
<target type='servicelist'>gitea</target>
<target type='family'>forge</target>
<target type='service_accesslist'>gitea_ssh</target>
</condition>
<condition name='disabled_if_in' source='gitea_mail_auth'>
<param>non</param>
<target type='variable'>gitea_email_user</target>
<target type='variable'>gitea_email_password</target>
</condition>
<fill name='calc_multi_condition' target='gitea_nginx'>
<param>oui</param>
<param name="operator">OR</param>
<param type="eole" name="condition_1" optional="True">activer_revprox</param>
<param name="condition_2">non</param>
<param name='match'>oui</param>
<param name='mismatch'>non</param>
</fill>
<condition name='disabled_if_in' source='gitea_nginx'>
<param>non</param>
<target type='filelist'>gitea-nginx</target>
<target type='service_accesslist'>gitea_with_nginx</target>
</condition>
<condition name='disabled_if_in' source='gitea_nginx'>
<param>oui</param>
<target type='service_accesslist'>gitea_without_nginx</target>
</condition>
</constraints>
<help>
<variable name='activer_gitea'>Activer la forge Gitea, Gitea est une forge basée sur Git clone de github (fork de gogs)</variable>
</help>
</creole>

View File

@ -1,108 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<creole>
<files>
<!-- Je suis un commentaire -->
<file filelist='gogs-nginx' name='/etc/nginx/sites-available/gogs' source='gogs.nginx' mkdir='True' rm='True'/>
<file filelist='gogs' name='/usr/share/eole/bastion/data/51-gogs-nat_rules' mkdir='True' rm='True' mode='0755'/>
<file filelist='gogs' name='/usr/share/eole/mysql/eole-gogs/gen/00-create-gogs-db.sql' mkdir='True' rm='True'/>
<service_access service='gogs_with_nginx'>
<port service_accesslist="gogs_with_nginx">443</port>
</service_access>
</files>
<containers>
<container name='forge' id='101'>
<package>apt-transport-https</package>
<!-- FIXME this have to be installed <package>gogs</package> -->
<file filelist='gogs' name='/etc/gogs/conf/app.ini' source='gogs.conf' mkdir='True' rm='True'/>
<!-- <service servicelist='xxxx'>nom-du-service-a-lancer-dans-le-conteneur</service> -->
<service servicelist='gogs'>gogs</service>
<service_access service='gogs_without_nginx'>
<port service_accesslist="gogs_without_nginx" port_type="SymLinkOption">git_http_port</port>
</service_access>
<service_access service='gogs_ssh'>
<tcpwrapper>sshd</tcpwrapper>
</service_access>
</container>
</containers>
<variables>
<family name='services'>
<variable name='activer_gogs' type='oui/non' description='Activer la forge Gogs'>
<value>non</value>
</variable>
</family>
<family name='forge'>
<variable name='gogs_name' type='string' description='Nom de la forge' mandatory='True'>
<value>Forge Numérique EOLE</value>
</variable>
<variable name='gogs_mail' type='oui/non' description="Activer l'envois de courriels">
<value>non</value>
</variable>
<variable name='gogs_mail_from' type='string' description="Adresse courriel a l'origine des messages de la forge"/>
<variable name='gogs_mail_auth' type='oui/non' description="Utiliser un compte pour le serveur smtp">
<value>non</value>
</variable>
<variable name='gogs_email_user' type='string' description="Nom de l'utilisateur SMTP"/>
<variable name='gogs_email_password' type='string' description="Mot de passe de l'utilisateur"/>
<variable name='gogs_web_name' type='string' description='Nom DNS de la forge' mandatory='True'/>
<variable name='git_root' type='string' description='Repertoire des dépôts git' mandatory='True'>
<value>/var/db/gogs/repo</value>
</variable>
<variable name='gogs_registration' type='oui/non' description="Les utilisateurs peuvent s'enregistrer">
<value>non</value>
</variable>
<variable name='git_http_port' type='string' description='Port HTTP pour la forge' mode='expert'>
<value>6000</value>
</variable>
<variable name='git_ssh_port' type='string' description='Port SSH pour la forge' mode='expert'>
<value>2222</value>
</variable>
<variable name='gogs_db_file' type='string' description='Fichier de base de données' mode='expert'>
<value>/var/db/gogs/gogs.db</value>
</variable>
<variable name='git_domain' type='string' description='Domaine git ... fixme ...' mode='expert'>
<value>localhost</value>
</variable>
<variable name='gogs_nginx' type='oui/non' hidden='True'/>
</family>
</variables>
<constraints>
<condition name='hidden_if_in' source='gogs_mail'>
<param>non</param>
<target type='variable'>gogs_mail_from</target>
</condition>
<condition name='disabled_if_in' source='activer_gogs'>
<param>non</param>
<target type='filelist'>gogs</target>
<target type='filelist'>gogs-nginx</target>
<target type='servicelist'>gogs</target>
<target type='family'>forge</target>
<target type='service_accesslist'>gogs_ssh</target>
</condition>
<condition name='disabled_if_in' source='gogs_mail_auth'>
<param>non</param>
<target type='variable'>gogs_email_user</target>
<target type='variable'>gogs_email_password</target>
</condition>
<fill name='calc_multi_condition' target='gogs_nginx'>
<param>oui</param>
<param name="operator">OR</param>
<param type="eole" name="condition_1" optional="True">activer_revprox</param>
<param name="condition_2">non</param>
<param name='match'>oui</param>
<param name='mismatch'>non</param>
</fill>
<condition name='disabled_if_in' source='gogs_nginx'>
<param>non</param>
<target type='filelist'>gogs-nginx</target>
<target type='service_accesslist'>gogs_with_nginx</target>
</condition>
<condition name='disabled_if_in' source='gogs_nginx'>
<param>oui</param>
<target type='service_accesslist'>gogs_without_nginx</target>
</condition>
</constraints>
<help>
<variable name='activer_gogs'>Activer la forge gogs, gogs est une forge basée sur Git clone de github</variable>
</help>
</creole>

1
eole-gitea.mk Normal file
View File

@ -0,0 +1 @@
systemd_DATA_DIR := $(DESTDIR)/etc/systemd/system

94
pretemplate/01-gitea-init Executable file
View File

@ -0,0 +1,94 @@
#!/bin/bash
# Install and initialize gitea
# Variables
WKDIR="/srv/forge"
USER="git"
GROUP="gitservice"
GECOS="Gitea User"
USERSHELL="/bin/bash"
HOMEDIR="${WKDIR}/${USER}"
OS="linux"
ARCH="amd64"
APPVERSION="1.5.2"
APPNAME="gitea"
APPBINARY="gitea"
APPSIG="7C9E68152594688862D62AF62D9AE806EC1592E2"
APPASC="${APPNAME}-${APPVERSION}-${OS}-${ARCH}.asc"
KEYSERV="pgp.mit.edu"
DLSERV="dl.gitea.io"
APPDIR="${WKDIR}/gitea"
APPBINDIR="${APPDIR}/bin"
APPCONFDIR="/etc/${APPNAME}"
if [[ -d ${APPCONFDIR} ]]
then
exit 0
fi
proxy=$(CreoleGet activer_proxy_client non)
if [[ ${proxy} == "oui" ]]
then
prAddr=$(CreoleGet proxy_client_adresse)
prPort=$(CreoleGet proxy_client_port)
export HTTP_PROXY=http://${prAddr}:${prPort}
export http_proxy=http://${prAddr}:${prPort}
export HTTPS_PROXY=http://${prAddr}:${prPort}
export https_proxy=http://${prAddr}:${prPort}
fi
if [[ ! -d ${APPDIR} ]]
then
mkdir -p ${APPDIR}
fi
# Create app user and group
groupadd ${GROUP}
adduser \
--shell ${USERSHELL} \
--gecos "${GECOS}" \
--ingroup ${GROUP} \
--disabled-password \
--home ${HOMEDIR} \
${USER}
# Create app structure
mkdir -p ${APPDIR}/{custom,data,indexers,public,log}
chown ${USER}:${GROUP} ${APPDIR}/{data,indexers,log}
chmod 750 ${APPDIR}/{data,indexers,log}
mkdir ${APPCONFDIR}
chown root:${GROUP} ${APPCONFDIR}
chmod 770 ${APPCONFDIR}
if [[ ! -d ${APPBINDIR} ]]
then
mkdir -p ${APPBINDIR}
fi
cd $APPBINDIR
if [[ ! -f ${APPBINARY} ]]
then
wget -O ${APPBINARY} https://${DLSERV}/${APPNAME}/${APPVERSION}/${APPNAME}-${APPVERSION}-${OS}-${ARCH}
if [[ $? -eq 0 ]]
then
chmod +x ${APPBINARY}
else
echo "Error downloading binary for ${APPNAME}"
return 123
fi
fi
if [[ ! -f ${APPASC} ]]
then
wget -O ${APPASC} https://${DLSERV}/${APPNAME}/${APPVERSION}/${APPASC}
gpg --keyserver ${KEYSERV} --recv ${APPSIG}
gpg --verify ${APPNAME}-${APPVERSION}-${OS}-${ARCH}.asc ${APPBINARY}
fi
cd -

View File

@ -1,22 +0,0 @@
#-*-coding:utf-8-*-
###########################################################################
#
# mon_appli.py
#
###########################################################################
"""
Configuration pour la création de la base de données de mon appli
"""
from eolesql.db_test import db_exists, test_var
gogs_TABLEFILENAMES = [ '/usr/share/eole/mysql/eole-gogs/gen/00-create-gogs-db.sql' ]
def test():
"""
test l'existence de la base de donnée zarafa
"""
return test_var('activer_gogs') and not db_exists('gogs')
conf_dict = dict(filenames=gogs_TABLEFILENAMES,
test=test)

View File

@ -1,5 +0,0 @@
[gogs]
username=gogs
template=PASSWD=
container=forge
filename=/etc/gogs/conf/app.ini

25
systemd/forge.service Normal file
View File

@ -0,0 +1,25 @@
[Unit]
Description=Forge Gitea (Git with a cup of tea)
After=syslog.target
After=network.target
After=mysqld.service
After=postgresql.service
After=memcached.service
After=redis.service
[Service]
#LimitMEMLOCK=infinity
#LimitNOFILE=65535
RestartSec=2s
Type=simple
User=git
Group=gitservice
WorkingDirectory=/srv/forge/gitea/bin/gitea
ExecStart=/srv/forge/gitea/bin/gitea/gitea web
Restart=always
Environment=USER=git HOME=/srv/forge/git
#CapabilityBoundingSet=CAP_NET_BIND_SERVICE
#AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target

41
tmpl/gitea-db.yml Normal file
View File

@ -0,0 +1,41 @@
---
%set dmode = %%getVar('gitea_db_mode','non')
%if %%dmode == "externe"
dbhost: %%gitea_dbserver
dbport: %%gitea_dbport
dbroot: %%gitea_dbuser
dbrootpwd: %%gitea_dbpass
%else if %%dmode == "local"
dbhost: 127.0.0.1
%end if
dbtype: mysql
dbname: gitea
dbuser: gitea
dbpass: "changeme"
%set allow_hosts = %%getVar('gitea_allow_hosts', '')
%if %%dmode == "local"
client_hosts: ["127.0.0.1", "localhost" %slurp
%else if %%dmode == "externe"
client_hosts: ["%%adresse_ip_eth0" %slurp
%end if
%if %%dmode != "default"
%if %%is_empty(%%allow_hosts)
]
%else
%for %%hst in %%allow_hosts
,"%%hst" %slurp
%end for
]
%end if
%end if
createscript: "/usr/share/eole/db/gitea/gen/00-create-gitea-db.sql"
#updatescripts: ["/usr/share/eole/db/gitea/updates/gitea-update-1.sql"]
%set cnt_prefix = %%getVar('container_path_reseau', '')
pwd_files:
- {file: '%%cnt_prefix/etc/gitea/conf/app.ini',
pattern: 'PASSWD="',
end_pattern: ';',
owner: 'root:www-data',
mod: '660' }

View File

@ -2,9 +2,9 @@
# PLEASE MAKE CHANGES ON CORRESPONDING CUSTOM CONFIG FILE
; App name that shows on every page title
APP_NAME = %%gogs_name
APP_NAME = %%gitea_name
; Change it if you run locally
RUN_USER = gogs
RUN_USER = git
; Either "dev", "prod" or "test", default is "dev"
RUN_MODE = prod
@ -15,28 +15,28 @@ SCRIPT_TYPE = bash
[server]
PROTOCOL = https
%if %%getVar('activer_revprox','non') == 'oui'
DOMAIN = %%gogs_web_name
DOMAIN = %%gitea_web_name
ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s/
%else
%if %%getVar('gogs_web_name', 'X-X-X-X') == 'X-X-X-X'
%if %%getVar('gitea_web_name', 'X-X-X-X') == 'X-X-X-X'
DOMAIN = %%adresse_ip_eth0
ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/
%else
DOMAIN = %%gogs_web_name
DOMAIN = %%gitea_web_name
ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s/
%end if
%end if
HTTP_ADDR =
HTTP_PORT = %%git_http_port
HTTP_PORT = %%gitea_http_port
; Disable SSH feature when not available
DISABLE_SSH = false
SSH_PORT = %%git_ssh_port
SSH_PORT = %%gitea_ssh_port
; Disable CDN even in "prod" mode
OFFLINE_MODE = false
DISABLE_ROUTER_LOG = false
; Generate steps:
; $ cd path/to/gogs/custom/https
; $ ./gogs cert -ca=true -duration=8760h0m0s -host=myhost.example.com
; $ cd path/to/gitea/custom/https
; $ ./gitea cert -ca=true -duration=8760h0m0s -host=myhost.example.com
;
; Or from a .pfx file exported from the Windows certificate store (do
; not forget to export the private key):
@ -55,14 +55,15 @@ LANDING_PAGE = explore
[database]
; Either "mysql", "postgres" or "sqlite3", it's your choice
DB_TYPE = mysql
HOST = %%container_ip_mysql:3306
NAME = gogs
USER = gogs
PASSWD=gogs1234
;FIXME FOR EOLEDB
HOST = %%getVar("container_ip_mysql","127.0.0.1"):3306
NAME = gitea
USER = gitea
PASSWD=gitea1234
; For "postgres" only, either "disable", "require" or "verify-full"
SSL_MODE = disable
; For "sqlite3" only
; PATH = %%gogs_db_file
; PATH = %%gitea_db_file
[admin]
@ -72,8 +73,8 @@ INSTALL_LOCK = true
SECRET_KEY = !#@FDEWREWR&*(
; Auto-login remember days
LOGIN_REMEMBER_DAYS = 7
COOKIE_USERNAME = gogs_awesome
COOKIE_REMEMBER_NAME = gogs_incredible
COOKIE_USERNAME = gitea_awesome
COOKIE_REMEMBER_NAME = gitea_incredible
; Reverse proxy authentication header name of user name
REVERSE_PROXY_AUTHENTICATION_USER = X-WEBAUTH-USER
@ -82,7 +83,7 @@ ACTIVE_CODE_LIVE_MINUTES = 180
RESET_PASSWD_CODE_LIVE_MINUTES = 180
; User need to confirm e-mail for registration
REGISTER_EMAIL_CONFIRM = false
%if %%getVar('gogs_registration','non') == 'oui'
%if %%getVar('gitea_registration','non') == 'oui'
; Does not allow register and admin create account only
DISABLE_REGISTRATION = false
%else
@ -94,12 +95,12 @@ REQUIRE_SIGNIN_VIEW = false
; Cache avatar as picture
ENABLE_CACHE_AVATAR = false
; Mail notification
%if %%getVar('gogs_mail','non') == 'non'
%if %%getVar('gitea_mail','non') == 'non'
ENABLE_NOTIFY_MAIL = false
%else
ENABLE_NOTIFY_MAIL = true
%end if
; More detail: https://github.com/gogits/gogs/issues/165
; More detail: https://github.com/gogits/gitea/issues/165
ENABLE_REVERSE_PROXY_AUTHENTICATION = false
ENABLE_REVERSE_PROXY_AUTO_REGISTRATION = false
; Do not check minimum key size with corresponding type
@ -113,7 +114,7 @@ DELIVER_TIMEOUT = 5
; Allow insecure certification
SKIP_TLS_VERIFY = false
%if %%getVar('gogs_mail','non') == 'oui'
%if %%getVar('gitea_mail','non') == 'oui'
[mailer]
ENABLED = true
; Buffer length of channel, keep it as it is if you don't know what it is.
@ -136,15 +137,15 @@ USE_CERTIFICATE = false
CERT_FILE = custom/mailer/cert.pem
KEY_FILE = custom/mailer/key.pem
; Mail from address, RFC 5322. This can be just an email address, or the "Name" <email@example.com> format
%if %%getVar('gogs_mail_from','M-M-M-M') == 'M-M-M-M'
%if %%getVar('gitea_mail_from','M-M-M-M') == 'M-M-M-M'
FROM = %%system_mail_from
%else
FROM = %%gogs_mail_from
FROM = %%gitea_mail_from
%end if
%if %%getVar('gogs_mail_auth','non') == 'oui'
%if %%getVar('gitea_mail_auth','non') == 'oui'
; Mailer user name and password
USER = %%gogs_email_user
PASSWD = %%gogs_email_password
USER = %%gitea_email_user
PASSWD = %%gitea_email_password
%end if
%else
[mailer]
@ -303,7 +304,7 @@ RECEIVERS =
LEVEL =
; Either "mysql" or "postgres"
DRIVER =
; Based on xorm, e.g.: root:root@localhost/gogs?charset=utf8
; Based on xorm, e.g.: root:root@localhost/gitea?charset=utf8
CONN =
[git]

View File

@ -1,6 +1,6 @@
server {
listen 80;
server_name %%gogs_web_name;
server_name %%gitea_web_name;
return 301 https://$host$request_uri;
}
@ -11,13 +11,13 @@ server {
ssl_certificate_key %%server_key;
ssl_client_certificate /etc/ssl/certs/ca.crt;
access_log /var/log/nginx/revprox.revprox_http.access-ssl.log;
server_name %%gogs_web_name;
server_name %%gitea_web_name;
error_page 403 404 502 503 504 /nginx.html;
location = /nginx.html{
root /usr/share/nginx/www;
}
location / {
proxy_pass https://%%container_ip_forge:%%git_http_port;
proxy_pass https://%%container_ip_forge:%%gitea_http_port;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;