Gitea A painless self-hosted Git service

module

(Mark Verlinde) #1

I’am working an a new feature Gitea, which is nice to have and fun to run on a RPI. :grinning:

It not so easy to setup from the command-line because most of the initialization is done at the first visit to the web interface. I figured out how to do it any way but encounter on problem which i just can’t solve.

in short the problem is the order of setup which can be done manual but can figure out how to do it with e-smith:

  1. create a new mysql database and load tables in to it
  2. write record to database with Pam login source
  3. expand templates with the mysql credentials
  4. run (bash) script to add local admin user
  5. start service

in bash scrips doing it manually it looks like this:

#!/bin/bash

# create new data base
password=`perl -e "use NethServer::Password; print NethServer::Password::store('giteaPass');"`

/usr/bin/mysql --defaults-file=/root/.my.cnf -e \
"CREATE DATABASE IF NOT EXISTS gitea DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
/usr/bin/mysql --defaults-file=/root/.my.cnf -e \
"CREATE USER gitea@localhost IDENTIFIED BY '$password';" 
/usr/bin/mysql --defaults-file=/root/.my.cnf -e \
"GRANT ALL PRIVILEGES ON gitea .* TO gitea@localhost;"

# write tables to it
mysql --defaults-file=/root/.my.cnf gitea < gitea-mysql-sample.sql

# Add PAM login source
epoch=$(date +%s)
/usr/bin/mysql --defaults-file=/root/.my.cnf -e \
"INSERT INTO gitea . login_source (id, type, name, is_actived, is_sync_enabled, cfg, created_unix, updated_unix) 
VALUES ('1', '4', 'Nethserver', '1', '0', '{\"ServiceName\":\"password-auth\"}', '$epoch', '$epoch');"

now (3) expand templates, then (4)

#!/bin/bash

# Add local admin user
pushd /var/lib/gitea
su gitea -c "/bin/gitea/gitea admin create-user --name gitea --password 'gitea' --email gitea@havak.lan --admin --config /etc/gitea/app.ini"
popd

A little bit to much information, my curllpit is to do (4) run a script after expanding templates.

Any directions? :confused:


(Marc) #2

I’m not the best one to give advice on this but if using templates2expand:

order of implicit actions:
You should normally link your action scripts in the range S10 to S80 so that they occur after templates2expand and before services2adjust.
The generic_template_expand action is currently run at S05 and adjust-services is run at S90.

Or as part of an action script:


(Mark Verlinde) #3

Nevertheless you opened my eyes and solved it :grinning:

Stupid of me not to think about an expand-template in the bash-conf-script


(Mark Verlinde) #4

It’s still rough around the edges but we have a runner.

You can have a sneak preview on nethsever-arm 7.5.1804 (32 bit) :grinning:

yum --enablerepo=nethserver-testing install nethserver-gitea

local admin = gitea
password = gitea

nethersever (ldap) users must login in with the short username and their own password.

Known to work:

  • creating repos
  • cloning / pushing over https and ssh
  • creating tags (releases)
  • migrate (clone) directly from github

Still to DO:

  • mailer
  • backup