summaryrefslogtreecommitdiff
path: root/SETUP.md
blob: fc5dd4c96b9b08908a9b184b70d8134e570273d9 (plain)

Setting up source hosting

Special strings

NB! This documentation includes the following special strings used e.g. when generating a documentation website:

feature_root: /usr/local/share/redpill/source-hosting redpill_root: /usr/local/share/redpill

gitshellhost: git.example.org

Prerequisites

All actions are done on the server git.example.org, except collecting your SSH public key.

Gitolite service need to know the public SSH key of its administrator. You can let it ask during install, but it may be more convenient to preconfigure that information instead.

On your local host, print your SSH public key e.g. with this command from your personal system (adapt to replace ed25519 if your SSH keypair use a different algorithm):

cat ~/.ssh/id_ed25519.pub

On the server git.example.org, preconfigure git user with above public key (the whole line without newline) as $YOURKEY, and install needed packages:

echo gitolite3 gitolite3/adminkey select "$YOURKEY" | sudo debconf-set-selections
echo gitolite3 gitolite3/gituser select git | sudo debconf-set-selections
sudo apt install gitolite3 myrepos git-daemon-sysvinit cgit cmark highlight

Silence noisy git warnings about migrating to non-oppressive language:

sudo -u git git config --global init.defaultBranch main

Enable hook

Clone the redpill feature project for source-hosting and register with myrepos (to ease later update):

sudo mkdir --parents /usr/local/share/redpill
cd /usr/local/share/redpill
sudo git clone https://source.redpill.dk/source-hosting.git
cd source-hosting
sudo mr reg

Edit the file /etc/gitolite3/gitolite.rc to have LOCAL_CODE point into the project cloned above, i.e. the line should look like this:

LOCAL_CODE =>  "/usr/local/share/redpill/source-hosting/lib/gitolite3",

Refresh gitolite setup by running this command:

sudo -u git gitolite setup

Web export

When some git project need to be exported to a website, a base directory should first be prepared.

Grant access for gitolite to write below /var/www with these commands:

sudo mkdir /var/www/gitolite3
sudo chown git:www-data /var/www/gitolite3

Configure web access

Adapt the file /etc/default/git-daemon:

GIT_DAEMON_ENABLE=true
GIT_DAEMON_USER=gitdaemon
GIT_DAEMON_BASE_PATH=/srv/git
GIT_DAEMON_DIRECTORY=/srv/git/source.example.org

# Additional options that are passed to the Daemon.
GIT_DAEMON_OPTIONS="--interpolated-path=/srv/git/%H/%D --user-path=public_git --export-all"

Adapt the file /etc/cgitrc:

css=/cgit-css/cgit.css
logo=/cgit-css/cgit.png

include=/usr/local/share/redpill/source-hosting/etc/cgitrc