diff --git a/Makefile b/Makefile index 0245ac5..49128ec 100644 --- a/Makefile +++ b/Makefile @@ -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= diff --git a/dicos/50_gitea.xml b/dicos/50_gitea.xml new file mode 100644 index 0000000..9189e7a --- /dev/null +++ b/dicos/50_gitea.xml @@ -0,0 +1,109 @@ + + + + + + + + + 443 + + + + + apt-transport-https + git-core + + + + forge + + gitea_http_port + + + sshd + + + + + + + non + + + + + Forge Numérique EOLE + + + non + + + + non + + + + + + + /var/db/gitea/repo + + + non + + + 6000 + + + 2222 + + + /var/db/gitea/gitea.db + + + localhost + + + + + + non + gitea_mail_from + + + non + gitea + gitea-nginx + gitea + forge + gitea_ssh + + + non + gitea_email_user + gitea_email_password + + + oui + OR + activer_revprox + non + oui + non + + + non + gitea-nginx + gitea_with_nginx + + + oui + gitea_without_nginx + + + + Activer la forge Gitea, Gitea est une forge basée sur Git clone de github (fork de gogs) + + diff --git a/dicos/50_gogs.xml b/dicos/50_gogs.xml deleted file mode 100644 index ff4ac88..0000000 --- a/dicos/50_gogs.xml +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - 443 - - - - - apt-transport-https - - - - gogs - - git_http_port - - - sshd - - - - - - - non - - - - - Forge Numérique EOLE - - - non - - - - non - - - - - - - /var/db/gogs/repo - - - non - - - 6000 - - - 2222 - - - /var/db/gogs/gogs.db - - - localhost - - - - - - non - gogs_mail_from - - - non - gogs - gogs-nginx - gogs - forge - gogs_ssh - - - non - gogs_email_user - gogs_email_password - - - oui - OR - activer_revprox - non - oui - non - - - non - gogs-nginx - gogs_with_nginx - - - oui - gogs_without_nginx - - - - Activer la forge gogs, gogs est une forge basée sur Git clone de github - - diff --git a/eole-gitea.mk b/eole-gitea.mk new file mode 100644 index 0000000..a1c95f7 --- /dev/null +++ b/eole-gitea.mk @@ -0,0 +1 @@ +systemd_DATA_DIR := $(DESTDIR)/etc/systemd/system diff --git a/posttemplate/01-gogs-nginx b/posttemplate/01-gitea-nginx similarity index 100% rename from posttemplate/01-gogs-nginx rename to posttemplate/01-gitea-nginx diff --git a/pretemplate/01-gitea-init b/pretemplate/01-gitea-init new file mode 100755 index 0000000..fd97898 --- /dev/null +++ b/pretemplate/01-gitea-init @@ -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 - diff --git a/sql/conf/gen/gogs.py b/sql/conf/gen/gogs.py deleted file mode 100644 index 7d752c3..0000000 --- a/sql/conf/gen/gogs.py +++ /dev/null @@ -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) - diff --git a/sql/conf/passwords/gogs.ini b/sql/conf/passwords/gogs.ini deleted file mode 100644 index 02ad667..0000000 --- a/sql/conf/passwords/gogs.ini +++ /dev/null @@ -1,5 +0,0 @@ -[gogs] -username=gogs -template=PASSWD= -container=forge -filename=/etc/gogs/conf/app.ini diff --git a/systemd/forge.service b/systemd/forge.service new file mode 100644 index 0000000..eadb677 --- /dev/null +++ b/systemd/forge.service @@ -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 \ No newline at end of file diff --git a/tmpl/00-create-gogs-db.sql b/tmpl/00-create-gitea-db.sql similarity index 100% rename from tmpl/00-create-gogs-db.sql rename to tmpl/00-create-gitea-db.sql diff --git a/tmpl/51-gogs-nat_rules b/tmpl/51-gitea-nat_rules similarity index 100% rename from tmpl/51-gogs-nat_rules rename to tmpl/51-gitea-nat_rules diff --git a/tmpl/gitea-db.yml b/tmpl/gitea-db.yml new file mode 100644 index 0000000..ecf8169 --- /dev/null +++ b/tmpl/gitea-db.yml @@ -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' } + diff --git a/tmpl/gogs.conf b/tmpl/gitea.conf similarity index 90% rename from tmpl/gogs.conf rename to tmpl/gitea.conf index d97abb1..9400c89 100644 --- a/tmpl/gogs.conf +++ b/tmpl/gitea.conf @@ -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" 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] diff --git a/tmpl/gogs.nginx b/tmpl/gitea.nginx similarity index 91% rename from tmpl/gogs.nginx rename to tmpl/gitea.nginx index 8843a58..bb2aeb2 100644 --- a/tmpl/gogs.nginx +++ b/tmpl/gitea.nginx @@ -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;