THE OPEN PITT What's cooking in Linux and Open Source in Western Pennsylvania =========================================================================== Issue 39 May 2008 www.wplug.org =========================================================================== In this issue: Accessing MoinMoin through E-Mail --------------------------------------------------------------------------- Coming Events May 18: 7th Annual WPLUG Open Source Picnic. 1pm to 6pm, Snyder Park, Whitehall The public is welcome at all events --------------------------------------------------------------------------- Accessing MoinMoin through E-Mail by Tom Rhodes Wikis are becoming a popular method for placing information on the web, with Wikipedia being probably the most visible example. The ease with which they can be edited, requiring no software other than a web browser, is a major attraction. But who says that a web interface is the only way to go? Why can't you post text to your wiki by e-mailing it? Right now, MoinMoin is the only wiki software I've found which supports such a feature. This article will cover how I set it up to work on my system. Installing MoinMoin on FreeBSD goes as follows: # cd /usr/ports/www/moinmoin && make install && make instance && make clean Linux users can look in their distribution's repositories for a MoinMoin package. The instance should now be in /usr/local/www/wiki if you've chosen the defaults. The display files are in /usr/local/share/moin and are usually not to be edited. If your installation lives in a different location, you'll have to adjust the paths used in the following steps to fit your circumstances. The Apache web server needs a directory with ExecCGI permissions and, for the use of .htaccess we'll describe later, AllowOverrides set to on. Putting the following into Apache's configuration file is sufficient for a wiki named "wiki" whose files live in the above locations: Alias /moin_static162/ "/usr/local/share/moin/htdocs/" ScriptAlias /wiki "/usr/local/www/wiki/cgi-bin/moin.cgi" Options ExecCGI AllowOverride AuthConfig Order allow,deny Allow from all Make sure to restart Apache so the configuration changes are loaded. Now edit the moin.cgi file. The invocation line needs fixed to: #!/usr/local/bin/python Or wherever you have the Python executable installed, instead of the call to env that currently exists. Now change the directory in the following line to match your setup: sys.path.insert(0, '/usr/local/www/wiki/cgi-bin/wikiconfig.py') Next you'll edit the wikiconfig.py file referenced above as shown below to set directory locations, add mail settings, and enable the XML-RPC interface. # Site name, used by default for wiki name-logo [Unicode] sitename = u'Toms Wiki' # a) if most wiki content is in a single language page_front_page = u"MyStartingPage" # Where your mutable wiki pages are. You want to make regular # backups of this directory. data_dir = '/usr/local/www/wiki/data/' # Where read-only system and help page are. You might want to share # this directory between several wikis. When you update MoinMoin, # you can safely replace the underlay directory with a new one. # This directory is part of MoinMoin distribution, you don't have # to backup it. data_underlay_dir = '/usr/local/www/wiki/underlay/' # The URL prefix we use to access the static stuff (img, css, js). # NOT touching this is maybe the best way to handle this setting # as moin uses a good internal default (something like # '/moin_static162' for moin version 1.6.2). # For Twisted and standalone server, the default will automatically # work. For others, you should make a matching server config (e.g. # an Apache Alias definition pointing to the directory with the # static stuff). url_prefix_static = '/moin_static162' You'll also need to fix up the mail section: # Mail ---------------------------------------------------------- # Configure to enable subscribing to pages (disabled by default) # or sending forgotten passwords. # SMTP server, e.g. "mail.provider.com" (None to disable mail) mail_smarthost = "example.com" # The return address, e.g u"J\xfcrgen " [Unicode] mail_from = u"wiki@example.com" # "user pwd" if you need to use SMTP AUTH mail_login = "" # Added by trhodes for mail import: mail_import_wiki_addrs="trhodes@FreeBSD.org" mail_import_secret= u"mypassword" Now go to the very bottom and add this if it doesn't already exist: # Actions excluded defaults to ['xmlrpc'] actions_excluded= [] Now create the cgi-bin directory and copy those two files to that directory: # mkdir cgi-bin # cp moin.cgi wikiconfig.py cgi-bin/ Now find the mailimport.py file; if it isn't in the current directory, run a search for it. Copy that file into the cgi-bin directory as well, and set the variables as follows. # This is the configuration file for the mail import client # This secret has to be known by the wiki server mail_import_secret = u"mypassword" # The target wiki URL mail_import_url = u"http://example.com/wiki/moin.cgi?action=xmlrpc2" The URL to use will be specific to your situation, and the secret must match the one in wikiconfig.py. Next edit sendmail's aliases file to add the address where you want your wiki to receive mail: wiki: "|/usr/local/bin/moin --wiki-url=http://example.com/wiki/moin.cgi --config-dir=/usr/local/www/wiki/cgi-bin/ xmlrpc mailimport" Then you'll rebuild the aliases database and restart sendmail with: # newaliases # /etc/rc.d/sendmail restart Finally, fix the permissions and ownership of the files. Both of these may not be required, or more restrictive permissions is a possibility--I just trust my users, perform consistent backups, and prefer not fighting with sendmail about executing binaries with different permissions than it likes: # find /usr/local/www/wiki | xargs chown daemon:daemon # find /usr/local/www/wiki | xargs chmod 775 Everything should be good now. Give it a try by sending e-mail to the address we configured in aliases (in this example, wiki@). Use the mail log file along with the Apache error log to debug any problems, but hopefully this should all be working. You can include MoinMoin markup in your e-mail. The help file has an in-depth explanation of the syntax--I recommend looking it over before adding your data. Trust me, it's very different from Mediawiki markup. If you want to install wiki themes, the primary theme directory goes into /usr/local/share/moin/htdocs and the python configuration file should be in /usr/local/lib/python2.5/site-packages/MoinMoin/theme. Now you should be able to go to the URL we defined above in the Apache configuration, /wiki, and check out your brand new wiki! This wiki install is by default completely open to the public, and if you try to use a .htaccess file to hide it, you'll soon realize that it breaks the e-mail support. Is it possible to password-protect the wiki and still allow e-mails to come in? Yes, with the following .htaccess file, which took me a few moments to figure out: AuthName "Wiki" AuthType Basic AuthUserFile /usr/local/share/moin/.htpasswd Require valid-user Order deny,allow Deny from all Allow from nnn.nnn.nnn.nnn Satisfy Any For nnn.nnn.nnn.nnn you need to substitute the IP address associated with the domain name or, if using name-based virtual hosting, use the host's primary IP address. Don't forget to create the .htpasswd file with the htpasswd utility. For years, my quick notes, mini-howtos, etc. have gone into a notebook or I just e-mailed them to myself. Now I can e-mail my wiki and store the data there. It's searchable, easy to edit, viewable from anywhere, and saves paper. A Pittsburgh native, Tom Rhodes is currently a senior system administrator, contractor, and developer in the Washington, DC area. His hobbies include being an active FreeBSD committer, homebrewing beer, vegan cooking, and ranting. Tom is trying his best to avoid becoming an OpenSolaris committer. =========================================================================== The Open Pitt is published by the Western Pennsylvania Linux Users Group Editor: Vance Kochenderfer Copyright 2008 Western Pennsylvania Linux Users Group. Any article in this newsletter may be reprinted elsewhere in any medium, provided it is not changed and attribution is given to the author and WPLUG.