vl-dcc
DCC generation for the vacumm laboratory.
install & activate
Create a file .git/hooks/pre-push
in the GIT repository with the following
content:
#!/bin/bash
# In the case of "git push --tags", writes the short tag value to the
# VERSION file in the top level directory of the Git repository
toplevel=$(git rev-parse --show-toplevel)
f=${toplevel}/VERSION
if [ ! -f "$f" ]; then
touch "$f"
git add "$f"
fi
old_version=$(cat $f)
new_version=$(git describe --tags --abbrev=0 2>/dev/null)
if [ "$old_version" != "$new_version" ]; then
echo "$new_version" > "$f"
git commit -am "update to version '"$new_version"'"
git push origin # Is required because normal push does not necessarily happen
fi
exit 0
Then make this file executable:
chmod 755 .git/hooks/pre-push
Do the following steps with root permission on the server installation:
mkdir -p /usr/local/share/vl-dcc
cd /usr/local/share/vl-dcc
curl --silent --output - \
https://gitlab1.ptb.de/niepra01/vl-dcc/-/archive/master/vl-dcc-master.tar \
| tar xf - --strip-components=1 # only once
python3 -m venv .
source bin/activate
pip3 install pip-tools
pip-compile
chown -R nobody.nobody ../vl-dcc
systemctl daemon-reload # if already exist
systemctl link $PWD/vl-dcc.service
systemctl enable vl-dcc.service # make permanent
systemctl start vl-dcc.service
systemctl status vl-dcc.service # running?
journalctl -f --unit vl-dcc.service # run-time check
api
vl-dcc/<cer_doc_id> (GET)
Returns a xml version of a certificate-document:
curl -s http://localhost:5006/vl-dcc/2019-75046 > dcc-2019-75046.xml
Returns a xml version of a certificate-document with validation at once:
curl -s http://a73434:5006/vl-dcc/2019-75046 | \
curl -s -X POST -H "Content-Type: text/xml" -d @- http://a73434:5005/validate
zz (GET)
returns a xml version based on the dummy certificate-document (zz.json
)
for test purpose.
curl -s http://localhost:5006/zz > zz.xml
update (POST)
pulls the latest program version from origin master
http://server:port/update
This URL must be specified in the GitLab server under "Settings / Webhooks" (no secret token). "Tag Push Events" must be activated. The following information sent by GitLab is evaluated in order to obtain all files of the Ropositorium via the requested tar stream:
{
...
"repository": {
"homepage": "https://a75436.berlin.ptb.de/vaclab/vl-dcc",
"name": "vl-dcc"
}
...
}
version (GET)
curl -s http://localhost:5006/version
More hints
Pretty printing the xml code:
cat foo.xml | tidy -xml --indent auto --indent-cdata yes --quiet yes \
--wrap 0 --tab-size 2 - > bar.xml