webgui.pl - mount WebGUI templates as filesystem
webgui.pl /data/WebGUI/etc/webgui.conf /mnt
With this script, you can utilize Fuse
and Fuse::DBI
modules to mount
templates from WebGUI and edit them using command-line utilities (like vi
or ftp
).
It will present templates in WebGUI as directory tree consisting of
directories (which represent template's namespace) and files (which are
templates from database). If template name has slash (/
) in name, deeper
directories will be created.
Template files will have correct lengths and write permissions which are specified in WebGUI database.
Fuse::DBI
module (which is core of this utility) uses Fuse
perl
bindings. Perl bindings are rather new addition to Fuse
, so
you will need recent CVS version of Fuse
. Current stable version doesn't
include perl binding, so you will probably have to compile Fuse
yourself
(see FUSE documentation for details about compilation and installation).
After compilation and installation of fuse
kernel module and Fuse
perl
bindings for it, you will have to load fuse
module into kernel. For that,
you will have to be root. If you are not administrator on particular
machine, ask your admin to install and load fuse
module for you.
If you used fusermount
command before running this script, module will be
already loaded.
There is no support for creation of new templates, renaming, or deleting. Although those operations map nicely to file system semantics there are still possible only using WebGUI web interface.
Unlink command (rm
) is implemented on files with special function: it
will remove in-memory cache of particular template and reload it from
database. That enables usage of web interface to make small changes and then
continuing editing using this script without restarting it.
In-memory cache is populated with data about available templates when you
start this script. Currently only way to refresh template list (after you
create copy of template through web interface) is to remove directory using
rmdir
or rm -rf
.
Don't panic! Destructive operations in filesystem (rm
and rmdir
)
just invalidate in-memory cache and re-read data from database (this will
also change ctime of file, so your editor will probably notice that file has
changed).
In-memory cache is used to speed up operations like grep on templates. If it wasn't there, grep wouldn't be useful at all. I think this is acceptable compromise.
Every write operation will erase all templates on disk (so that next reload on browser will show your changes). It would be better if just changed template is erased, but this works well enough. You might notice performance penalty of this simplification if you are running very loaded production site.
You have to have write permission on uploads/temp/templates/
directory
for your WebGUI instance for this to work. If you don't Fuse::DBI
will
complain.
This script have embedded SQL queries for MySQL and PostgreSQL. Other databases could be supported easily. Contributions are welcomed.
Fuse::DBI
uses transactions (if your database supports them) to prevent
accidental corruption of data by reading old version. Depending on type of
database back-end, MySQL users might be out of luck.
Transport endpoint is not connected is very often error when Fuse perl
bindings exit without clean umount (through Fuse::DBI
umount
method or
with fusermount -u /mnt
command).
This script will automatically run fusermount -u /mnt
if it receives
above error on startup. If it fails, mount point is still in use (that
happens if you changed directory to mount point in other shell). Solution is
simple, just change directory in other back to $HOME
(with just cd
)
and re-run this script.
If this script complains about missing Data::Config
module, you will have
to point path at top which points to lib directory of WebGUI installation.
By default it points to /data/WebGUI
:
use lib '/data/WebGUI/lib/';
Fuse::DBI
website
http://www.rot13.org/~dpavlin/fuse_dbi.html
FUSE (Filesystem in USErspace)
website
http://fuse.sourceforge.net/
Dobrica Pavlinusic, <dpavlin@rot13.org>
Copyright (C) 2004 by Dobrica Pavlinusic
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.