Create Installation instructions authored by Nikolai.Hartmann's avatar Nikolai.Hartmann
# Install packages on debian host system
```bash
apt install acl dnf rpm git systemd-container python3-venv
```
# Clone git and checkout config files
```bash
git clone https://gitlab.physik.uni-muenchen.de/Nikolai.Hartmann/xcache-nspawn-lrz.git
# as root in repository dir
cd xcache-nspawn-lrz
# optional, in order to be able to push into the dir if no modifications
git config receive.denyCurrentBranch updateInstead
# remove everything, except .git
rm -r *
# checkout files
git reset --hard
# check tracked files
git ls-files /
# remove README
rm /README.md
git update-index --assume-unchanged /README.md
```
# Build image
```bash
cd /var/local/mkosi
# if not existing yet
mkdir mkosi.cache
# seems mkosi-10 from backports is not working
# most recent version from github works
# The following commands will install mkosi from the latest github version
# into a virtual environment inside the directory .venv
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install git+https://github.com/systemd/mkosi.git
# generate image (mkosi command available after source .venv/bin/activate)
mkosi -i -t directory -o /var/lib/machines/xcache-$(date +%Y-%m-%d-%H%M)
```
# Create xrootd user in host system
We will map the xrootd user id inside the container (typically 999) to one shifted by 65536 * 10 on the host system. This is an arbitrary choice and one should check this range of user ids is not used by anything else.
```bash
# for some reason that command might add a carriage return (therefore the sed) ...
XRD_UID_INSIDE=$(systemd-nspawn -D /var/lib/machines/<img-name> id -u xrootd | sed 's/\r//')
let "XRD_UID_HOST = $XRD_UID_INSIDE + 65536 * 10"
useradd --no-create-home --system -u $XRD_UID_HOST xrootd
```
# Directories for bind mounts
Create directories for bind mounts and make them owned by xrootd where nescessary
```bash
mkdir -p /var/spool/xrootd /var/run/xrootd /srv/data/xrootd/namespace /srv/data/xrootd/xrdcinfos /srv/data/xrootd/data
chown xrootd /var/spool/xrootd /var/run/xrootd /srv/data/xrootd/namespace /srv/data/xrootd/xrdcinfos /srv/data/xrootd/data
# if not existing
mkdir -p /etc/grid-security
# if running with authentication and need host key
setfacl -m "u:xrootd:r" /etc/grid-security/hostkey.pem
```
# Start and enable xcache service running in container
The running image has to be linked to `/var/lib/machines/xcache` in order to pick up the configuration in `/etc/systemd/nspawn/xcache.nspawn`.
```
ln -s /var/lib/machines/{<img-name>,xcache}
machinectl start xcache
machinectl enable xcache
```
\ No newline at end of file