all repos — aaoth.xyz @ 5aae3e80a31476c5762720489f911a989891496d

aaoth.xyz website

_posts/2020-12-09-fossil-autoupdate-cronjob.md (view raw)

 1---
 2title: auto-update fossil using cron(8)
 3tags: openbsd tutorial fossil
 4date: 2020-12-09T01:37+03:00
 5---
 6
 7i'm running an instance of fossil on my openbsd server (it's the same that is
 8powering this website) and for some reason i want it to be up-to-date. more
 9presicely, bleeding edge.
10
11<!--more-->
12
13for that i added this part to my `daily.local` script (for those of you who
14don't know, it's script that running every day by cron(8)):
15
16```
17cd /root/fossil && \
18    /usr/local/bin/fossil up | \
19    awk '/changes:/ {
20        if ($2 == "None."){
21            print "No changes, exiting...";
22            exit 1
23        }else{
24            out="";
25            for(i=2; i<=NF; i++){
26                out=out" "$i
27            };
28        }
29        print out;
30        exit 0
31    }' && \
32    /usr/local/bin/fossil revert src/repolist.c >/dev/null && \
33    patch src/repolist.c /var/www/htdocs/fsl.aaoth.xyz/repolist.c.patch \
34        >/dev/null && \
35    ./configure --static >/dev/null && \
36    make >/dev/null && \
37    cp fossil /var/www/bin && \
38    make distclean >/dev/null && \
39    /usr/local/bin/fossil stat
40```
41
42it is very straightforward and simple. firstly, it's changing directory into
43place, where i have fossil checkout (made with `fossil clone` and
44`fossil open`). then it runs `fossil up` and piping it to a small awk script
45that is checking, is there any changes pulled down.
46
47after that there's one interesting part. `fossil revert src/repolist.c` is there
48because i modified it a little bit to make my [repolist][1] page look better.
49after my edits, i exported a patch by executing:
50
51```
52fossil diff > repolist.c.patch
53```
54
55maybe it would be better if i committed those changes, but i don't want to hold
56a full fossil repo among my other fossils, because its history is fairly long.
57and also i'm not very good at c programming, so i'll keep it as is for now.
58if you're interested this patch is free to use and you can [check it out][2].
59
60after that, there's just a normal configure and make procedure and also final
61cleanup.
62
63i also have a mail server running there, so i get an email of what changes were
64applied and that everything went fine.
65
66[1]:https://fsl.aaoth.xyz
67[2]:https://fsl.aaoth.xyz/repolist.c.patch