]> sipb.mit.edu Git - ikiwiki.git/blob - doc/tips/inside_dot_ikiwiki.mdwn
Merge branch 'master' of git://git.ikiwiki.info
[ikiwiki.git] / doc / tips / inside_dot_ikiwiki.mdwn
1 [[!meta title="inside .ikiwiki"]]
2
3 The `.ikiwiki` directory contains ikiwiki's internal state. Normally,
4 you don't need to look in it, but here's some tips for how to do so if
5 you need/want to.
6
7 ## the index
8
9 `.ikiwiki/indexdb` contains a cache of information about pages.
10 This information can always be recalculated by rebuilding the wiki.
11 (So the file is safe to delete and need not be backed up.)
12 It used to be a (semi) human-readable text file, but is not anymore.
13
14 To dump the contents of the file, enter a perl command like this.
15
16         joey@kodama:~/src/joeywiki/.ikiwiki> perl -le 'use Storable; my $index=Storable::retrieve("indexdb"); use Data::Dumper; print Dumper $index' | head
17         $VAR1 = {
18           'index' => {
19                      'ctime' => 1199739528,
20                      'dest' => [
21                                  'index.html'
22                                ],
23                      'mtime' => 1199739528,
24                      'src' => 'index.mdwn',
25                      'links' => [
26                                   'index/discussion',
27
28 ## the user database
29
30 `.ikiwiki/userdb` is the user database, which records preferences of all
31 web users.
32
33 To list all users in the database, enter a perl command like this.
34 Note that the output can include both registered users, and known
35 openids.
36
37         joey@kodama:~/src/joeywiki/.ikiwiki> perl -le 'use Storable; my $userinfo=Storable::retrieve("userdb"); print $_ foreach keys %$userinfo'         
38         http://joey.kitenet.net/
39         foo
40
41 To list each user's email address:
42
43         joey@kodama:~/src/joeywiki/.ikiwiki> perl -le 'use Storable; my $userinfo=Storable::retrieve("userdb"); print $userinfo->{$_}->{email} foreach keys %$userinfo'
44         
45         joey@kitenet.net
46
47 To dump the entire database contents:
48
49         joey@kodama:~/src/joeywiki/.ikiwiki> perl -le 'use Storable; my $userinfo=Storable::retrieve("userdb"); use Data::Dumper; print Dumper $userinfo'
50         $VAR1 = {
51                   'http://joey.kitenet.net/' => {
52                                                   'email' => 'joey@kitenet.net',
53         [...]
54
55 Editing values is simply a matter of changing values and calling `Storable::nstore()`.
56 So to change a user's email address:
57
58         joey@kodama:~/src/joeywiki/.ikiwiki> perl -le 'use Storable; my $userinfo=Storable::retrieve("userdb"); $userinfo->{"foo"}->{email}=q{foo@bar}; Storable::lock_nstore($userinfo, "userdb")'
59
60 To remove that user:
61         
62         joey@kodama:~/src/joeywiki/.ikiwiki> perl -le 'use Storable; my $userinfo=Storable::retrieve("userdb"); delete $userinfo->{"foo"}; Storable::lock_nstore($userinfo, "userdb")'
63
64 I've not written actual utilities to do this yet because I've only needed
65 to do it rarely, and the data I've wanted has been different each time.
66 --[[Joey]]
67
68 ## the session database
69
70 `.ikiwiki/sessions.db` is the session database. See the [[!cpan CGI::Session]]
71 documentation for more details.
72
73 ## lockfiles
74
75 In case you're curious, here's what the various lock files do.
76
77 * `.ikiwiki/lockfile` is the master ikiwiki lock file. Ikiwiki takes this 
78   lock before reading/writing state.
79 * `.ikiwiki/commitlock` is locked as a semophore, to disable the commit hook
80   from doing anything.
81 * `.ikiwiki/cgilock` is locked by the cgi wrapper, to ensure that only 
82   one ikiwiki process is run at a time to handle cgi requests.
83
84 ## plugin state files
85
86 Some plugins create other files to store their state. 
87
88 * `.ikiwiki/aggregate` is a plain text database used by the aggregate plugin
89   to record feeds and known posts.
90 * `.ikiwiki/xapian/` is created by the search plugin, and contains xapian-omega
91   configuration and the xapian database.